I am using Lasso for multi-output regression. However, whatever value of alpha I am using, it is producing the same mse and R^2 values. Am I doing something wrong?

I have tested the code with different values of alpha starting from 0.001 to 10, but with no effect. On the contrary, Ridge gives me different results.

#for alp in [0.1, 0.2, 0.3, 0.4, 0.5]:
for alp in [0.01,0.1,0.5,1,5]:
    print('Working with alpha=',alp)
    Lasso_Regr = Lasso(alpha=alp, normalize=True)
    Lasso_Regr.fit(x_train, y_train)
    y_pred = Lasso_Regr.predict(x_test)
    pred_mean = pd.DataFrame(y_pred.mean(axis=0))
    y_mse.append(mean_squared_error(y_test, y_pred))
    y_r2score.append(r2_score(actual_mean, pred_mean))

print("Mean Squared Error (y_test Vs. y_pred): ", y_mse)
print("r2 Score (y_test_mean Vs. y_pred_mean): ", y_r2score)

Output: MSE: 0.0123499507 R^2 Score: 0.98817476 Same pair of results for all alpha values


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.