Calculate predictions, residuals, and MSE for w=2,.
Compare w,b obtained using np.linalg.lstsq with the baseline model in the same table.
Results to retain
Prediction and scatter plots, and a model comparison table.
Items to record and points to check
Model
w
b
MSE
Prediction for
Points to check
Did you keep a consistent sign convention for the residual y_hat-y?
2. The Influence of One Sample
Starting conditions
Create data with the last y changed to 18 and compare changes in coefficients, MSE, and predictions at .
Procedure
Keep x unchanged and create a copy with only the last y changed to 18. Apply np.linalg.lstsq separately to the original and modified data.
Record the two models' , MSE on their respective training data, and predictions at in two rows. Plot the original points, modified points, and both prediction lines on the same axes.
Using the table and plot, explain how changing one sample affected the coefficients and predictions for new inputs.
Results to retain
Two fitted lines and a table comparing coefficients, MSE, and predictions for new inputs.
Items to record and points to check
Training data
w·b
MSE
Prediction at x=6
Points to check
Did you preserve the fitting method and all samples except the one changed?
3. Checking Other Inputs
Starting conditions
Plot predictions at and distinguish them from predictions within the observed range.
Procedure
Use the two models trained above to calculate predictions for . Record both models' predictions in the same table.
Draw prediction lines over a range covering the original observations and the three new inputs. Use different symbols for observed points and new predictions. For the new inputs, record predictions and whether they lie within the observed range, rather than ground truth values.
Explain how the difference between the two models' predictions changes farther outside the observed range.
Results to retain
A prediction table for the three new inputs and a prediction plot that distinguishes the observed range.
Items to record and points to check
New input x
Model predictions for the original data
Model predictions for modified data
Inside the observed range or not; difference between the two predictions
Points to check
Did you avoid interpreting predictions for new inputs without ground truth as actual errors?