The linear regression model is represented as:
Where:
-
$y$ is the predicted value (in this case, the predicted salary). -
$m$ is the slope (or coefficient) of the linear model. -
$b$ is the intercept (or bias) of the linear model. -
$x$ is the input feature, which represents years of experience.
The cost function measures the error between the predicted values (
Where:
-
$J(m, b)$ is the cost function, which quantifies how well the model fits the data. -
$n$ is the number of data points in the dataset. -
$y_i$ is the actual value (salary) for the $i$th data point. -
$x_i$ is the input feature (years of experience) for the $i$th data point. -
$m$ and$b$ are the parameters of the linear model that we want to optimize to minimize the cost function.
Gradient descent is an iterative optimization algorithm used to find the values of
The update formulas for
Where:
-
$m$ is the current value of the slope. -
$l$ is the learning rate, which controls the step size of the updates. -
$\frac{\partial J}{\partial m}$ is the gradient of the cost function with respect to$m$ .
Where:
-
$b$ is the current value of the intercept. -
$l$ is the learning rate. -
$\frac{\partial J}{\partial b}$ is the gradient of the cost function with respect to$b$ .
These update formulas are applied iteratively for a specified number of epochs (iterations) to gradually adjust the values of