Multiple Linear Regression: A Solved Numerical Example
Scenario: Restaurant Revenue Prediction
The Objective: Predict a restaurant's weekly revenue (£'s) based on seating capacity and average customer rating.
Step 1: The Historical Data & Target Point
When we have more than one independent variable (feature), we use Multiple Linear Regression to find a hyper-plane of best fit. We are trying to predict the Weekly_Revenue_hundreds using the given features.
| Data Point | Seating_Capacity | Avg_Rating | Weekly_Revenue_hundreds |
|---|---|---|---|
| P1 | 35 | 4 | 14 |
| P2 | 40 | 3.8 | 15 |
| P3 | 25 | 3.2 | 10 |
| Target | 45 | 4.1 | ? |
Step 2: Extract X and Y Matrices
First, we convert our tabular data into matrices. Notice how we add a column of 1s to the very beginning of the X Matrix. This acts as a placeholder for our Y-intercept
Step 3: Calculate X-Transpose and Multiply
We flip the rows and columns of Matrix to create its Transpose (). Then, we multiply by the original matrix to create a square matrix.
Step 4: Find Inverse and Multiply
Because there is no "division" in matrix math, we find the Inverse of our square matrix. Multiplying by an inverse is the mathematical equivalent of dividing!
Step 5: Solve for B (Weights & Intercept)
Finally, we multiply our accumulated matrix by the original Matrix . This yields the Beta Matrix (), which contains our intercept () and the optimal weights () for our features.
Intercept () : -2.00
Weight for () : 0.27
Weight for () : 1.67
Step 6: Final Equation & Prediction
We extract those weights and build our Multiple Linear Regression equation. Then we plug in our new Target Point to calculate the final prediction!
Line: Y = -2.0000 + (0.2667 * 45) + (1.6667 * 4.1)
Y = 16.83
Final Takeaway
Based on the interactions between all selected features, the model predicts an estimated result of 16.83.