Block 74: Regression: Linear & Polynomial
Predict continuous outcomes with regression models.
Concepts
- LinearRegression from sklearn.linear_model
- Mean Squared Error (MSE) and R² score
- PolynomialFeatures for non-linear relationships
- Visualizing the fit line vs data points
Code Examples
See exercise below.
Exercise
Train a Linear Regression on a housing price dataset (or Boston/diabetes). Compute RMSE and R². Add PolynomialFeatures (degree=2) and compare R² before/after.
Homework
When does a high R² indicate a good model? When can it be misleading? Wednesday