【发布时间】:2019-12-04 21:46:29
【问题描述】:
所以我用一些包含一些分类变量的数据训练了一个 CatBoost 分类器模型;问题是我想对单个样本进行预测,但总是出错;像这样:
# X is a dataframe with 23 vars, 14 of which are categorical
model.predict(X.loc[1]) # This gives the error below
CatBoostError: Invalid cat_features[1] = 1 value: index must be < 1.
# I've tried reshaping the series but this raises another error
model.predict(X.loc[1].values.reshape(1, -1)) # This form works with LightGBM
CatBoostError: 'data' is numpy array of floating point numerical type, it means no categorical
features, but 'cat_features' parameter specifies nonzero number of categorical features
但是,如果我尝试使用两个或更多样本,它会完美运行
model.predict(X.iloc[:2,:])
array([1., 0])
我不明白如何只做一个简单的预测,我还没有找到这方面的信息。
¿如何使用 catboost 对单个样本进行预测?
【问题讨论】:
标签: python prediction catboost