Ravindra BagaleCourses & study guides English Track your progress

37. ML Model चांगले आहे का कसे तपासायचे

Data Science

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 वाचा

  1. confusion_matrix(y_true, y_pred) print करा.
  2. False negatives (missed fraud) आणि false positives (false alarms) गोल करा.
  3. कोणती चूक दुकानाला जास्त नुकसान करते ते ठरवा.
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.