-
Notifications
You must be signed in to change notification settings - Fork 3.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
Weights & Early Stopping with LGBMRegressor #4551
Comments
Thanks for using LightGBM! We need some more information to help you.
|
From Mini-Conda list:
Not sure how ppl usually do this, but this minimal code will reproduce error as long as pickle objects are OK. It wouldn't upload here, so I put into a link in my repository:
Thanks Again |
Thanks very much! Through that information, you've shared that you're using Python 3.9, version 3.2.1 of I personally don't open pickle files whose origin I don't know about, since it is possible to define arbitrary code to run when an object is unpickled. You could create a fully-reproducible example for this case by, for example
|
Will csv work? Got it to do the same with csv files.
|
Hey @John64! Thanks a lot for the repro!
This is the same error as in #4534. And the solution is in #4534 (comment).
Just fix these lines in your code:
Note that
|
Thank You very much Striker. Working Great |
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. |
I've been using LightGBM for a while, but mostly with classification & never weights. I have a basic pandas dataframe with the weights in a column. I can't get an early stopping LGBMRegressor, utilizing 'mae', to run. Keep getting this error:
('Wrong type(float) for weight.\nIt should be list, numpy 1-D array or pandas Series',) Wrong type(float) for weight. It should be list, numpy 1-D array or pandas Series
Here is how the model is declared:
model fit causes error:
X_test & X_train are pandas dataframes with y_test & y_train being pandas series
I've tried various combinations of .values, .to_list(), and .ravel() as one post online had said this can happen if the dataframe format doesn't match the weights formats (mis-match of formats) --but not finding a solution. Always the same error as long as "eval_sample_weight" is being given. Without it, everything appears to run, but of course the early_stopping will be equally weighting all samples in the eval_set, creating error.
Hoping someone else has run into this or knows what the error is referencing. There are no nans/nulls in the weightings & they're the correct length. Format for the weighting column in pandas is float64 & all values are between ~.03 and ~.078.
I'm running this in parallel and some of the .to_lists() and .values appear to be slowing things down, so if someone has a cleaner solution to train with a Dataframe, that'd be great. Any help (examples, links, general advice...) would be appreciated. I'm out of ideas. Thank You
The text was updated successfully, but these errors were encountered: