lesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residualslesson 4 of 5 · regression metrics and residuals
Checkpoint
One last thing before we move on. pass this to mark the lesson done, or skip and keep moving. hop to the next when you're ready.
Build R² from scratch and put it next to the baseline it secretly contains. Compute ss_res (sum of squared model errors), ss_tot (sum of squared deviations of actuals from their mean), and R² = 1 - ss_res/ss_tot. Then compute the predict-the-mean baseline's MAE and the model's MAE. Print: f"R^2 = {r2:.2f}", f"predict-the-mean MAE = {...:.1f}", f"model MAE = {...:.1f}", and "beats the baseline:" with the comparison. R² is chapter 38's baseline rebuilt as a metric: 0 means no better than the mean, 1 means perfect.