Which regularization technique, Lasso or Ridge, provides a better solution for a predictive regression model based on the resulting photo?

조회 수: 3 (최근 30일)
In the photo, the variables [minMSEL, idxL] represent the minimum mean squared error (MSEL) values obtained for the ridge and lasso models, respectively. Considering overfitting and better prediction, which of the two models demonstrates superior performance based on these results?
Fuel Economy - Regularized Linear Models
Instructions are in the task pane to the left. Complete and submit each task one at a time.
This code loads the data.
load carEcon
whos XTrain XTest econTrain econTest
Task 1
Fit ridge model
lambdaR = 0:300;
bR = ridge(econTrain,XTrain,lambdaR,0);
Task 2
Calculate and plot MSE. Find smallest MSE.
econPredR = bR(1,:) + XTest*bR(2:end,:);
err = econPredR - econTest;
MSER = mean(err.^2);
[minMSER,idxR] = min(MSER)
plot(lambdaR,MSER)
xlabel("\lambda")
ylabel("MSE")
title("Ridge model")
Task 3
Fit lasso model
lambdaL = (0:300)/length(econTrain);
[bL,fitInfo] = lasso(XTrain,econTrain,"Lambda",lambdaL);
Task 4
Calculate and plot MSE. Find smallest MSE.
econPredL = fitInfo.Intercept + XTest*bL;
err = econPredL - econTest;
MSEL = mean(err.^2);
[minMSEL,idxL] = min(MSEL)
plot(lambdaL,MSEL)
xlabel("\lambda")
ylabel("MSE")
title("Lasso model")
  댓글 수: 5
Mohammadreza
Mohammadreza 2023년 6월 25일
The tasks have been completed, and now I have a question regarding interpretation. The low value of "minMSEL" in the expression "min(MSEL)" indicates better prediction performance. However, it also raises concerns about overfitting. Another criterion to consider is the "idxL" value, which may suggest that a lower value is preferable. Based on this interpretation, would the Lasso mode be more suitable than ridge in this specific example?
the cyclist
the cyclist 2023년 6월 26일
idxR and idxL are just the indices to which element has the minimum MSE.
Because you are calculating the MSE on the test set, and not the training set, I would not be too concerned with overfitting.
The lasso model also typically has a simpler interpretation, because it shrinks coefficients all the way to zero, dropping them out of the model completely.
There are nuances and subtleties in all of this, but it would be too much to explain in this forum.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Support Vector Machine Regression에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by