Linear Regression with positive coefficients in Python
I'm trying to find a way to fit a linear regression model with positive coefficients.
The only way I found is sklearn's Lasso model, which has positive=true arguments, but doesn't recommend using with alpha=0 (means no other constraints on the weights).
Do you know of another model/method/way to do it?
Thanks
IIUC, this is a problem which can be solved by the scipy.optimize.nnls
, which can do non-negative least squares.
Solve argmin_x || Ax - b ||_2 for x>=0.
In your case, b is the y, A is the X, and x is the β (coefficients), but, otherwise, it's the same, no?
链接地址: http://www.djcxy.com/p/90796.html上一篇: launchModes,singleTask:如何在“屏幕”之间切换?
下一篇: Python中具有正系数的线性回归