Logistic Regression Implementation
Implement the logistic regression.
We'll cover the following...
It's time to implement what we have learned and see how logistic regression can be used in business.
The data and its overview
We can think about a college’s decision to shortlist the applicants for admission based on their GRE or GPA. The college offers some specializations; the codes are in the field column. We are trying to keep it simple and are considering only a few columns.
gre: The GRE score of the applicant.gpa: The GPA of the applicant.field: The field of study for which the student has applied to.admit: The target column with binary 1-0 outcomes showing if the student was successful or not.
We can see some missing data in this small dataset, and we can calculate the numbers.
Well, only a small fraction of the data is missing. We can ignore it.
Let's compute the probabilities and the odds for admission based on the field of study.
So far, we have four fields available for the applicants, and most students were admitted to the field with code 2.
Now that we have the probabilities and odds, let’s model them and compare.
Linear regression vs. logistic regression
Similar to linear regression, we’ll have to create instances for the logistic regression and train the model on the dataset. Once the model is trained, we can also grab the ...