Today, I worked up further on Logistic Regression.
Binary logistic regression, ordinal logistic regression, and multinomial logistic regression are the three primary subtypes of logistic regression.
When the dependent variable is binary, Binary Logistic Regression—the most popular of the three forms of logistic regression—is employed. It can only make two assumptions.
Accuracy Score
The accuracy score is a commonly used metric to measure the performance of a classification model. It calculates the percentage of correct predictions made by the model. The accuracy score ranges from 0 to 1, where 1 represents a perfect prediction.
Classification Report
The classification report provides a comprehensive summary of the model’s performance for each class in a classification problem. It includes metrics such as precision, recall, and F1-score, which help evaluate the model’s ability to correctly classify instances of each class.
The code provided consists of two main parts: importing the necessary modules and evaluating the logistic regression model’s performance.
First, we import the accuracy_score
and classification_report
functions from the sklearn.metrics
module using the from
keyword.
Next, we have the report
variable, which stores the classification report generated by the classification_report
function. This function takes two arguments: y_test
and y_pred
. y_test
represents the true labels of the test data, while y_pred
represents the predicted labels generated by the logistic regression model.
Finally, I printed the accuracy score and the classification report using the print
function.
Output –
Logistic Regression Model Accuracy: 0.9567341242149338 Classification Report: precision recall f1-score support 0 0.00 0.00 0.00 62 1 0.96 1.00 0.98 1371 accuracy 0.96 1433 macro avg 0.48 0.50 0.49 1433 weighted avg 0.92 0.96 0.94 1433