成功解決ValueError: Expected 2D array, got 1D array instead

成功解決ValueError: Expected 2D array, got 1D array insteadhtml

 

 

 

 

目錄python

解決問題ide

解決思路code

解決方法htm


 

 

 

 

 

 

 

 

 

 

解決問題

ValueError: Expected 2D array, got 1D array insteadit

 

 

 

 

 

 

解決思路

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.class

在最新版本的sklearn中,全部的數據都應該是二維矩陣,哪怕它只是單獨一行或一列,因此,要進行格式改正!方法

 

 

 

 

 

解決方法

按照下邊改正便可!數據

scaler.fit(df['Age'])
改成
scaler.fit(df['Age'].reshape(-1, 1))

大功告成!哈哈!margin

相關文章
相關標籤/搜索