Programming Assignment: Explore the BBC news archive - C3W1_Assignment - Exercise 4: fit_label_encoder

Hello everyone,

I have the following case that I can’t figure it out.

My code response is the output below:

Vocabulary before adjustment: [None, ‘sport’, ‘business’, ‘politics’, ‘tech’, ‘entertainment’]
Vocabulary after adjustment: [‘sport’, ‘business’, ‘politics’, ‘tech’, ‘entertainment’]
Vocabulary of labels looks like this: [None, ‘sport’, ‘business’, ‘politics’, ‘tech’, ‘entertainment’]

First ten labels: [‘tech’, ‘business’, ‘sport’, ‘sport’, ‘entertainment’, ‘politics’, ‘politics’, ‘sport’, ‘sport’, ‘entertainment’]

First ten label sequences: [4 2 1 1 5 3 3 1 1 5]

But the Expected Output is:

Vocabulary of labels looks like this: [‘sport’, ‘business’, ‘politics’, ‘tech’, ‘entertainment’]

First ten labels: [‘tech’, ‘business’, ‘sport’, ‘sport’, ‘entertainment’, ‘politics’, ‘politics’, ‘sport’, ‘sport’, ‘entertainment’]

First ten label sequences: [3 1 0 0 4 2 2 0 0 4]

I wrote in my code extra prints for debugging purposes

Also after running the test code, I get this error:

Vocabulary before adjustment: [None, ‘cat’, ‘mouse’, ‘dog’]
Vocabulary after adjustment: [‘cat’, ‘mouse’, ‘dog’]
Failed test case: the number of entries in the vocabulary did not correspond to the number of unique labels when using 5 labels (3 unique). Check the vocabulary does not include a OOV token.
Expected: 3
Got: 4

Can somebody help?

Thanks!

Here’s a hint:
What happens when you customize the value of num_oov_indices to exclude oov tokens?

I was stuck at this thanks for giving the hint

So I had a problem with the notebook (assignment) for the last course (C2W4) which I attributed to incrementally making changes and not running the notebook from the top. But that assignment had a pre-trained model loaded, and I concluded that incremental changes were “corrupting” (unfavourably modifying?) the in-memory model so I could not make my training/accuracy numbers and successive runs were not deterministic.

This week I submitted after getting all the code/output to match the expected output, and all unit tests passed. AND THEN it graded my submission as if I still had the OOV token (like the problem mentioned in the previous posts.)

So, I went round and round on this – back to the docs, did I miss an additional option? And then I remember my previous “wound” from notebook artefacts and restarted my kernel and ran everything again. AND THEN submitted the SAME code. Yes, the SAME CODE.

This time the grader gave me the 100%.

HOWEVER, given this weird artefact did the grader get it right the 1st time or the second. There’s not enough data to know.

It may be useful to include in the submission notes some notebook artefacts that can undermine the student’s efforts. And how to guard against and solve them. I think that could be managed without giving away any answers.

–J

Mentors don’t have access to grader infrastructure. That said, a common mistake that learners make is not saving their changes before submission (which would explain the odd grader behavior).

If you submit the same notebook (i.e. saved at the same timestamp) twice and the grader docked points one time and not the other, it requires the staff to look into it. Please confirm if this is the case.

The grader does not use your results from running the notebook in the course environment. It has a completely different execution scope. It never looks at your results of the in-notebook tests.

The grader has its own set of independent test cases.

This supports the assessment that many grading issues are caused by not saving your notebook before you submit for grading.

Balaji,

For one submission I received 87.5% and the following submission I received 100%. I only remember restarting the kernel. It is possible I did not save my results before submitting. There may be no need for further investigation.

–J

TMosh,


The grader does not use your results from running the notebook in the course environment. It has a completely different execution scope. It never looks at your results of the in-notebook tests.

I full expect that would be the case. I was only pointing out that I was getting perfect results based on the feedback mechanisms provided in the lesson(s)/assignment(s) – i.e., unit tests and other expect output cells that are provided.

As I answered above, it is wholly possible I did not save my notebook before submission. But here’s the thing, I am not conditioned to save my notebook. After 20+ modules I can remember a time that I intentionally saved before submitting, and I never had this problem till now.

Now I know this can be a problem and I’ll adjust my behavior.

Thanks.

–J

Thanks