Skip to content

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

Notifications You must be signed in to change notification settings

mixed-farming/Univariate-Linear-Regression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published