/simple-linear-regression

from scratch using python

Primary LanguageJupyter Notebook

simple-linear-regression

Linear regression attempts to model the relationship between two variables by fitting a linear equation to observed data. A linear regression line has an equation of the form Y = a + bX, where X is the explanatory variable and Y is the dependent variable.

The case of one explanatory variable is called simple linear regression. For more than one explanatory variable, the process is called multiple linear regression.

We will first learn to implement simple linear regression from scratch with python.

Gradient Descent

Gradient descent is an optimization algorithm used to find the values of parameters (coefficients) of a function (f) that minimizes a cost function (cost).

Dependencies

  • Numpy
  • Matplotlib
  • Pandas

Dataset

inusrance.csv - swedish insurance dataset to demonstrate simple linear regression data.csv - sample dataset with two variables used for the gradient descent example.

Usage

  • linearregression.ipynb - A Jupyter notebook to demonstrate code of simple linear regression
  • gradientdescent.ipynb - A Jupyter notebook to demonstrate gradient descent using simple linear regression.