Created
Feb 25, 2025
Last Modified
2 weeks ago

Linear Regression

Regression

  • linear regression

  • polynomial regression

  • logistic regression

Linear regression is a method in machine learning where we fit a straight line to a set of data points that appear to be concentrated around the line. This model helps to predict the outcome for future values.

Equation of line:

  • where is scaler used to transform the line.

  • and (coefficient of x) is slope of the line

Linear regression graph showing best fit line with actual data points, predicted values, slope (beta), and y-intercept

 (Input)

.

.

 (Outcome)

.

.

In the figure, n data points are plotted. We are trying to fit the line to this set of discrete data points.

  1. Given Data:

    • (Actual Data): The value of the output variable where , as provided by the data set.

  2. Line Equation:

    • (Predicted Data): The value of the outcome as predicted by the line , corresponding to .

  3. Error Calculation:

    • Error: The difference between (actual data point) and (predicted value from the line).

    • Square of Errors:

    • Sum of Square of Errors:

Where:




Goal

Now, we are trying to find out those value of and for which is minimum.

Partial Derivative with respect to :

using the power rule:

  1. Differentiate with respect to


  2. Apply the Chain Rule:

  3. Differentiate the Inner Term:








  4. Put the inner term:










  5. Simplify:






    Divide both sides by
    :







Partial Derivative with respect to :

  1. Differentiate the Error Function with respect to


  2. Apply the Chain Rule:


  3. Differentiate the Inner Term:








  4. Put the inner term:







  5. Simplify:







    Divide both sides by
    :




Equation 1:

Equation 2:

Multiply Equation 1 by :

Subtracting from Equation 2:


Variance


Co-variance


Put the value of in :

Final Value