CDonnerer / xgboost-distribution

Probabilistic prediction with XGBoost.
MIT License
100 stars 17 forks source link

Error when calling predict regarding check_is_fitted #95

Open arandomgoodguy opened 1 year ago

arandomgoodguy commented 1 year ago

Hi, I have used XGBDistribution model trained by me for very long time, before it was all fine, but recently something strange happened.

When I call model.predict(), it give me this error, using version of 0.2.4

NotFittedError: This XGBDistribution instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.

https://github.com/scikit-learn/scikit-learn/blob/8ae5f186986667bc3042a36f5d23e352acc40154/sklearn/utils/validation.py#L1408

It may because of people in scikit_learn recently change some code regarding function check_is_fitted since this year every time I load my model and predict, it is all fine.

But even if with I delete the check_is_fitted line and run again, it says

AttributeError: 'XGBDistribution' object has no attribute '_starting_params'

That's weird, why my trained model didn't have this attribute, and why it can predict without it through more than 1 year and then tell me now it need it to predict? I think if the model is trained in 0.2.4, it doesn't save this attribute, if you train a same model using 0.2.8, it will save that attribute so the error will not happen. So it seems like now we needs a way to predict without knowing the _starting_params.

What trick do you think can solve this error, otherwise my trained model is just useless now.