Member-only story

Machine Learning

Fully Explained Logistic Regression with Python

A Statistical non-linear approach in the machine learning algorithm

Amit Chauhan
Towards AI
Published in
5 min readJan 16, 2021

--

Linear and Non-Linear diagram. A photo by Author

The reason we switch from a linear regression model to a non-linear regression model is because of the output feature variable. While studying linear regression last week, I got a data set in which the dependent variable has categories.

In this article, we will discuss basic concepts regarding logistic regression and learn how we will about maximum likelihood estimates and log(odds). A good understanding is very much important and it saves lots of our time.

First, we need to know why linear regression is not suitable for categories of data. From the graph below we observe that the first one is for linear regression and the second one is also for linear but with binary category values. The insights from these two graphs we can take are that the first graph has values in linearly approach i.e. the independent variable increases the dependent variable is also increased. But, the second graph doesn’t tell this type of behavior rather the dependent variable values are spotted on two values i.e. “0” and “1” only.

The linear approach on a different type of dependent variables. A photo by Author

If we use the linear approach on the second values the error rate will increase and our model won’t fit well and one more thing to be noticed that the linear line is more above and more below the data points that we don’t need for prediction. So, we need an approach in which the prediction will be in “0” and “1” only.

Logistic Regression Curve. A photo by Author

From this thought, we can think about probability in which the probability values ranges from “0” to “1”. Alright, but we also need to change our prediction line…

--

--

Published in Towards AI

The leading AI community and content platform focused on making AI accessible to all. Check out our new course platform: https://academy.towardsai.net/courses/beginner-to-advanced-llm-dev

Responses (2)

Write a response