Making Predictions with a Fitted Model
You'll learn: How to use your trained linear regression model to predict new outcomes and when those predictions might be unreliable.
Using Your Learned Parameters
Once you've fitted a linear regression model and obtained the parameters (slope m and intercept b), making predictions is straightforward. You simply plug new x-values into your learned equation: y_pred = m * x_new + b.
Think of it like learning a recipe. After many trials, you've discovered that baking time = 2 * cake_layers + 20 minutes. Now when someone asks, "How long for a 5-layer cake?", you confidently calculate: 2 × 5 + 20 = 30 minutes.
The Mechanics
If you trained your model on data like house sizes (x) and prices (y), and learned that price = 150 * size + 50000, you can now predict:
- A 1000 sq ft house:
150 * 1000 + 50000 = $200,000 - A 1500 sq ft house:
150 * 1500 + 50000 = $275,000
The model applies the pattern it learned from training data to new, unseen inputs.
Extrapolation Risk
Here's the critical warning: predictions are most reliable within the range of your training data (interpolation). Predicting far outside that range (extrapolation) is dangerous.
If your training data only included houses between 800-2000 sq ft, predicting the price of a 5000 sq ft mansion assumes the linear relationship holds forever—which it probably doesn't. Real-world relationships often change outside observed ranges.
Key Takeaway: After fitting a model, making predictions means applying learned parameters to new inputs, but beware: predictions are only trustworthy within the range of your training data.