admin管理员组

文章数量:1650772

👦👦一个帅气的boy,你可以叫我Love And Program
🖱 ⌨个人主页:Love And Program的个人主页
💖💖如果对你有帮助的话希望三连💨💨支持一下博主

UserWarning: X has feature names, but LassoCV was fitted without feature names

在使用sklearn过程中程序出现如上报错,说明咱们输入时没有用Dataframe作为模型的训练集

只需要将训练数据改成如下形式即可(我是将array转换成Dataframe格式):


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().

 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().

在数据拟合过程中fit()出现数据转换的问题,提示使用ravel()函数,转换前是二维数组的形式,如下图:

y_train


转换后变成一维数组,警告消失,但是对结果影响不大

y_train.ravel()
# 或
np.array(y_train).reshape(1,-1)[0]

本文标签: 报错UserWarningskleaenfeaturefitted