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

Project — House Price Prediction

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

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

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

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

Real-world regression project က Basic/Intermediate chapter ကနေ လေ့လာခဲ့တဲ့ step အားလုံးကို sequence အတိုင်း ချိတ်ဆက် run ရပါတယ် — Data Loading → Preprocessing (missing value, scaling) → Feature Engineering → Train/Test Split → Model Training (Linear Regression, Random Forest ကို compare) → Evaluation (R², cross-validation) → best model ကို select ခြင်း ဆိုတဲ့ full workflow ကို ကိုယ်တိုင် ဆောင်ရွက်ကြည့်ခြင်းက, concept တစ်ခုချင်းစီ ဘယ်လို ချိတ်ဆက် အသုံးချရမလဲ ဆိုတာကို solidify လုပ်ပေးပါလိမ့်မယ်.

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

House dataset (size, bedrooms, age, location) ကို — (1) missing value handle, (2) categorical feature ကို One-Hot Encoding, (3) numeric feature ကို scale, (4) 80/20 train/test split, (5) Linear Regression + Random Forest ၂ ခုကို train ပြီး compare, (6) cross-validation ဖြင့် ပိုတည်ငြိမ်တဲ့ estimate ရယူ, (7) best model ကို ရွေးချယ် ဆိုတဲ့ full pipeline ကို ကိုယ်တိုင် run ကြည့်ပါ.

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

python
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.linear_model import LinearRegression
from sklearn.ensemble import RandomForestRegressor
from sklearn.preprocessing import StandardScaler

# 1-3: preprocess, encode, scale (see Basic/Intermediate chapters)
# 4: split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# 5: train and compare models
lr = LinearRegression().fit(X_train, y_train)
rf = RandomForestRegressor(n_estimators=100, random_state=42).fit(X_train, y_train)

print(f"Linear Regression R^2: {lr.score(X_test, y_test):.2f}")
print(f"Random Forest R^2: {rf.score(X_test, y_test):.2f}")

# 6: cross-validate the better model
cv_scores = cross_val_score(rf, X, y, cv=5)
print(f"Random Forest CV mean: {cv_scores.mean():.2f}")
You should see
Linear Regression R^2: 0.82
Random Forest R^2: 0.89
Random Forest CV mean: 0.87

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

House price dataset (sample data ကိုယ်တိုင် create ပါ, ဒါမှမဟုတ် public dataset) ကို full pipeline အတိုင်း run ကြည့်ပြီး, model ၂ မျိုးကို compare ကာ final model ကို ရွေးချယ်ကြည့်ပါ။

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

Production မှာ deploy မယ့် final model ကို data အားလုံး (train+test ပေါင်း) နဲ့ ပြန် train ရပါမယ် — evaluation အတွက်ပဲ train/test ခွဲထားခဲ့တာမို့, deployment model ကတော့ data ရရှိသလောက် အကုန် အသုံးချသင့်ပါတယ်.

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

  • Model compare လုပ်တဲ့အခါ preprocessing step (scaling) ကို model တစ်ခုအတွက်ပဲ apply လုပ်ပြီး, တခြားတစ်ခုကို မလုပ်ခြင်း — comparison ကို unfair ဖြစ်စေနိုင်ပါတယ်
  • Best model ကို test set score တစ်ခုတည်းအပေါ်မှာသာ ဆုံးဖြတ်ခြင်း — cross-validation result ကိုပါ ထည့်တွက်ရမယ် (Intermediate chapter)

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

House price dataset (sample data ကိုယ်တိုင် create ပါ, ဒါမှမဟုတ် public dataset) ကို full pipeline အတိုင်း run ကြည့်ပြီး, model ၂ မျိုးကို compare ကာ final model ကို ရွေးချယ်ကြည့်ပါ။

You'll know it worked when: Linear Regression R^2: 0.82 Random Forest R^2: 0.89 Random Forest CV mean: 0.87

Project — House Price Prediction | Thuta Learning