Restricting Lasso-coefficients

조회 수: 5 (최근 30일)
Maximilian Voigt
Maximilian Voigt 2019년 9월 10일
댓글: John D'Errico 2019년 9월 16일
Hello all,
I am currently working on a Finance-application of Lasso. However, for my purpose I would need to restrict the coefficients obtained from the lasso(X,y)-command to be larger or equal to zero.
How can I achieve this?
My initial trial is to copy and change the existing lasso-function. In the subfunction lassoFit(), I find the command:
B(:,i) = b;
Now, before this I would simply add:
b(b<0) = 0; % restrict b to be larger/ equal to 0
B(:,i) = b;
However, I am not really sure if this is correct and any help would be highly appreciated.
Many thanks.
Best
Max

답변 (1개)

Pravin Jagtap
Pravin Jagtap 2019년 9월 16일
Hello Miximilian,
To fit the data, it is important to understand how different models of regression work and what is the effect of regularization term on overall error minimization function. Please refer to following documentation for detail understanding of error minimization objectives:
In order to achieve non-negative coefficients, try exploring some other methods such as ridge regression, weighted least squares, etc. because ‘lasso’ algorithm uses the square loss function which has less tendency of hitting coefficients at zero than ridge regression (Understand the geometric meaning of ‘L1’ and ‘L2’ loss functions and optimization using it). Enforcing the constraints provided by you is similar to changing the overall objective function of ‘lasso’ regression mathematically.
Kind Regards
~Pravin
  댓글 수: 1
John D'Errico
John D'Errico 2019년 9월 16일
I would add that it is rarely a good idea to modify existing toolbox code. Unless of course, you know enough to have written the code yourself. And even then, it is a dangerous thing to do. As you might introduce bugs into the code, or someone in the future will use your function, not knowing that it was hacked to do something that is not in the documentation.
So, if you know enough to write the code yourself, then the best thing is to write it yourself anyway. Write a simple version, that does exactly what you need.

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

카테고리

Help CenterFile Exchange에서 Gaussian Process Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by