這里我找到我的問題是:
使用的是一個新的scikit學習版本,它拋出了一個錯誤,因為在新版本中,所有東西都必須是一個二維矩陣,甚至是一個列或行。
它甚至說:用數組來重塑你的數據。如果您的數據有一個單獨的特性或數組,那么重構(-1,1)。重構(1,-1)如果它包含一個單一的樣本
這是在git上面看到的一個國際友人的解答。
原文,如下:
I think you're using a new scikit-learn version and it's throwing an error because in the new version everything has to be a 2d matrix, even a single column or row.
It even says: Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Have you tried this on your y column?
我遇到的就是這個問題,因為我使用的sklearn 是anaconda的3.5版本,應該是最新版本,所以出現了這個問題吧
然后我們來看看解決問題的方法:
調用 xx.reshape(1,-1)
可以使用,本人親測
即可將其轉為二維數組
各位加油!
有人問起怎么調用了,這里我說下 ,直接用需要修改的 數組名.reshape(1,-1) 即可

