Thuta Learning
Machine Learning Basics
AdvancedData & Databasesအလယ်အလတ်

Support Vector Machines (SVM)

Machine Learning Basicsသင်ခန်းစာ 16

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

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

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

SVM ရဲ့ core idea က class ၂ ခုကို ခွဲခြားတဲ့ boundary (decision boundary) ကို ရှာတဲ့အခါ, class နှစ်ခုစလုံးက boundary နဲ့ 'ဝေးဝေးဆုံး' ဖြစ်အောင် (maximum margin) ရှာဖွေခြင်းပါ — boundary နဲ့ အနီးဆုံးက data point တွေကို 'Support Vector' လို့ ခေါ်ပါတယ် (boundary ကို ဆုံးဖြတ်ပေးတဲ့ point တွေဖြစ်လို့ ဒီနာမည်ရတာပါ)။ Kernel Trick ကတော့ data ကို linear boundary ဖြင့် ခွဲခြား၍ မရတဲ့ scenario (data ကို circle ပုံစံလိုမျိုး ပြန့်ကျဲနေတဲ့) မှာ data ကို higher dimension ဆီ mathematically ပြောင်းလဲပြီး, linear boundary ရှာနိုင်စေတဲ့ technique ပါ (`kernel='linear'`, `kernel='rbf'` စတာမျိုး ရွေးချယ်နိုင်ပါတယ်).

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

`from sklearn.svm import SVC; model = SVC(kernel='rbf'); model.fit(X_train, y_train)` လို့ ရေးရင် — 'rbf' (Radial Basis Function) kernel ကို သုံးပြီး, linear boundary နဲ့ ခွဲမရတဲ့ complex pattern ကိုပါ classify နိုင်ပါတယ် — image classification, text classification (spam detection) ကဲ့သို့ high-dimensional feature space ရှိတဲ့ problem တွေမှာ SVM က traditionally strong performance ပြသလေ့ရှိပါတယ်.

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

python
from sklearn.svm import SVC

# 'rbf' kernel handles non-linear decision boundaries
model = SVC(kernel='rbf', C=1.0)
model.fit(X_train, y_train)

accuracy = model.score(X_test, y_test)
print(f"SVM accuracy: {accuracy:.2f}")
You should see
SVM accuracy: 0.89

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

SVM model ကို `kernel='linear'` နှင့် `kernel='rbf'` ၂ မျိုးနဲ့ train ကြည့်ပြီး, accuracy result ကို compare ကြည့်ပါ — dataset ရဲ့ pattern က linear ဒါမှမဟုတ် non-linear ဆိုတာ ဘယ် kernel ကနေ ပိုကောင်းလဲ ကနေ ခန့်မှန်းနိုင်ပါတယ်.

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

SVM ရဲ့ hyperparameter (`C`, kernel parameter) ကို tune မလုပ်ဘဲ default value ကို သုံးရင် — performance suboptimal ဖြစ်နိုင်ပါတယ်, Hyperparameter Tuning (နောက် lesson) ကို ဆက်လေ့လာပါ.

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

  • SVM ကို large dataset (row သန်းချီ) ပေါ်မှာ တိုက်ရိုက် train ကြိုးစားခြင်း — SVM ရဲ့ training time က dataset size ကြီးလာတာနဲ့အမျှ သိသိသာသာ ကြာလာနိုင်ပါတယ်, large-scale problem အတွက် အသင့်တော်ဆုံး algorithm မဟုတ်ပါ
  • Feature Scaling မလုပ်ဘဲ SVM ကို သုံးခြင်း — SVM က KNN ကဲ့သို့ distance-based concept ကို သုံးလို့, scaling က performance ကို သိသိသာသာ သက်ရောက်ပါတယ်

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

SVM model ကို `kernel='linear'` နှင့် `kernel='rbf'` ၂ မျိုးနဲ့ train ကြည့်ပြီး, accuracy result ကို compare ကြည့်ပါ — dataset ရဲ့ pattern က linear ဒါမှမဟုတ် non-linear ဆိုတာ ဘယ် kernel ကနေ ပိုကောင်းလဲ ကနေ ခန့်မှန်းနိုင်ပါတယ်.

အလုပ်ဖြစ်ကြောင်း ဒီလိုသိမယ်: SVM accuracy: 0.89

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Support Vector Machines (SVM) | Thuta Learning