Concept:
Linear Regression is one of the simplest and most widely used machine learning algorithms for predicting a continuous output based on input features. It assumes a linear relationship between independent variables and the dependent variable.
Step 1: {\color{red}What is Linear Regression?}
Linear regression models the relationship using a linear equation:
\[
y = mx + c
\]
where:
- $y$ = predicted output
- $x$ = input feature
- $m$ = slope (weight)
- $c$ = intercept (bias)
For multiple features, the equation extends to multiple linear regression.
Step 2: {\color{red}Goal of Linear Regression}
The objective is to:
- Find the best-fitting line
- Minimize the difference between predicted and actual values
This difference is called the
error or
residual.
Step 3: {\color{red}Mean Squared Error (MSE) Loss Function}
MSE is used to quantify prediction error:
\[
\text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2
\]
where:
- $y_i$ = actual value
- $\hat{y}_i$ = predicted value
- $n$ = number of samples
Step 4: {\color{red}Role of MSE in Training}
MSE plays a critical role by:
- Penalizing larger errors more heavily (due to squaring)
- Providing a smooth, differentiable loss function
- Enabling optimization using gradient descent
Step 5: {\color{red}Why MSE is Preferred}
- Simple and mathematically convenient
- Works well with linear models
- Helps achieve a unique optimal solution