Prediction With Linear Regression
After a Linear Regression model learns a relationship from training data, we can give it new input and ask it to predict a numerical value.
New input → trained model → numerical prediction.
The model uses the relationship it learned during training to estimate the output for data it has not seen before.
Start With a Trained Model
Suppose we trained a model using students' study hours and exam scores.
After training, suppose the model learns this relationship:
Give the Model New Input
Now imagine a new student who studied for 6 hours.
The model has not seen this student's data during training. We want it to predict the student's score.
Calculate the Prediction
We put the new input into the equation learned by the model.
The new student studied for 6 hours:
Prediction Is an Estimate
This is important: the prediction is not guaranteed to be the student's actual score.
The model might predict:
The model made an estimate based on the relationship it learned from the training data.
The difference between the actual value and predicted value is called the residual or prediction error.
Prediction for Another Example
Let's use a different problem: predicting house prices.
Suppose the trained model learned:
Now we have a new house with a size of 1,500 sq ft.
The model uses the new house size and the relationship it learned during training to produce the prediction.
What Happens Inside the Model?
At a simple level, the prediction process looks like this:
The model does not simply memorize the answer. It uses the parameters it learned during training to calculate a prediction.
Multiple Linear Regression Prediction
The same idea works when there are multiple input features.
Suppose a house-price model uses:
2,000 sq ft
3 bedrooms
5 years
Multiple Linear Regression combines all the input features using the learned coefficients to produce one numerical prediction.
Prediction vs Training
Do not confuse these two stages.
Uses training data to learn the relationship and coefficients.
Uses new input to produce an estimated output.
Training creates the model. Prediction uses that trained model.
Prediction = New Input + Trained Model → Estimated Output.
The model first learns a relationship from training data. When new input is provided, the trained model applies that learned relationship to produce a numerical prediction.
Can You Follow the Prediction?
The trained model takes the new input of 5 hours and calculates a predicted score of 85.