6.2 Why not Linear Regression?
One might question why linear regression cannot be used to solve classification problems and why logistic regression is necessary. Let’s understand and explore it with an example.
Example 6.1. Consider a dataset that contains information about individuals with or without diabetes based on their age. Our goal here is to predict whether a person will have diabetes or not based on their age for new individuals. Here, Age is an independent variable or a feature variable, and the Diabetes flag (Yes or No) is a dependent variable or a target variable.
Please note that, for the purpose of illustrating logistic regression concepts, we have currently simplified the dataset. However, when we conduct the model assessment at the end, we will use the same example with a complete dataset.
Now if we look at the dataset and its scatter plot (Fig 6.1), we can observe a clear relationship indicating that individuals over 40 years of age are more likely to have diabetes. It is worth noting that since we have only two categories for diabetes (0 for "No" and 1 for "Yes"), all our plots will have this binary representation regardless of the person's age. Consequently, we end up with a binary relationship.