37. ML Model चांगले आहे का कसे तपासायचे
37.3 Confusion Matrix
का गरजेचे आहे. Confusion matrix चार buckets दाखवते: true/false × positive/negative — म्हणून कोणी एका % वरून वाद घालत नाही
हे काय आहे. Rows = खरा class, columns = predicted class (sklearn default). एका grid मध्ये true positives, false positives, true negatives, false negatives दिसतात.
कसे करायचे.
Grid वाचा
confusion_matrix(y_true, y_pred)print करा.- False negatives (missed fraud) आणि false positives (false alarms) गोल करा.
- कोणती चूक दुकानाला जास्त नुकसान करते ते ठरवा.
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
y_true = [1, 1, 1, 0, 0, 0, 0, 0]
y_pred = [1, 1, 0, 1, 0, 0, 0, 0]
print(confusion_matrix(y_true, y_pred))
# Optional plot in Jupyter:
# ConfusionMatrixDisplay.from_predictions(y_true, y_pred)
Ravindra Bagale's Tip
Draw the confusion matrix on a whiteboard or on paper once by yourself. When you draw the four boxes with your own hand, you will easily remember what each number means.
Ravindra Bagale's Tip – मराठी
Confusion matrix एकदा स्वतः whiteboard वर किंवा कागदावर काढा. चारही boxes स्वतःच्या हाताने काढल्यावर प्रत्येक number चा अर्थ सहज लक्षात राहतो.
Ravindra Bagale's Tip – हिंदी
Confusion matrix को एक बार खुद whiteboard या कागज़ पर बनाओ. चारों boxes अपने हाथ से बनाने पर हर number का मतलब आसानी से याद रहता है.