且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python中的加权非负最小二乘线性回归

更新时间:2022-06-22 06:58:55

您可以通过修改 X y 输入来模拟OLS加权.在OLS中,您为

β 求解

You can simulate OLS weighting by modifying the X and y inputs. In OLS, you solve β for

X t Xβ = X t y .

XtX β = Xty.

在加权OLS中,您可以解决

X t X Wβ = X t W y .

XtX W β = Xt W y.

其中 W 是具有非负项的对角矩阵.因此,存在 W 0.5 ,您可以将其表示为

where W is a diagonal matrix with nonnegative entries. It follows that W0.5 exists, and you can formulate this as

(X W 0.5 ) t (XW 0.5 )β =(X W 0.5 ) t (XW 0.5 )y

(X W0.5)t(XW0.5) β = (X W0.5)t(XW0.5) y,

这是具有 X W 0.5 W 0.5 y 的OLS问题.

which is an OLS problem with X W0.5 and W0.5 y.

因此,通过修改输入,可以使用不直接识别权重的非负约束系统.

Consequently, by modifying the inputs, you can use a non-negative constraint system which does not directly recognize weights.