-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
While predicting the model doesn't check if data dtypes have changed #3626
Comments
For categorical feature in pandas.DF, there is mapping (from categories to integer) saved in model. So if you convert it to numpy without that mapping, it produces the wrong results. |
Thanks for answering. But this is exactly why I'm suggesting this as a feature, not as a bug, because feeding numpy array accepted, but silently produces wrong results. |
@sbushmanov I think it is a trade-off. If we only accept the same data type in prediction, using a trained model will be limited. |
I think issuing at least a Warning is warranted. It took me half an hour to troubleshoot this one without a hint. |
Adding this as a sub-issue for |
This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Summary
Suppose we trained a model with a pandas df, some of the features defined as categorical. Then, if we feed a numpy array, the model silently accepts an array, but produces wrong (?) results. It would be nice to have:
Train demo:
Predict on df:
Predict on numpy array (result chnages):
The text was updated successfully, but these errors were encountered: