Validity of Lasso regression using fminunc function. Promising results with some parameters equal to zero.

2 Ansichten (letzte 30 Tage)
I have written the following function using the fminunc function for estimation of a regression model based on lasso. I have not seen anything similar in matlab until now so I don't no if it is valid. However the reults seem promising. Any opinions?
function [theta]=LASSO(outputsignal,inputsignal,na,nb,th,lambda)
N=length(outputsignal);
% lambda: regularization parameter
% na,nb: polynomial orders
% th: initial parameter vector
%Formation of regression matrix
PHI=zeros(N,na);
for na=1:na
PHI(na+1:end,na)=-outputsignal(1:end-na);
end
for nb=0:nb
PHI(nb+1:end,na+1+nb)=inputsignal(1:end-nb);
end
th=PHI\outputsignal;
fun=@(theta) sum((outputsignal-PHI*theta).^2)+lambda*sum(abs(theta));
theta = fminunc(fun,th);
end
  2 Kommentare
Pavl M.
Pavl M. am 31 Dez. 2024
Bearbeitet: Pavl M. am 2 Jan. 2025
Good point,
I checked it for rande, randp, randg distributions generated stochastic IN and OUT and theta for them and found for randi stochastic numbers it produces each run the same theta in shape of near delta(impulse) if the input output are constants and stationary mean of the theta when input and output changes a bit like in PDM, right?, very short square wave in the beginning, see:
rng('default')
function [theta]=ls(outputsignal,inputsignal,na,nb,lambda)
N=length(outputsignal);
% lambda: regularization parameter
% na,nb: polynomial orders
%Formation of regression matrix
PHI=zeros(N,na);
for i=1:na
PHI(i+1:end,i)=-outputsignal(1:end-i);
end
for i=0:nb
PHI(i+1:end,na+1+i)=inputsignal(1:end-i);
end
th=PHI\outputsignal;
fun=@(theta) sum((outputsignal-PHI*theta).^2)+lambda*sum(abs(theta));
options = optimoptions('fmincon','Display','iter','MaxIterations',1000,'OptimalityTolerance',1e-12,'UseParallel',true,'ScaleProblem',true,'ObjectiveLimit',-1e24,'StepTolerance',1e-24,'Algorithm','sqp');
A = [];
b = [];
Aeq = [];
beq = [];
ub = [];
lb = [];
nonlcon = [];
theta = fmincon(fun,th,A,b,Aeq,beq,lb,ub,nonlcon,options);
end
inputs = randi(1,1,1000)';
outps = randi(1,1,1000)';
na = 100;
nb = 1000;
lambda = 10;
theta=ls(outps,inputs,na,nb,lambda)
Warning: Unable to create a parallel pool. Continuing with evaluations in serial. To avoid this warning, set the 'UseParallel' option to false.
Iter Func-count Fval Feasibility Step Length Norm of First-order step optimality 0 1102 1.000000e+01 0.000e+00 1.000e+00 0.000e+00 1.000e+01 1 2335 1.000000e+01 0.000e+00 5.103e-21 1.693e-18 1.000e+01 2 3566 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 3 4797 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 4 6028 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 5 7259 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 6 8490 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 7 9721 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 8 10952 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 9 12183 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 10 13414 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 11 14645 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 12 15876 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 13 17107 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 14 18338 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 15 19569 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 16 20800 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 17 22031 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 18 23262 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 19 24493 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 20 25724 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 21 26955 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 22 28186 1.000000e+01 0.000e+00 1.041e-20 3.456e-18 1.000e+01 23 29416 1.000000e+01 0.000e+00 1.488e-20 4.937e-18 1.000e+01 24 30646 1.000000e+01 0.000e+00 1.488e-20 4.937e-18 1.000e+01 25 31876 1.000000e+01 0.000e+00 1.488e-20 4.937e-18 1.000e+01 26 33106 1.000000e+01 0.000e+00 1.488e-20 4.937e-18 1.000e+01 27 34336 1.000000e+01 0.000e+00 1.488e-20 4.937e-18 1.000e+01 28 35566 1.000000e+01 0.000e+00 1.488e-20 4.937e-18 1.000e+01 29 36796 1.000000e+01 0.000e+00 1.488e-20 4.937e-18 1.000e+01 Iter Func-count Fval Feasibility Step Length Norm of First-order step optimality 30 38025 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 31 39254 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 32 40483 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 33 41712 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 34 42941 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 35 44170 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 36 45399 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 37 46628 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 38 47857 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 39 49086 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 40 50315 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 41 51544 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 42 52773 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 43 54002 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 44 55231 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 45 56460 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 46 57689 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 47 58918 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 48 60147 1.000000e+01 0.000e+00 2.125e-20 7.053e-18 1.000e+01 49 61375 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 50 62603 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 51 63831 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 52 65059 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 53 66287 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 54 67515 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 55 68743 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 56 69971 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 57 71199 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 58 72427 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 59 73655 1.000000e+01 0.000e+00 3.036e-20 1.008e-17 1.000e+01 Iter Func-count Fval Feasibility Step Length Norm of First-order step optimality 60 74882 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 61 76109 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 62 77336 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 63 78563 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 64 79790 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 65 81017 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 66 82244 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 67 83471 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 68 84698 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 69 85925 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 70 87152 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 71 88379 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 72 89606 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 73 90833 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 74 92060 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 75 93287 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 76 94514 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 77 95741 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 78 96968 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 79 98195 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 80 99422 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 81 100649 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 82 101876 1.000000e+01 0.000e+00 4.338e-20 1.439e-17 1.000e+01 83 103102 1.000000e+01 0.000e+00 6.197e-20 2.056e-17 1.000e+01 84 104328 1.000000e+01 0.000e+00 6.197e-20 2.056e-17 1.000e+01 85 105554 1.000000e+01 0.000e+00 6.197e-20 2.056e-17 1.000e+01 86 106780 1.000000e+01 0.000e+00 6.197e-20 2.056e-17 1.000e+01 87 108006 1.000000e+01 0.000e+00 6.197e-20 2.056e-17 1.000e+01 88 109232 1.000000e+01 0.000e+00 6.197e-20 2.056e-17 1.000e+01 89 110458 1.000000e+01 0.000e+00 6.197e-20 2.056e-17 1.000e+01 Solver stopped prematurely. fmincon stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 1.101000e+05.
theta = 1101×1
1.0e+00 * 0.0000 -0.0000 0.0000 -0.0000 -0.0000 -0.0000 0.0000 -0.0000 -0.0000 -0.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
theta2=lasso(outps,inputs)
theta2 = 1×100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
plot(theta)
title('theta')
figure
plot(theta2)
title('theta2')
inputs = randi(2,1,100)';
outps = randi(2,1,100)';
na = 100;
nb = 100;
lambda = 1;
theta=ls(outps,inputs,na,nb,lambda)
Warning: Unable to create a parallel pool. Continuing with evaluations in serial. To avoid this warning, set the 'UseParallel' option to false.
Iter Func-count Fval Feasibility Step Length Norm of First-order step optimality 0 202 5.797983e+01 0.000e+00 1.000e+00 0.000e+00 1.000e+00 1 493 5.797983e+01 0.000e+00 1.636e-14 2.319e-13 1.000e+00 2 770 5.797983e+01 0.000e+00 2.412e-12 3.419e-11 1.000e+00 3 1033 5.797983e+01 0.000e+00 3.556e-10 5.042e-09 1.000e+00 4 1282 5.797983e+01 0.000e+00 5.243e-08 7.434e-07 1.000e+00 5 1499 5.793477e+01 0.000e+00 4.748e-03 9.448e-02 2.479e+01 6 1723 5.763679e+01 0.000e+00 3.910e-04 6.648e-01 1.585e+01 7 1943 5.741297e+01 0.000e+00 1.628e-03 3.143e-01 1.808e+01 8 2165 5.715719e+01 0.000e+00 7.979e-04 1.118e-01 1.122e+01 9 2381 5.521815e+01 0.000e+00 6.782e-03 9.513e-01 1.523e+01 10 2598 5.199702e+01 0.000e+00 4.748e-03 1.512e+00 2.097e+01 11 2812 5.046204e+01 0.000e+00 1.384e-02 1.764e+00 2.017e+01 12 3028 4.868324e+01 0.000e+00 6.782e-03 9.342e-01 2.157e+01 13 3242 4.657674e+01 0.000e+00 1.384e-02 9.178e-01 2.253e+01 14 3455 4.566696e+01 0.000e+00 1.977e-02 1.152e+00 2.283e+01 15 3668 4.547075e+01 0.000e+00 1.977e-02 8.810e-01 1.517e+01 16 3881 4.420156e+01 0.000e+00 1.977e-02 5.515e-01 1.067e+01 17 4093 4.271783e+01 0.000e+00 2.825e-02 6.280e-01 8.424e+00 18 4306 4.113224e+01 0.000e+00 1.977e-02 5.787e-01 1.051e+01 19 4518 3.886588e+01 0.000e+00 2.825e-02 7.096e-01 6.521e+00 20 4730 3.751423e+01 0.000e+00 2.825e-02 8.032e-01 9.444e+00 21 4942 3.518426e+01 0.000e+00 2.825e-02 1.064e+00 1.231e+01 22 5156 3.326559e+01 0.000e+00 1.384e-02 6.137e-01 7.986e+00 23 5367 3.242401e+01 0.000e+00 4.035e-02 1.318e+00 9.471e+00 24 5579 3.189142e+01 0.000e+00 2.825e-02 7.710e-01 7.813e+00 25 5791 3.186328e+01 0.000e+00 2.825e-02 5.378e-01 7.130e+00 26 6003 3.095626e+01 0.000e+00 2.825e-02 5.197e-01 1.020e+01 27 6216 3.020621e+01 0.000e+00 1.977e-02 4.379e-01 1.306e+01 28 6428 2.972554e+01 0.000e+00 2.825e-02 5.086e-01 1.365e+01 29 6640 2.879901e+01 0.000e+00 2.825e-02 4.674e-01 1.280e+01 Iter Func-count Fval Feasibility Step Length Norm of First-order step optimality 30 6851 2.861838e+01 0.000e+00 4.035e-02 7.272e-01 1.273e+01 31 7063 2.739906e+01 0.000e+00 2.825e-02 5.063e-01 1.665e+01 32 7274 2.698326e+01 0.000e+00 4.035e-02 7.595e-01 1.645e+01 33 7486 2.576103e+01 0.000e+00 2.825e-02 6.492e-01 8.137e+00 34 7698 2.472916e+01 0.000e+00 2.825e-02 5.468e-01 4.945e+00 35 7910 2.407070e+01 0.000e+00 2.825e-02 4.567e-01 7.266e+00 36 8122 2.311949e+01 0.000e+00 2.825e-02 5.076e-01 1.068e+01 37 8334 2.266618e+01 0.000e+00 2.825e-02 4.161e-01 1.108e+01 38 8546 2.236406e+01 0.000e+00 2.825e-02 3.753e-01 6.935e+00 39 8758 2.187820e+01 0.000e+00 2.825e-02 3.754e-01 6.166e+00 40 8970 2.124237e+01 0.000e+00 2.825e-02 3.599e-01 3.745e+00 41 9182 2.049836e+01 0.000e+00 2.825e-02 3.834e-01 5.599e+00 42 9393 2.042081e+01 0.000e+00 4.035e-02 5.042e-01 9.531e+00 43 9605 1.978278e+01 0.000e+00 2.825e-02 3.979e-01 8.127e+00 44 9817 1.944046e+01 0.000e+00 2.825e-02 3.816e-01 7.670e+00 45 10030 1.905181e+01 0.000e+00 1.977e-02 2.737e-01 8.418e+00 46 10242 1.898972e+01 0.000e+00 2.825e-02 2.988e-01 5.809e+00 47 10454 1.881344e+01 0.000e+00 2.825e-02 2.830e-01 5.178e+00 48 10666 1.867515e+01 0.000e+00 2.825e-02 2.673e-01 5.790e+00 49 10877 1.865734e+01 0.000e+00 4.035e-02 4.107e-01 7.195e+00 50 11089 1.848107e+01 0.000e+00 2.825e-02 2.550e-01 7.815e+00 51 11301 1.828433e+01 0.000e+00 2.825e-02 2.748e-01 7.731e+00 52 11513 1.790436e+01 0.000e+00 2.825e-02 3.490e-01 9.353e+00 53 11726 1.770168e+01 0.000e+00 1.977e-02 2.526e-01 8.845e+00 54 11939 1.752141e+01 0.000e+00 1.977e-02 1.972e-01 8.486e+00 55 12151 1.734169e+01 0.000e+00 2.825e-02 2.907e-01 3.591e+00 56 12364 1.713756e+01 0.000e+00 1.977e-02 2.175e-01 5.193e+00 57 12576 1.692661e+01 0.000e+00 2.825e-02 3.169e-01 4.476e+00 58 12789 1.679478e+01 0.000e+00 1.977e-02 2.279e-01 3.799e+00 59 13001 1.672568e+01 0.000e+00 2.825e-02 2.636e-01 3.209e+00 Iter Func-count Fval Feasibility Step Length Norm of First-order step optimality 60 13215 1.664207e+01 0.000e+00 1.384e-02 1.394e-01 2.767e+00 61 13429 1.651667e+01 0.000e+00 1.384e-02 1.311e-01 3.898e+00 62 13644 1.646908e+01 0.000e+00 9.689e-03 9.674e-02 4.569e+00 63 13859 1.639990e+01 0.000e+00 9.689e-03 1.105e-01 4.745e+00 64 14073 1.637388e+01 0.000e+00 1.384e-02 1.635e-01 6.536e+00 65 14285 1.634241e+01 0.000e+00 2.825e-02 2.169e-01 8.410e+00 66 14499 1.621592e+01 0.000e+00 1.384e-02 1.704e-01 7.271e+00 67 14713 1.605251e+01 0.000e+00 1.384e-02 1.713e-01 7.504e+00 68 14927 1.600985e+01 0.000e+00 1.384e-02 1.364e-01 7.301e+00 69 15140 1.585682e+01 0.000e+00 1.977e-02 1.698e-01 5.444e+00 70 15354 1.578220e+01 0.000e+00 1.384e-02 1.338e-01 5.905e+00 71 15567 1.569772e+01 0.000e+00 1.977e-02 1.748e-01 6.230e+00 72 15781 1.567696e+01 0.000e+00 1.384e-02 1.256e-01 7.316e+00 73 15995 1.562043e+01 0.000e+00 1.384e-02 1.222e-01 5.801e+00 74 16209 1.553002e+01 0.000e+00 1.384e-02 1.233e-01 4.064e+00 75 16425 1.548229e+01 0.000e+00 6.782e-03 8.114e-02 3.772e+00 76 16638 1.546427e+01 0.000e+00 1.977e-02 1.866e-01 3.482e+00 77 16852 1.545094e+01 0.000e+00 1.384e-02 1.276e-01 2.914e+00 78 17066 1.537076e+01 0.000e+00 1.384e-02 1.050e-01 2.558e+00 79 17281 1.535369e+01 0.000e+00 9.689e-03 9.431e-02 2.511e+00 80 17495 1.530227e+01 0.000e+00 1.384e-02 1.135e-01 3.445e+00 81 17708 1.529554e+01 0.000e+00 1.977e-02 1.449e-01 3.621e+00 82 17922 1.527354e+01 0.000e+00 1.384e-02 8.923e-02 4.132e+00 83 18137 1.522178e+01 0.000e+00 9.689e-03 8.741e-02 3.155e+00 84 18351 1.514938e+01 0.000e+00 1.384e-02 1.211e-01 3.094e+00 85 18565 1.512798e+01 0.000e+00 1.384e-02 1.258e-01 2.567e+00 86 18779 1.506048e+01 0.000e+00 1.384e-02 1.076e-01 3.942e+00 87 18994 1.500325e+01 0.000e+00 9.689e-03 7.505e-02 3.589e+00 88 19208 1.499837e+01 0.000e+00 1.384e-02 1.114e-01 2.948e+00 89 19421 1.493970e+01 0.000e+00 1.977e-02 1.481e-01 4.184e+00 Iter Func-count Fval Feasibility Step Length Norm of First-order step optimality 90 19635 1.491204e+01 0.000e+00 1.384e-02 1.120e-01 3.216e+00 91 19849 1.489494e+01 0.000e+00 1.384e-02 9.724e-02 3.223e+00 92 20064 1.488242e+01 0.000e+00 9.689e-03 7.833e-02 3.264e+00 93 20278 1.487523e+01 0.000e+00 1.384e-02 1.045e-01 3.275e+00 Solver stopped prematurely. fmincon stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 2.010000e+04.
theta = 201×1
-0.0819 -0.0283 -0.0235 -0.0037 0.0445 -0.0005 0.1698 -0.0162 0.0090 -0.0182
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
theta2 = lasso(inputs,outps)
theta2 = 1×100
0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1328 0.1327 0.1327 0.1327 0.1327 0.1327 0.1327 0.1327 0.1327
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
plot(outps)
title('Response')
figure
plot(inputs)
title('Predictor')
figure
plot(theta)
title('theta')
figure
plot(theta2)
title('theta2')
mean(theta)
ans = 0.0060
mean(theta2)
ans = 0.1179
Can you help?
What will be the future use cases for it?
For which practical solutions, resolutions, specific artefacts bring-about you've thought the methode?
Anast
Anast am 2 Jan. 2025
The function was created for identification of regression models, theta is the parameter vector of the regression model.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Gayathri
Gayathri am 2 Jan. 2025
Hi @Anast,
I understand that you are trying to perform LASSO regression, but there are some improvements you can consider.
The variables "na" and "nb" are being overwritten in your loops. You should use different variable names inside the loops to avoid confusion as shown below.
for i = 1:na
PHI(i+1:end, i) = -outputsignal(1:end-i);
end
for j = 0:nb
PHI(j+1:end, na+1+j) = inputsignal(1:end-j);
end
Also, "fminunc" is used for unconstrained optimization, but LASSO requires constrained optimization. Consider using "fmincon" function, that handles regularization constraints.
For more information on "fmincon" function, please refer to the documentation link below.
MATLAB includes a built-in lasso function, available in the "Statistics and Machine Learning Toolbox". You can consider using the same.
theta = lasso(X,y)
"theta" will have the fitted least-squares regression coefficients for linear models of the predictor data X and the response y.
For more information about the "lasso" function, please refer to the documentation link below.
Hope you find this information helpful!
  2 Kommentare
Anast
Anast am 2 Jan. 2025
Bearbeitet: Anast am 2 Jan. 2025
Thank you Gayathri. Your comments were very useful. However how could someone explain the fact that the results seem valid for regularization? I mean, some parameters go to zero and the identified model is accurate. Also I have included the L1 constraint in the fminunc function.
Gayathri
Gayathri am 3 Jan. 2025
Bearbeitet: Gayathri am 3 Jan. 2025
The L1 constraint of LASSO regression encourages sparsity in the model. This means it actively pushes some coefficients to zero, effectively removing less important features. This is particularly useful in high-dimensional data where many features may be irrelevant or redundant.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by