use*_*057 6 python pickle xgboost
我使用 Xgboost 1.4.2 版本构建了 XGBClassifier 模型,并以 pickle 格式保存在 S3 中。
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.
Run Code Online (Sandbox Code Playgroud)
接下来,我读回 s3 中的 pickled 模型,当我尝试进行预测时,它会抛出错误:
AttributeError:“XGBModel”对象没有属性“enable_categorical”
我有一个tf-idf
变换后的矩阵,我正在传递以获得预测。
知道为什么当我取消模型并进行预测时会出现上述错误吗?
归档时间: |
|
查看次数: |
7569 次 |
最近记录: |