值错误:传递的项目数错误2,展示位置表示1 [英] Value Error:Wrong number of items passed 2, placement implies 1
本文介绍了值错误:传递的项目数错误2,展示位置表示1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码可以正常工作...
This code works fine...
forest1 = RandomForestClassifier()
forest1.fit(train[['Random Forest Score','lr','neural']],train['target'])
但是当我尝试预测时,
test['target'] = forest1.predict_proba(test[['Random Forest Score','lr','neural']])
显示错误.
ValueError:传递的项目数错误2,展示位置表示1
ValueError: Wrong number of items passed 2, placement implies 1
推荐答案
It returns an array of shape = [n_samples, n_classes]
, or a list of n_outputs
such arrays if n_outputs > 1. The class probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_.
test ['target']
需要一个向量(一维数组)
test['target']
expects a vector (1D array)
尝试使用 predict()
代替 predict_proba
:
test['target'] = forest1.predict(test[['Random Forest', 'Score','lr','neural']])
这篇关于值错误:传递的项目数错误2,展示位置表示1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文