Logistic Regression
What Is Logistic Regression?
Logistic regression is a supervised classification algorithm, used mostly for binary classification. It predicts the probability that an outcome belongs to a certain class.
For example, suppose we know whether a person smokes, their age, and their blood pressure and cholesterol. From this information, we want to predict whether the person could have heart disease. This is a binary classification problem.
Logistic regression can be used for many other classification problems:
- Medical diagnosis: predicting whether a patient has a disease, such as diabetes, from symptoms, test results, or genetic data
- Credit scoring: predicting whether a person will default on a loan, based on prior data
- Customer behavior: predicting whether a customer will buy a product from their age, income, and past purchases, or whether they will click on it
The Problem
In this lesson, we predict heart disease from age, blood pressure, cholesterol, and whether someone is a smoker. Our labeled training dataset has samples:
| Age | Blood Pressure | Cholesterol | Smoker | Heart Disease |
|---|---|---|---|---|
| 45 | 130 | 230 | 1 | 1 |
| 54 | 140 | 250 | 0 | 1 |
| 62 | 150 | 240 | 1 | 1 |
| 50 | 120 | 210 | 0 | 0 |
| 38 | 110 | 190 | 0 | 0 |
| 65 | 155 | 260 | 1 | 1 |
| 59 | 145 | 255 | 1 | 1 |
| 48 | 125 | 200 | 0 | 0 |
| 53 | 135 | 245 | 1 | 1 |
| 70 | 160 | 270 | 1 | 1 |