Member-only story

Implementing ordinary least squares (OLS) using Statsmodels in Python

Dhiraj K
Heartbeat
Published in
4 min readOct 10, 2019
Photo by Ilze Lucero on Unsplash

Are you looking for a computationally cheap, easy-to-explain linear estimator that’s based on simple mathematics? Look no further than OLS!

OLS stands for ordinary least squares. OLS is heavily used in econometrics—a branch of economics where statistical methods are used to find the insights in economic data.

As we know, the simplest linear regression algorithm assumes that the relationship between an independent variable (x) and dependent variable (y) is of the following form: y = mx + c, which is the equation of a line.

In line with that, OLS is an estimator in which the values of m and c (from the above equation) are chosen in such a way as to minimize the sum of the squares of the differences between the observed dependent variable and predicted dependent variable. That’s why it’s named ordinary least squares.

Also, it should be noted that when the sum of the squares of the differences is minimum, the loss is also minimum—hence the prediction is better.

Please find below the video on Multiple Linear Regression in Python and sklearn

--

--

Published in Heartbeat

Comet is a machine learning platform helping data scientists, ML engineers, and deep learning engineers build better models faster

Written by Dhiraj K

Data Scientist & Machine Learning Evangelist. I love transforming data into impactful solutions and sharing my knowledge through teaching. dhiraj10099@gmail.com

No responses yet

Write a response