pycharm提示:DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().return f(**kwargs)
文章目录
一、问题
clf = sklearn.linear_model.LogisticRegressionCV()
clf.fit(X.T,Y.T)
报错界面:数据转换警告:当需要一维数组时,传递了列向量y。请将Y的形状更改为(n_samples,),例如使用ravel()。
二、解决
1.解决思路
该问题是警告信息,不处理亦可运行程序,只需理解一下即可!建议以后使用此类方法,要规范使用!
2.解决方法
修改为这样
#clf.fit(X.T,Y.T);
clf.fit(X.T,Y.T.ravel());