You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Edition 3, page 133/1457 (Kindle e-book), the date fit-transformed by OneHotEncoder is not sent into .toarray() and results in error -- onehotencoder ValueError: Shape of passed values is (2, 1), indices imply (2, 5). With current code in the book, Python sees df_test_unknown.shape as (2,1).
To Reproduce
Please copy the code that fails here, using code blocks like this:
Oh.. I think I found where the confusion is coming from.
In the book, the author suggested using dense matrix as just an alternative.
Alternatively, you can set sparse=False when creating the OneHotEncoder, in which case the transform() method will return a regular (dense) NumPy array directly.
Géron, Aurélien. Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow (p. 131). O'Reilly Media. Kindle Edition.
There is no code block on the book. So I used sparse encoder which caused this problem.
But in the notebook code in this repo, the cat_encoder is created with sparse_output=False option.
Thanks for helping us improve this project!
Before you create this issue
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml3/blob/main/INSTALL.md#update-this-project-and-its-libraries
Also please make sure to read the FAQ (https://github.com/ageron/handson-ml3#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml3/issues
Describe the bug
Edition 3, page 133/1457 (Kindle e-book), the date fit-transformed by OneHotEncoder is not sent into .toarray() and results in error -- onehotencoder ValueError: Shape of passed values is (2, 1), indices imply (2, 5). With current code in the book, Python sees df_test_unknown.shape as (2,1).
To Reproduce
Please copy the code that fails here, using code blocks like this:
Solution
Versions (please complete the following information):
Additional context
Maybe add to FaQ or elsewhere where you think readers will notice (buying a book again for just one fix is impractical)
The text was updated successfully, but these errors were encountered: