为什么sklearn的LinearRegression要用形如x=[[6]]的列表来作为入参? 财富值13

2017-08-20 16:35发布


x=[[6],[8],[10],[14],[18]]
y=[[7],[9],[13],[17.5],[18]]
是正确的,但是使用
x=[6,8,10,14,18]
y=[7,9,13,17.5,18]
就会报错
DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
DeprecationWarning)
ValueError: Found input variables with inconsistent numbers of samples: [1, 5]

网址
http://www.jianshu.com/p/738f...

相关介绍没有看懂,惭愧。。。
http://scikit-learn.org/stabl...

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
4条回答

Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1)

一周热门 更多>