I'm having issues loading a pretrained xgboost model using the following code:
xgb_model = pickle.load(open('churnfinalunscaled.pickle.dat', 'rb'))
And when I do that, I get the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-29-31e7f426e19e> in <module>()
----> 1 xgb_model = pickle.load(open('churnfinalunscaled.pickle.dat', 'rb'))
ModuleNotFoundError: No module named 'sklearn.preprocessing._label'
I haven't seen anything online so any help would be much appreciated.
The ModuleNotFoundError: No module named ‘xgboost’ error occurs when we try to import the ‘ xgboost ‘ module without installing the package or if you have not installed it in the correct environment. We can resolve the issue by installing the xgboost module by running the pip install xgboost command.
In Python, ModuleNotFoundError: No module named ‘xgboost’ error occurs if we try to import the ‘ xgboost ‘ module without installing the package or if you have not installed it in the correct environment.
Presumably, you'll have to run the command: conda install -c conda-forge xgboost pip install -U scikit-learn To install your machine learning packages. Share Improve this answer
xgboost is not a built-in module (it doesn’t come with the default python installation) in Python; you need to install it explicitly using the pip installer and then use it. XGBoost is an optimized distributed gradient boosting library designed to be highly efficient , flexible, and portable.
I was able to solve my issue. Simply update scikit-learn
from 0.21.3 to 0.22.0 seems to solve the issue. Along the way I have to update my pandas
version to 0.25.2 as well.
The cue is provided in this link: https://www.gitmemory.com/vruusmann, where it states:
During Scikit-Learn version upgrade from 0.21.X to 0.22.X many modules were renamed (typically, by prepending an underscore character to the module name). For example, sklearn.preprocessing.label.LabelEncoder
became sklearn.preprocessing._label.LabelEncoder
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With