mixed-farming / Univariate-Linear-Regression

Implementing the gradient descent algorithm from scratch to perform univariate linear regression to analyze the profit made by a bike sharing company.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Univariate-Linear-Regression

Problem statement

Linear Regression is implemented to identify the relationship between profit of a bike sharing company and population of different cities. The main objective is to find the next city in which a new outlet should be opened which results in optimal profitability.

Data visualization

data_plot

Implementation

  • Application of the cost function as shown below:
    cost_function_formula

  • Visualization of the cost function by plotting the cost over a 2-dimensional grid of πœƒ_0 and πœƒ_1 values. The cost function J(πœƒ) is bowl-shaped and has a global minimum.
    cost_function_3D

  • Implementation of gradient descent algorithm from scratch in Python without the use of machine learning frameworks such as scikit-learn and statsmodels. Ran the algorithm over 2000 iterations to minimize the cost J(ΞΈ). With each step of batch gradient descent, the parameters πœƒ_j come closer to the optimal values that will achieve the lowest cost J(πœƒ). The plot of convergence is shown below:
    gradient_descent

Results

Univariate Linear Regression Fit:

line_of_bestfit

Libraries used

  • matplotlib
  • numpy
  • pandas
  • seaborn
  • mpl_toolkits

References

About

Implementing the gradient descent algorithm from scratch to perform univariate linear regression to analyze the profit made by a bike sharing company.


Languages

Language:Jupyter Notebook 98.2%Language:Python 1.8%