我试图使用sklearn输出预测输出,但实际的ndarray看起来与Lasso的输出不同,因为我无法计算错误。我有什么事吗?我希望Y_PRED与Y_ACT看起来相同。
Y_PRED:
[[-0.2345764 2.95901652 -0.49351205 ..., -0.4138885 -0.51545272
-0.43058412]]
Y_ACT :
[[-0.72284503]
[ 3.31750686]
[-0.42046417]
...,
[-0.75198836]
[-0.80438594]]
以下是示例代码:
x_df = TR_SET_FEATURE
y_df = TR_SET_TARGET
for train_index, test_index in kf:
x_train = x_df.iloc[train_index, :].values
x_test = x_df.iloc[test_index, :].values
y_train = y_df.iloc[train_index].values
y_test = y_df.iloc[test_index].values
regr = ElasticNet(alpha=a)
regr.fit(x_train, y_train)
y_pred = regr.predict(x_test)
print "y_pred: " ,y_pred.shape()
print "y_act: " ,y_test.shape()
pred_error = y_pred - y_test
输出:
y_pred:
文件" dataframe.py",第700行,in
打印" y_pred:" ,y_pred.shape()