How Does Logistic Regression Work?
Just like linear regression, where the beta coefficients for the variables are estimated using the Ordinary Least Squares (OLS) method, a logistic regression model leverages the maximum-likelihood estimation (MLE). The MLE function estimates the best set of values of the model parameters or beta coefficients such that it maximizes the likelihood function, that is, the probability estimates, which can be also defined as the agreement of the selected model with the observed data. When the best set of parameter values are estimated, plugging these values or beta coefficients into the model equation as previously defined would help in estimating the probability of the outcome for a given sample. Akin to OLS, MLE is also an iterative process.
Let's see a logistic regression model in action on our dataset. To get started, we will use only a small subset of variables for the model. Ideally, it is recommended to start with the most important variables based on the...