In the case of Linear Regression, the Cost function is –

But for Logistic Regression,

It will result in a non-convex cost function. But this results in cost function with local optima’s which is a very big problem for Gradient Descent to compute the global optima.

So, for Logistic Regression the cost function is

**If y = 1**

Cost = 0 if y = 1, h_{θ}(x) = 1

But as,

h_{θ}(x) -> 0

Cost -> Infinity

**If y = 0**

So,

To fit parameter **θ**, J(θ) has to be minimized and for that Gradient Descent is required.

**Gradient Descent – **Looks similar to that of Linear Regression but the difference lies in the hypothesis h_{θ}(x)

Attention geek! Strengthen your foundations with the **Python Programming Foundation** Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the **Python DS** Course.

## Recommended Posts:

- ML | Linear Regression vs Logistic Regression
- Understanding Logistic Regression
- Identifying handwritten digits using Logistic Regression in PyTorch
- ML | Logistic Regression using Tensorflow
- ML | Logistic Regression using Python
- ML | Why Logistic Regression in Classification ?
- ML | Logistic Regression v/s Decision Tree Classification
- ML | Kaggle Breast Cancer Wisconsin Diagnosis using Logistic Regression
- ML | Heart Disease Prediction Using Logistic Regression .
- Logistic Regression in R Programming
- Differentiate between Support Vector Machine and Logistic Regression
- Logistic Regression using Statsmodels
- Advantages and Disadvantages of Logistic Regression
- Implementation of Logistic Regression from Scratch using Python
- COVID-19 Peak Prediction using Logistic Function
- Python - Logistic Distribution in Statistics
- sympy.stats.Logistic() in python
- numpy.random.logistic() in Python
- Linear Regression (Python Implementation)
- Multiple Linear Regression using R

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.