今天 用XGBOOST调参的时候碰到了这个问题:
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)
原因是,在训练时的y_train的格式不对。
用ravel转换下数据格式即可运行。
y_train = y_train.values.ravel()
或把label值转成list
y_train = y_train['label'].tolist()
网友评论