# ML | Why Logistic Regression in Classification ?

Using Linear Regression, all predictions >= 0.5 can be considered as 1 and rest all < 0.5 can be considered as 0. But then the question arises why classification can’t be performed using it?

**Problem –**

Suppose we are classifying a mail as spam or not spam and our output is **y**, it can be 0(spam) or 1(not spam). In case of Linear Regression, h_{θ}(x) can be > 1 or < 0. Although our prediction should be in between 0 and 1, the model will predict value out of the range i.e. maybe > 1 or < 0.

So, that’s why for a Classification task, Logistic/Sigmoid Regression plays its role.

Here, we plug **θ ^{T}x** into logistic function where θ are the weights/parameters and

**x**is the input and

**h**is the hypothesis function.

_{θ}(x)**g()**is the sigmoid function.

It means that y = 1 probability when x is parameterized to **θ**

To get the discrete values 0 or 1 for classification, discrete boundaries are defined. The hypothesis function cab be translated as

Decision Boundary is the line that distinguishes the area where y=0 and where y=1. These decision boundaries result from the hypothesis function under consideration.

**Understanding Decision Boundary with an example – **

Let our hypothesis function be

Then the decision boundary looks like

Let out weights or parameters be –

So, it predicts y = 1 if

And that is the equation of a circle with radius = 1 and origin as the center. This is the Decision Boundary for our defined hypothesis.

## Recommended Posts:

- ML | Logistic Regression v/s Decision Tree Classification
- ML | Logistic Regression using Tensorflow
- ML | Logistic Regression using Python
- Understanding Logistic Regression
- ML | Cost function in Logistic Regression
- Identifying handwritten digits using Logistic Regression in PyTorch
- ML | Kaggle Breast Cancer Wisconsin Diagnosis using Logistic Regression
- ML | Classification vs Regression
- Regression and Classification | Supervised Machine Learning
- Getting started with Classification
- ML | Using SVM to perform classification on a non-linear dataset
- Python | Image Classification using keras
- Multiclass classification using scikit-learn
- ML | Cancer cell classification using Scikit-learn
- Basic Concept of Classification (Data Mining)

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.