@Michael Okelolaโ :
The error message 'XGBModel' object has no attribute 'feature_types' suggests that the XGBModel object does not have the attribute feature_types. This could happen if the model object was saved with an older version of XGBoost that did not include the feature_types attribute or if the model object was saved with a different library or version that did not have this attribute.
One possible solution is to retrain the XGBoost model with the latest version of XGBoost library and ensure that the feature_types attribute is included. Alternatively, you can try to investigate how the
XGBModel object was created and saved in the first place to determine if there were any issues with the saving process that might have caused the missing attribute.
Another option is to use the get_booster() method of the XGBModel object to obtain the underlying XGBoost Booster object, and then call the set_feature_types() method of the Booster object to set the feature types manually. Here's an example:
import xgboost as xgb
model = pickle.load(open('/.../model.pkl', 'rb'))
booster = model.get_booster()
booster.set_feature_types({'feature_name': 'feature_type'})
probs = booster.predict(dmatrix)
In the code above, you would replace feature_name with the actual name of your feature, and feature_type with the type of your feature, such as 'int' or 'float'. You can specify the feature types for all the features in your dataset this way.