KeyError: 'i'. index of word 'i' should be 2

why im getting a keyerror

all my outputs are correct

Please click my name and message your notebook as an attachment.
Do remove code from all your posts on this thread.

I think you are skipping reading all markdown cells and code comments.
For instance, in function parse_data_from_file, you keep appending 1 to labels.
This is what the assignment instructions ask you to do:
The labels are originally encoded as strings (‘0’ representing negative and ‘4’ representing positive). You need to change this so that the labels are integers and 0 is used for representing negative, while 1 should represent positive.

Here’s another instance in train_val_split:
You’re using MAX_EXAMPLES to set the split point.
This is from the docstring: training split (float): proportion of the dataset to convert to include in the train set.

Consider function fit_tokenizer:
This is what MAX_EXAMPLES means: MAX_EXAMPLES: Max number of examples to use. Defaults to 160000 (10% of the original number of examples)This should not be used as a parameter fornum_words`.

Please redo the assignment from start and use local variables and function parameters instead of global variables whenever possible.

so should i change every 4 in the list to 1?

Pointed out a piece of code that’s incorrect inside parse_data_from_file. Please avoid such errors moving forward.