# GRADED FUNCTION: preprocess_dataset error - "name 'labels' is not defined"

Related topic: https://community.deeplearning.ai/t/re-graded-function-preprocess-dataset/708885

I am running in to the “name ‘labels’ is not defined” error while preprocessing the dataset before training.

Please advise!

The correction you made to the dataset where I mentioned you to use text_vectorizer for text and label_encoder for labels. I no where mentioned you to use dataset.map. So that is the incorrect correction you did.

Let me know if it stills throws any error, then we might have to look at your codes.

Also sharing a post comment link which will provide you to understand on checking if your other grade cells codes are recalled correctly. Please read comments with one instruction at a time, so you don’t misunderstand or confuse it.

Regards
DP

Thank you for your response.

I did all previous graded cells correctly, what was confusing me was the use of lambda inside dataset.map(lambda ). I was confused, even if I send text and labels as argument, and add the function recalls with arguments as the expression of lambda, why I was still getting “name ‘text’ or ‘labels’ is not defined” error!
This last part was confusing, I tried many other fixes [using another dataset.map or .adapt() for function recalls] that did not help solve the problem, instead resulted in different errors.
At last, I understood the expression part of lambda needs to be a tuple, so I just needed to put the function recalls within () !!!
Now all of it seems so obvious! lol!

4 Likes