首页 > 解决方案 > ValueError: X.shape[1] = 96 应该等于2,训练时的特征数

问题描述

我在这里学习教程:https ://scikit-learn.org/stable/auto_examples/miscellaneous/plot_multilabel.html#sphx-glr-auto-examples-miscellaneous-plot-multilabel-py 。

我有想要分类的文本,所以我对它们进行了编码。上线

classif = OneVsRestClassifier(SVC(kernel = 'linear'))
classif.fit(X, Y)

X是 (188, 96),我Y是 (188, 2)。

当我尝试运行时clf.predict(test),即使test是 (56, 96),我也会收到错误消息ValueError: X.shape[1] = 96 should be equal to 2, the number of features at training time。2 个特征从何而来?我的Y标签是二维数组,但我X有 96 列。

标签: pythonscikit-learnclassificationmultilabel-classification

解决方案


推荐阅读