Machine learning 当要预测的值是绝对值时不起作用

Machine learning 当要预测的值是绝对值时不起作用,machine-learning,catboost,Machine Learning,Catboost,问题:当要预测的值是绝对值时不起作用 catboost版本:0.8 操作系统:Windows 中央处理器:英特尔 当我的预测值(Y)太过明确时,得到了“不能对流浮动”的误差。我必须对Y值进行一次热编码吗 谢谢你的帮助 Python代码: from sklearn.model_selection import train_test_split train_set , test_set = train_test_split(trainPLData, test_size=0.2, random_sta

问题:当要预测的值是绝对值时不起作用 catboost版本:0.8 操作系统:Windows 中央处理器:英特尔

当我的预测值(Y)太过明确时,得到了“不能对流浮动”的误差。我必须对Y值进行一次热编码吗

谢谢你的帮助

Python代码:

from sklearn.model_selection import train_test_split
train_set , test_set = train_test_split(trainPLData, test_size=0.2, random_state=42)

for col in ['product_line','a_plant', 'a_pa', 'b_plant','b_pa',
'c_plant', 'c_pa', 'D_plant', 'D_pa', 'fam', 'pkg','defect']:
train_set[col] = train_set[col].astype('category')
test_set[col] = test_set[col].astype('category')

x_train = train_set[['product_line','a_plant', 'a_pa', 'b_plant','b_pa',
'c_plant', 'c_pa', 'D_plant', 'D_pa', 'fam', 'pkg']]
y_train = train_set[['defect']]

x_test = test_set[['product','a_plant', 'a_pa', 'b_plant','b_pa',
'c_plant', 'c_pa', 'D_plant', 'D_pa', 'fam', 'pkg']]
y_test = test_set[['defect']]

from catboost import CatBoostClassifier
model=CatBoostClassifier(iterations=50, depth=3, learning_rate=0.1,one_hot_max_size=10)

categorical_features_indices = np.where(x_train.dtypes != np.float)[0]
print(categorical_features_indices)

model.fit(x_train, y_train,cat_features=categorical_features_indices,
eval_set=(x_test, y_test))
那么错误是:

ValueError:无法将字符串转换为浮点:“某些缺陷”


Catboost尝试将其转换为浮点,因为它需要它是一个数字。使用LabelEncoder来做,效果很好,我在一个多类问题中使用过它,没有任何问题。

发布完整的错误,并向我们展示您的X、Y数据集性质(每个数据集至少打印5个值),否则我们无法猜到问题出在哪里。问题是Y值也是分类的,我使用lableEncoder对其进行了更改,它可以工作。