Skip to main content
added 665 characters in body
Source Link

I have fitted a Linear Regression Model using one dataset. Now, I have another smaller dataset that I want to refine the model with. Can I use Ridge regression to update the estimated coefficients for this new dataset? Or do you recommend a more appropriate approach?

Edit: after the useful Answer by John Madden, I have implemented his approach using Python, as follows, do you find any issue in this code in reflecting that logic:

# Step 1: Compute coefficients on dataset (X1, y1) beta1 = np.linalg.pinv(X1) @ y1 print("Original coefficients:", beta1) # Step 2: Compute residuals on dataset (X2, y2) y_hat2 = X2 @ beta1 residual2 = y2 - y_hat2 # Step 3: Perform ridge regression on residuals ridge_reg = Ridge(alpha=alpha) ridge_reg.fit(X2, residual2) delta = ridge_reg.coef_ # Step 4: Adjust coefficients beta2 = beta1 + delta print("Adjusted coefficients:", beta2) 

I have fitted a Linear Regression Model using one dataset. Now, I have another smaller dataset that I want to refine the model with. Can I use Ridge regression to update the estimated coefficients for this new dataset? Or do you recommend a more appropriate approach?

I have fitted a Linear Regression Model using one dataset. Now, I have another smaller dataset that I want to refine the model with. Can I use Ridge regression to update the estimated coefficients for this new dataset? Or do you recommend a more appropriate approach?

Edit: after the useful Answer by John Madden, I have implemented his approach using Python, as follows, do you find any issue in this code in reflecting that logic:

# Step 1: Compute coefficients on dataset (X1, y1) beta1 = np.linalg.pinv(X1) @ y1 print("Original coefficients:", beta1) # Step 2: Compute residuals on dataset (X2, y2) y_hat2 = X2 @ beta1 residual2 = y2 - y_hat2 # Step 3: Perform ridge regression on residuals ridge_reg = Ridge(alpha=alpha) ridge_reg.fit(X2, residual2) delta = ridge_reg.coef_ # Step 4: Adjust coefficients beta2 = beta1 + delta print("Adjusted coefficients:", beta2) 
Source Link

Can I utilize Ridge Regression to update coefficients of a Linear Regression model for a new dataset?

I have fitted a Linear Regression Model using one dataset. Now, I have another smaller dataset that I want to refine the model with. Can I use Ridge regression to update the estimated coefficients for this new dataset? Or do you recommend a more appropriate approach?