मॉडल मूल्यांकन और विज़ुअलाइज़ेशन

एंड-टू-एंड मशीन लर्निंग

Joshua Stapleton

Machine Learning Engineer

Accuracy

  • सही accuracy मेट्रिक्स मज़बूत मॉडल मूल्यांकन के लिए ज़रूरी हैं
  • नतीजों को गलत समझना या छिपना आसान है

स्टैंडर्ड accuracy:

  • स्टैंडर्ड accuracy = सही उत्तरों की संख्या / कुल उत्तरों की संख्या
  • स्टैंडर्ड accuracy कई बार मददगार नहीं होती

उदाहरण:

# 99 पॉजिटिव और 1 नेगेटिव वाले imbalanced डेटासेट पर ~99% accuracy
for patient_datapoint in heart_disease_dataset:
    model.prediction(patient_datapoint) = 'positive'
एंड-टू-एंड मशीन लर्निंग

Confusion matrix

True positives (TP)

  • Model prediction = actual classification = positive
  • मॉडल ने हृदयरोग प्रीडिक्ट किया, मरीज को वाकई हृदयरोग था

False positives (FP)

  • Model prediction = positive, actual classification = negative
  • मॉडल ने हृदयरोग प्रीडिक्ट किया, मरीज को हृदयरोग नहीं था

False negatives (FN)

  • Model prediction = negative, actual classification = positive
  • मॉडल ने हृदयरोग नहीं प्रीडिक्ट किया, लेकिन मरीज को हृदयरोग था

True negatives (TN)

  • Model prediction = actual classification = negative
  • मॉडल ने हृदयरोग नहीं प्रीडिक्ट किया, और मरीज को हृदयरोग नहीं था
एंड-टू-एंड मशीन लर्निंग

Balanced accuracy

  • ज़्यादातर बाइनरी क्लासिफिकेशन मॉडलों के लिए plain accuracy से बेहतर मेट्रिक
  • दोनों क्लास पर वेटेड एवरेज देता है
  • Balanced accuracy = (TP + TN) / 2
from sklearn.metrics import balanced_accuracy_score

# Assume y_test is the true labels and y_pred are the predicted labels
y_pred = model.predict(X_test)
bal_accuracy = balanced_accuracy_score(y_test, y_pred)
print(f"Balanced Accuracy: {bal_accuracy:.2f}")
Balanced Accuracy: 0.85
एंड-टू-एंड मशीन लर्निंग

Confusion matrix का उपयोग

कन्फ्यूज़न मैट्रिक्स

एंड-टू-एंड मशीन लर्निंग

Cross validation

Cross-validation

  • रिसैंपलिंग प्रक्रिया
  • नतीजों की मजबूती सुनिश्चित करता है

 

k-fold cross-validation

  • पैरामीटर 'k' = डेटासेट के स्प्लिट की संख्या
  • हर मॉडल रन पर नया train/test स्प्लिट रिसैंपल करें

क्रॉस-वैलिडेशन दर्शाता डायग्राम

एंड-टू-एंड मशीन लर्निंग

Cross validation उपयोग

  • sklearn से k-fold cross validation का सीधा इम्प्लीमेंटेशन
  • मॉडल-अज्ञेय स्कोरिंग

उपयोग:

from sklearn.model_selection import cross_val_score, KFold

# डेटा को 10 बराबर हिस्सों में बाँटें
kfold = KFold(n_splits=5, shuffle=True, random_state=42)

# दिए गए मॉडल के लिए cross validation accuracy लें cv_results = cross_val_score(model, heart_disease_X, heart_disease_y, cv=kfold, scoring='balanced_accuracy')
एंड-टू-एंड मशीन लर्निंग

हाइपरपैरामीटर ट्यूनिंग

हाइपरपैरामीटर:

  • ग्लोबल मॉडल पैरामीटर (ट्रेनिंग के दौरान नहीं बदलता)
  • मॉडल प्रदर्शन सुधारने हेतु एडजस्ट करें
# टेस्ट करने वाले Hyperparameters
C_values = [0.001, 0.01, 0.1, 1, 10, 100, 1000]

# Hyperparameters पर मैन्युअल इटरेशन
for C in C_values:
    model = LogisticRegression(max_iter=200, C=C)
    model.fit(X_train, y_train)
    accuracy = cross_val_score(model, X, y, cv=kfold, scoring='balanced_accuracy')
    print(f"C = {C}: Bal Acc: {accuracy.mean():.4f} (+/- {accuracy.std():.4f})")
एंड-टू-एंड मशीन लर्निंग

हाइपरपैरामीटर ट्यूनिंग उदाहरण

हाइपरपैरामीटर ट्यूनिंग का उदाहरण आउटपुट:

 

C = 0.001: Bal Acc: 0.6200 (+/- 0.0215)
C = 0.01: Bal Acc: 0.7325 (+/- 0.0234)
C = 0.1: Bal Acc: 0.7923 (+/- 0.0202)
C = 1: Bal Acc: 0.8050 (+/- 0.0191)
C = 10: Bal Acc: 0.8034 (+/- 0.0185)
C = 100: Bal Acc: 0.8021 (+/- 0.0187)
C = 1000: Bal Acc: 0.8017 (+/- 0.0188)
एंड-टू-एंड मशीन लर्निंग

अभ्यास करते हैं!

एंड-टू-एंड मशीन लर्निंग

Preparing Video For Download...