I built a XGBClassifier model using Xgboost 1.4.2 version and saved in S3 in pickle format.
from xgboost import XGBClassifier
xgb_model = XGBClassifier()
xgb_model.fit(x_Traintfidf, y_Train)
xgb_predictions = xgb_model.predict(x_Testtfidf)
xgb_predictions = [round(value) for value in xgb_predictions]
from sklearn.metrics import accuracy_score
accuracy = accuracy_score(y_Test.to_list(), xgb_predictions)
print("Accuracy: %.2f%%" % (accuracy * 100.0))
# Save model to s3 as pickle file.
Next, I read back in the pickled model from s3 and when I try to do predictions, it throws the error:
AttributeError: 'XGBModel' object has no attribute 'enable_categorical'
I have a tf-idf transformed matrix, I am passing in to get predictions.
Any idea why I get the error above that when I unpickle the model and do predictions?
You might want to double check the xgboost version in your virtual env using pip list | grep xgboost to make sure its actually 1.4.2.
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