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

ပထမဆုံး ML Model

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

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

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

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

Linear Regression က ML algorithm ထဲမှာ ရိုးရှင်းဆုံး, နားလည်ရလွယ်ဆုံးထဲက တစ်ခုပါ — feature (x) နဲ့ target (y) ကြားက linear relationship (straight line) ကို ရှာဖွေခြင်းပါ။ scikit-learn ရဲ့ API pattern က algorithm အားလုံး consistent ပါ — `.fit(X_train, y_train)` (model ကို train), `.predict(X_test)` (prediction ချ) — ဒီ pattern ကို tutorial တစ်လျှောက်လုံးမှာ algorithm ကွဲပြားတိုင်း ထပ်ခါထပ်ခါ တွေ့ရမှာပါ.

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

House size (X) ကနေ house price (y) ကို predict ချင်ရင် — `from sklearn.linear_model import LinearRegression; model = LinearRegression(); model.fit(X_train, y_train)` လို့ ရေးရင် model ကို train ပြီးပါပြီ, `predictions = model.predict(X_test)` လို့ ရေးရင် test data ရဲ့ price ကို predict ချပေးပါတယ် — `model.score(X_test, y_test)` ကို run ရင် model ရဲ့ accuracy (R² score) ကို ချက်ချင်း ကြည့်နိုင်ပါတယ်.

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

python
from sklearn.linear_model import LinearRegression

model = LinearRegression()
model.fit(X_train, y_train)

predictions = model.predict(X_test)
print(predictions[:5])

accuracy = model.score(X_test, y_test)
print(f"R^2 score: {accuracy:.2f}")
You should see
[245000. 312000. 198000. 410000. 275000.]
R^2 score: 0.87

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

Sample dataset (house size vs price) ကို ကိုယ်တိုင် create ပြီး, Linear Regression model ကို train/predict/score run ကြည့်ပါ — R² score ရလာပြီး confirm လုပ်ကြည့်ပါ။

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

Linear Regression ရဲ့ R² score တစ်ခုတည်းကို 'model ကောင်း/မကောင်း' ဆိုတဲ့ final judgment အနေနဲ့ မသုံးပါနှင့် — Intermediate chapter ရဲ့ evaluation metric များစွာကို ပေါင်းစပ် ကြည့်ရှုသင့်ပါတယ်.

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

  • `.fit()` ကို run ဖို့ မေ့ဘဲ `.predict()` ကို တိုက်ရိုက် ခေါ်ကြိုးစားခြင်း — 'model not fitted' error တွေ့ရနိုင်ပါတယ်
  • R² score = 0.99+ (almost perfect) ရလာရင် 'model ကောင်းလွန်းပြီ' ဆိုပြီး suspicious မဖြစ်ခြင်း — overfitting/data leakage ရဲ့ warning sign ဖြစ်နိုင်ပါတယ်

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

Sample dataset (house size vs price) ကို ကိုယ်တိုင် create ပြီး, Linear Regression model ကို train/predict/score run ကြည့်ပါ — R² score ရလာပြီး confirm လုပ်ကြည့်ပါ။

You'll know it worked when: [245000. 312000. 198000. 410000. 275000.] R^2 score: 0.87

ပထမဆုံး ML Model | Thuta Learning