Logistic Regression with assessments Confusion Matrix ,ROC and AUC
Experiment:
๐ฏ Aim
To implement Logistic Regression using scikit-learn on the Pima Indians Diabetes dataset and evaluate model performance with and without feature scaling using:
- Accuracy
- Precision
- Recall
- F1-score
- Confusion Matrix
- ROC Curve and AUC
๐ Theory
Logistic Regression is a supervised classification algorithm used for binary classification problems. It predicts the probability of a class using the sigmoid function:
- Output ranges from 0 to 1
-
A threshold (0.5) is used to classify:
- ≥ 0.5 → Class 1 (Disease present)
- < 0.5 → Class 0 (No disease)
๐น Feature Scaling
Feature scaling standardizes input features so that all variables contribute equally:
- Helps faster convergence
- Improves model performance
๐น Confusion Matrix
| Predicted 0 | Predicted 1 | |
|---|---|---|
| Actual 0 | TN | FP |
| Actual 1 | FN | TP |
ROC Curve (Receiver Operating Characteristic)
The ROC Curve is a graphical representation used to evaluate the performance of a binary classification model at different threshold values.
Instead of fixing the threshold at 0.5, the ROC curve shows how the model behaves for all possible thresholds (0 to 1).
๐ธ Key Terms
- True Positive Rate (TPR) / Recall / Sensitivity
- False Positive Rate (FPR)
๐ธ ROC Curve Interpretation
- X-axis → False Positive Rate (FPR)
- Y-axis → True Positive Rate (TPR)
Each point on the curve represents a different threshold value.
๐ธ Important Observations
- A curve closer to the top-left corner indicates better performance
- A random model gives a diagonal line (no discrimination ability)
- A perfect model reaches the point (0, 1)
๐น AUC (Area Under the Curve)
The AUC is the area under the ROC curve and provides a single number to summarize model performance.
๐ธ AUC Interpretation
| AUC Value | Meaning |
|---|---|
| 1.0 | Perfect classifier |
| 0.9 – 0.99 | Excellent |
| 0.8 – 0.89 | Good |
| 0.7 – 0.79 | Fair |
| 0.5 | Random guessing |
| < 0.5 | Poor model |
๐ธ Intuitive Meaning of AUC
AUC represents the probability that the model ranks a random positive example higher than a random negative example.
๐น Why ROC–AUC is Important
- Works well even when classes are imbalanced
- Independent of classification threshold
- Gives a comprehensive evaluation of model performance
๐น In This Experiment
-
ROC curves are plotted for:
- Model without scaling
- Model with scaling
- AUC values are compared to determine which model performs better
Simple Insight for Students
ROC shows how good the model is at separating classes,
AUC tells how good it is overall in one number.
๐ Dataset
Pima Indians Diabetes Dataset ( used in the previous experiment)
- Medical diagnostic dataset
-
Binary target:
- 0 → No Diabetes
- 1 → Diabetes
⚙️ Procedure
- Load the dataset
- Separate features and target
- Split into training and testing sets
- Train Logistic Regression model without scaling
- Evaluate using metrics, confusion matrix, and ROC curve
- Apply feature scaling
- Train model again
- Evaluate and compare results
๐ป Program
Output
๐ Result
- Logistic Regression model was successfully implemented
- Performance metrics were computed
- Confusion matrices and ROC curves were plotted
- Model with feature scaling showed improved performance
๐ Inference
-
Feature scaling improves:
- Model accuracy
- Convergence speed
- ROC-AUC score
- It ensures fair contribution of all features




Comments
Post a Comment