我管道中的最后一步是linearsvc()
分类器。我正在使用相同的管道进行培训和评分。因此,两种情况下的数据类型转换都应该相同。
运行时出现以下错误
pipeline.score(X_test, y_truth)
错误日志:
return self.model.score(X, y)
File "lib\site-packages\sklearn\utils\metaestimators.py", line 116, in <lambda>
out = lambda *args, **kwargs: self.fn(obj, *args, **kwargs)
File "lib\site-packages\sklearn\pipeline.py", line 602, in score
return self.steps[-1][-1].score(Xt, y, **score_params)
File "lib\site-packages\sklearn\base.py", line 357, in score
return accuracy_score(y, self.predict(X), sample_weight=sample_weight)
File "lib\site-packages\sklearn\metrics\classification.py", line 176, in accuracy_score
y_type, y_true, y_pred = _check_targets(y_true, y_pred)
File "lib\site-packages\sklearn\metrics\classification.py", line 72, in _check_targets
type_true = type_of_target(y_true)
File "lib\site-packages\sklearn\utils\multiclass.py", line 287, in type_of_target
if (len(np.unique(y)) > 2) or (y.ndim >= 2 and len(y[0]) > 1):
File "lib\site-packages\numpy\lib\arraysetops.py", line 264, in unique
ret = _unique1d(ar, return_index, return_inverse, return_counts)
File "lib\site-packages\numpy\lib\arraysetops.py", line 312, in _unique1d
ar.sort()
TypeError: '<' not supported between instances of 'float' and 'str'