python - 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 列。
解决方案
推荐阅读
- python - 如何通过dronekit python 用 Pixhawk 和 raspberry 武装和起飞无人机
- angular - 如何使用 @Input 在 *ngFor 指令中设置管道
- integer - 对于输入和输出整数数组的神经网络中的 PyTorch 参数,我应该使用什么 dtype?
- powershell - O365 PShell 类似的收件人搜索不会使用 Where {$_.RecipientAddress -like 返回正确的结果
- amazon-ec2 - Amazon 启动模板 - 更新的 AMI
- c - 在某些情况下,我的程序似乎无法分隔单词
- vue.js - 使用 ESLint 和 Prettier 在 Visual Studio Code 中保存时无法获得正确的自动格式化
- python - 如何从 Tensorflow 中的其他张量中找到张量中的值
- android - 在适配器中设置 GradientDrawable 颜色
- xamarin - 使用 Children.Add 时的 Xamarin TabbedPage 性能