Module 06: Linear Regression - Participation Exercises#
Exercise 6.1: Critique - Coefficient Interpretation#
Type: 🔍 Critique (5 min)
A colleague shows you their regression model and says: “Temperature has a coefficient of 0.002, and pressure has a coefficient of 5.3. Clearly pressure is way more important!”
Task: Write 2-3 sentences explaining why this interpretation might be wrong and what they should do instead.
Your critique:
Exercise 6.2: Mini-Exercise - Diagnose the Model#
Type: đź”§ Mini-Exercise (7 min)
Look at these residual plots and diagnose what’s wrong with each model.
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(42)
n = 100
y_pred = np.linspace(0, 100, n)
# Three different residual patterns
fig, axes = plt.subplots(1, 3, figsize=(15, 4))
# Pattern A: Curved residuals
residuals_A = (y_pred - 50)**2 / 100 + np.random.normal(0, 2, n)
axes[0].scatter(y_pred, residuals_A, alpha=0.6)
axes[0].axhline(0, color='r', linestyle='--')
axes[0].set_title('Model A')
axes[0].set_xlabel('Predicted')
axes[0].set_ylabel('Residual')
# Pattern B: Fan shape
residuals_B = np.random.normal(0, y_pred/10 + 0.5, n)
axes[1].scatter(y_pred, residuals_B, alpha=0.6)
axes[1].axhline(0, color='r', linestyle='--')
axes[1].set_title('Model B')
axes[1].set_xlabel('Predicted')
# Pattern C: Good residuals
residuals_C = np.random.normal(0, 3, n)
axes[2].scatter(y_pred, residuals_C, alpha=0.6)
axes[2].axhline(0, color='r', linestyle='--')
axes[2].set_title('Model C')
axes[2].set_xlabel('Predicted')
plt.tight_layout()
plt.show()
# TASK: For each model, identify:
# 1. What pattern do you see?
# 2. What does it indicate?
# 3. How would you fix it?
Your diagnosis:
Model A:
Pattern:
Problem:
Fix:
Model B:
Pattern:
Problem:
Fix:
Model C:
Pattern:
Problem:
Fix:
Exercise 6.3: Reflection - Causation vs Correlation#
Type: 🤔 Reflection (3 min)
Your regression model shows that “catalyst age” has a negative coefficient for yield. A manager suggests: “Let’s always use fresh catalyst!”
Reflect:
Does the coefficient prove that old catalyst causes lower yields?
What else might explain the relationship?
What would you need to establish causation?
Your reflection: