Thuta Learning
ရှာဖွေရန်
IntermediateData & Databasesintermediate

Model Evaluation Metrics

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Model Evaluation Metrics ကို ကြောက်စရာမလိုအောင် နားလည်မယ်
  • ကိုယ်တိုင် scikit-learn code ကို run ကြည့်တတ်မယ်
  • Real project ထဲမှာ ဒီ concept ကို ချက်ချင်း အသုံးချတတ်မယ်

ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်

Confusion Matrix က classification result ကို ၄ category (True Positive, True Negative, False Positive, False Negative) ခွဲပြထားတဲ့ table ပါ — Accuracy (correct prediction/total) တစ်ခုတည်းက class imbalance ရှိတဲ့ dataset မှာ misleading ဖြစ်နိုင်ပါတယ် (Intermediate lesson 2 ရဲ့ spam example ကလို)။ Precision (positive predict ချတာထဲက ဘယ်နှစ်ခု really positive လဲ, false alarm နည်းချင်တဲ့အခါ ဦးစားပေး) နဲ့ Recall (real positive ထဲက ဘယ်နှစ်ခု ဖမ်းမိလဲ, false negative ဆိုးရွားတဲ့ scenario ဥပမာ - disease detection မှာ ဦးစားပေး) ကြား trade-off ရှိပါတယ် — F1 Score ကတော့ Precision/Recall ၂ ခုစလုံးကို balance ပေးတဲ့ single metric ပါ.

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

Cancer detection model တစ်ခုမှာ — Recall ကို ဦးစားပေးသင့်ပါတယ် (patient တစ်ယောက်ကို 'ရောဂါမရှိဘူး' လို့ မှားခန့်မှန်းရင် (False Negative) ဘဝနစ်နာမှု ကြီးမားနိုင်လို့), Spam filter မှာတော့ Precision ကို ဦးစားပေးနိုင်ပါတယ် (important email ကို spam လို့ မှားခန့်မှန်းရင် (False Positive) user disturb ဖြစ်နိုင်လို့) — `from sklearn.metrics import classification_report; print(classification_report(y_test, predictions))` ကို run ရင် metric အားလုံးကို table format ဖြင့် တစ်ပြိုင်နက် ကြည့်နိုင်ပါတယ်.

အတူတူ ကြည့်မယ်

python
from sklearn.metrics import confusion_matrix, classification_report

predictions = model.predict(X_test)

print(confusion_matrix(y_test, predictions))
print(classification_report(y_test, predictions))
You should see
[[85  5]
 [10 100]]

              precision    recall  f1-score
           0       0.89      0.94      0.92
           1       0.95      0.91      0.93

၅ မိနစ် စမ်းကြည့်

Classification model (Intermediate lesson 2 ရဲ့ spam example) ကို `confusion_matrix()`/`classification_report()` ဖြင့် evaluate ကြည့်ပြီး, Precision/Recall/F1 value ကို ဖတ်ရှင်းကြည့်ပါ — ဘယ် metric ကို ဒီ use case အတွက် ဦးစားပေးသင့်လဲ ရေးကြည့်ပါ။

သတိလေးတစ်ချက်

Metric ကို test set တစ်ခုတည်းနဲ့ တစ်ကြိမ်ပဲ ကြည့်ပြီး final decision ချခြင်းသည် statistically unreliable ဖြစ်နိုင်ပါတယ် — Cross-Validation (နောက် lesson) ကို သုံးရင် ပိုတည်ငြိမ်တဲ့ estimate ရနိုင်ပါတယ်.

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Class imbalance ရှိတဲ့ dataset ကို Accuracy တစ်ခုတည်းနဲ့ evaluate ခြင်း — 95% not-spam data ဆိုရင် 'always predict not-spam' model ကတောင် 95% accuracy ရနိုင်ပေမယ့် useless ပါ
  • Precision/Recall trade-off ကို use case context မရှိဘဲ 'F1 score ကို အမြဲ maximize လုပ်ရမယ်' လို့ blanket rule အဖြစ် လိုက်နာခြင်း — business context (false positive vs false negative cost) ကို ထည့်တွက်ရပါမယ်

အခု ကိုယ်တိုင် စမ်းကြည့်

Classification model (Intermediate lesson 2 ရဲ့ spam example) ကို `confusion_matrix()`/`classification_report()` ဖြင့် evaluate ကြည့်ပြီး, Precision/Recall/F1 value ကို ဖတ်ရှင်းကြည့်ပါ — ဘယ် metric ကို ဒီ use case အတွက် ဦးစားပေးသင့်လဲ ရေးကြည့်ပါ။

You'll know it worked when: [[85 5] [10 100]] precision recall f1-score 0 0.89 0.94 0.92 1 0.95 0.91 0.93

Model Evaluation Metrics | Thuta Learning