// TODO: Explain this formula
e = y
if self._constant:
e = e - np.average(y, weights=root_w)
total_ss = float(w.T @ (e ** 2))
r2 = 1 - residual_ss / total_ss
After Change
// TODO: Explain this formula
e = y
if self._constant:
e = e - (w * y).sum() / w.sum()
total_ss = float(w.T @ (e ** 2))
r2 = 1 - residual_ss / total_ss