handson-ml2 icon indicating copy to clipboard operation
handson-ml2 copied to clipboard

Chapter 2 Question 5 Score failed

Open SichengYang opened this issue 3 years ago • 2 comments

I open Jupiter Notebook and run the program. It said score failed with lots of errors. Everything before seems works fine.

I do not know how to solve it. Thanks!

Screen Shot 2022-01-04 at 11 19 49 PM Screen Shot 2022-01-04 at 11 20 12 PM

SichengYang avatar Jan 05 '22 05:01 SichengYang

Hi @SichengYang , Thanks for your question. These errors are displayed but training continues, right? Do you see ValueError: Found unknown categories ['ISLAND'] in column 0 during transform? If so, then I believe the problem is not very important, it's just a warning, let me explain:

The ISLAND category is rare in the training set. So during K-fold cross-validation, it's possible for all instances of the ISLAND category to end up in the validation set, with none at all in the training set. This means that ISLAND will be considered an unknown category when the model gets evaluated against the validation set, which causes an error. That's not a big deal, it just means that we're missing out on a few hyperparameter combinations. You can ignore this problem, or if you prefer to avoid it completely, you need to tell the OneHotEncoder to ignore unknown categories rather than raise an error (which is the default behavior). This can be done by setting the handle_unknown = 'ignore' when creating the OneHotEncoder.

I hope this helps.

ageron avatar Jan 10 '22 08:01 ageron

Thank you!

SichengYang avatar Jan 10 '22 19:01 SichengYang