Some observations are more reliable than others. Weighted least squares minimises ∑iwi(yi−xi⊤β)2\sum_i w_i (y_i - x_i^\top\beta)^2∑iwi(yi−xi⊤β)2.
Implement fit_wls(X, y, w) returning (intercept, coefs). Rows with weight 0 must be ignored entirely.
fit_wls(X, y, w)
(intercept, coefs)