Linear Regression is one of the simplest and most widely used algorithms in machine learning.
It is used to predict a continuous target variable based on one or more input features.
The key idea is to fit a linear equation to the observed data:
$$ y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \dots + \beta_n x_n + \epsilon $$
Where:
[ MSE = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y_i})^2 ]
Linear Regression works best when the following assumptions hold:
```python from sklearn.linear_model import LinearRegression import numpy as np
X = np.array([[1], [2], [3], [4], [5]]) y = np.array([2, 4, 5, 4, 5])
model = LinearRegression() model.fit(X, y)
print(“Coefficient:”, model.coef_) print(“Intercept:”, model.intercept_)