-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clarification Chapter 3] FutureWarning: elementwise comparison failed; returning scalar instead #583
Comments
Hi Vedanthv, I noticed this too. The problem seems to occur because "y_train" is created as type "object." Then the condition "y_train == 5" checks whether these objects are equivalent to integers - which they aren't, so every element returns False. Here, we can see that the first element ought to be True.
My solution was to cast y_train as type integer, and reshape it in the following step (SGDClassifier expects a 2D array in the correct shape).
|
Hi Ian, |
Thanks for your question @vedanthv , and thanks for the solution @ian-coccimiglio ! Btw, the third edition of the book will come out in October 2022, and the updated notebooks are available at https://github.com/ageron/handson-ml3 Hope this helps! |
This is a warning I got while running the Binary Classifier (5 Detector) code from Chapter 3 specifically when I was creating the subset of the dataset with only 5's on the train and test set.
This error forbids me from running the SGDClassifier in the next code block of the book/jupyter notebook since y is not 1D array.
Also realized that the same error is still open as an issue on numpy and pandas repositories.
I'm using the versions mentioned in the readme of this repository.
Any help regarding this is appreciated. If a similar issue exists, please leave a comment and I'll close this.
Thanks!
The text was updated successfully, but these errors were encountered: