优艾设计网

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

优艾设计网 https://www.uibq.com 2023-04-07 08:47 出处:网络 作者:在线设计
用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


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优艾设计网_设计LOGO.jianshu.com/p/738f...

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


郁怀玉 2022-04-25 19:32

优艾设计网_PS交流

1维数组来传递数据在0.19版本将触发ValueError。用X.reshape(-1, 1)来重塑数据的形状(数组的维度)


thierrylye 2022-04-25 19:32

优艾设计网_Photoshop问答

也就是说,你需要以二维数组的方式传递数据。


鬼子进了村部 2022-04-25 19:41

我觉得你对机器学习算法还是不了解的,其实是这样的:你的输入的数据X应该是数据的特征向量,y是特征向量对应的标签。每一个样本都有一个特征向量,这样你输入的X一定是二维数组才对,y如果是单标签就为一维数组,若为多标签或者像神经元网络那样的标签就为二维优艾设计网_设计客数组。你的x=[[6],[8],[10],[14],[18]],算法可以理解为只有一个特征项,但是如果为x=[6,8,10,14,18],你让算法怎么理解


我没有你并非不行 2022-04-25 19:55

优艾设计网_设计

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)


0

精彩评论

暂无评论...
验证码 换一张
取 消