如何解决CatBoostError: catboost/libs/data/model_dataset_compatibility.cpp:53: Feature feature_49 在模型中是分类的,但在数据集中标记不同
我第一次使用 catboost
,但是当我尝试通过 predict_proba
预测类别概率时出现错误,我仅在设置 iterations > 50
时才会收到此错误,y_train
的值是 float
并且 X_train
包含 50 个特征并且都有 int
值,cat_features
是一个列表 range 0 to 49
,
我的代码:
from catboost import CatBoostClassifier
clf = CatBoostClassifier(
iterations=200,random_seed=42,learning_rate=0.1,custom_loss=['AUC','Accuracy']
)
clf.fit(
X_train,y_train,cat_features=cat_features,eval_set=(X_val,y_val),verbose=1,plot=True,)
错误信息:
CatBoostError Traceback (most recent call last)
<ipython-input-64-be92151f9ec3> in <module>
----> 1 predict = clf.predict_proba(test_)
/opt/conda/lib/python3.7/site-packages/catboost/core.py in predict_proba(self,data,ntree_start,ntree_end,thread_count,verbose)
4631 with probability for every class for each object.
4632 """
-> 4633 return self._predict(data,'Probability',verbose,'predict_proba')
4634
4635
/opt/conda/lib/python3.7/site-packages/catboost/core.py in _predict(self,prediction_type,parent_method_name)
2091 self._validate_prediction_type(prediction_type)
2092
-> 2093 predictions = self._base_predict(data,verbose)
2094 return predictions[0] if data_is_single_object else predictions
2095
/opt/conda/lib/python3.7/site-packages/catboost/core.py in _base_predict(self,pool,verbose)
1416
1417 def _base_predict(self,verbose):
-> 1418 return self._object._base_predict(pool,verbose)
1419
1420 def _base_virtual_ensembles_predict(self,virtual_ensembles_count,verbose):
_catboost.pyx in _catboost._CatBoost._base_predict()
_catboost.pyx in _catboost._CatBoost._base_predict()
CatBoostError: catboost/libs/data/model_dataset_compatibility.cpp:53: Feature feature_49 is Categorical in model but marked different in the dataset
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。