Two regression tasks share one weight vector. Train on task A, then on task B, and measure what training on B did to task A. Each training run is a ridge regression solved in closed form, so the only moving part is the order in which the data arrives.
ridge_fit(X, y, lam)
X is an (n, d) array, y an (n,) array, lam a non-negative float.(d,) weight vector that minimises . Use the normal equations with added to ; no intercept.sequential_forgetting(XA, yA, XB, yB, lam=0.0, decimals=4)
"mse_A_after_A", "mse_A_after_B", "mse_B_after_B", "forgetting" (mse_A_after_B - mse_A_after_A), "mse_A_joint", "mse_B_joint", and "joint_total" (the sum of the two joint errors). Round every value to decimals and return Python floats.np.linalg.solve on the regularised normal equations is numerically preferable to forming an explicit inverse.np.vstack / np.concatenate of the two tasks.