The summary table
The summary table below gives us a descriptive summary about the regression results.
Python3
# printing the summary table print (log_reg.summary()) |
Output :
Logit Regression Results ============================================================================== Dep. Variable: admitted No. Observations: 30 Model: Logit Df Residuals: 27 Method: MLE Df Model: 2 Date: Wed, 15 Jul 2020 Pseudo R-squ.: 0.4912 Time: 16:09:17 Log-Likelihood: -10.581 converged: True LL-Null: -20.794 Covariance Type: nonrobust LLR p-value: 3.668e-05 =================================================================================== coef std err z P>|z| [0.025 0.975] ----------------------------------------------------------------------------------- gmat -0.0262 0.011 -2.383 0.017 -0.048 -0.005 gpa 3.9422 1.964 2.007 0.045 0.092 7.792 work_experience 1.1983 0.482 2.487 0.013 0.254 2.143 ===================================================================================
Explanation of some of the terms in the summary table:
- coef : the coefficients of the independent variables in the regression equation.
- Log-Likelihood : the natural logarithm of the Maximum Likelihood Estimation(MLE) function. MLE is the optimization process of finding the set of parameters that result in the best fit.
- LL-Null : the value of log-likelihood of the model when no independent variable is included(only an intercept is included).
- Pseudo R-squ. : a substitute for the R-squared value in Least Squares linear regression. It is the ratio of the log-likelihood of the null model to that of the full model.
Logistic Regression using Statsmodels
Prerequisite: Understanding Logistic Regression
Logistic regression is the type of regression analysis used to find the probability of a certain event occurring. It is the best suited type of regression for cases where we have a categorical dependent variable which can take only discrete values.
The dataset :
In this article, we will predict whether a student will be admitted to a particular college, based on their gmat, gpa scores and work experience. The dependent variable here is a Binary Logistic variable, which is expected to take strictly one of two forms i.e., admitted or not admitted.