TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Getting Started

Linear regression and gradient descent for absolute beginners

Lily Chen
6 min readNov 26, 2020

--

Image created by me
height of mother/daughter pairs
Line of best fit, or “regression line”

Linear regression is about finding the line of best fit for a dataset. This line can then be used to make predictions.

Gradient descent is a tool to arrive at the line of best fit

y = 0.89*(5.5 / 4.07)x + b
y = 1.2x + b
63.33 = 1.2*63.5 + b
b = -12.87
y = 1.2x - 12.87

Regression line using statistics is y = 1.2x -12.87

Error and square of error

Line of best fit is the least square regression line

Line C is better fit than B, which is better fit than A

Gradient descent is an algorithm that approaches the least squared regression line via minimizing sum of squared errors through multiple iterations.

Gradient Descent Algorithm

cost equation
Gradient descent formula by taking partial derivative of the cost function

Gradient descent is an algorithm that approaches the least squared regression line via minimizing sum of squared errors through multiple iterations.

https://algebra1course.wordpress.com/2013/02/19/3-matrix-operations-dot-products-and-inverses/

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Lily Chen
Lily Chen

Written by Lily Chen

Senior software engineer at Datadog. I write about tech and life. Portfolio: https://lilychencodes.com/

Responses (4)