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?

1 Like