MCPcopy
hub / github.com/ddbourgin/numpy-ml / _update2D

Method _update2D

numpy_ml/linear_models/linear_regression.py:156–170  ·  view source on GitHub ↗

Woodbury update for multiple examples

(self, X, y, W)

Source from the content-addressed store, hash-verified

154 beta += S_inv @ x.T @ (y - x @ beta)
155
156 def _update2D(self, X, y, W):
157 """Woodbury update for multiple examples"""
158 beta, S_inv = self.beta, self.sigma_inv
159
160 # convert X to a design matrix if we're fitting an intercept
161 if self.fit_intercept:
162 X = np.c_[np.diag(W), X]
163
164 I = np.eye(X.shape[0]) # noqa: E741
165
166 # update the inverse of the covariance matrix via Woodbury identity
167 S_inv -= S_inv @ X.T @ np.linalg.pinv(I + X @ S_inv @ X.T) @ X @ S_inv
168
169 # update the model coefficients
170 beta += S_inv @ X.T @ (y - X @ beta)
171
172 def fit(self, X, y, weights=None):
173 r"""

Callers 1

updateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected