我正在同一数据集上构建岭回归和套索回归,但是套索模型的预测形状似乎与岭不同。如果有人能解释我做错了什么,我将不胜感激......
###Ridge Regression
model3 = Ridge(alpha=5)
model3.fit(x_train2, y_train)
y_pred3=model3.predict(x_test2)
y_pred3.shape
#result is: (1542, 1)
###Lasso Regression
from sklearn.linear_model import Lasso
model4 = Lasso(alpha=0.1)
model4.fit(x_train2, y_train)
y_pred4=model4.predict(x_test2)
y_pred4.shape
#result is: (1542,)