Python的Reshape your data either using array.reshape(-1, 1) if your data has a single feature or

在使用sklearn进行数据处理的时候出现了报错,如题所示;

报错地方的代码如下

#dataitem = x_train[1]

y_predicted.append(clf.predict(dataitem))

报错的原因是,dataitem是一个数组的类型,而predict()函数应该传入的是list类型的参数,因此出现报错

解决方法如下:

y_predicted.append(clf.predict([dataitem]))

 

posted @ 2018-12-17 11:18  kyrie_chen  阅读(13806)  评论(0编辑  收藏  举报