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
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개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!