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]))

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM