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

Feature Engineering

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

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

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

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

Feature Engineering ဆိုတာ raw data ကနေ model ကို ပိုအထောက်အကူဖြစ်စေမယ့် feature အသစ်တွေ ဖန်တီးခြင်း/ရွေးချယ်ခြင်းပါ — 'Garbage in, garbage out' ဆိုတဲ့ principle အရ, feature ကောင်းကောင်း မရှိရင် algorithm ဘယ်လောက် sophisticated ဖြစ်ဖြစ် performance ကောင်းလို့ မရနိုင်ပါ။ Categorical Encoding ကတော့ text category (ဥပမာ - 'red', 'blue', 'green') ကို number ဆီ ပြောင်းလဲခြင်းပါ — One-Hot Encoding (category တစ်ခုချင်းစီအတွက် binary column သီးခြား ဖန်တီး) ကို အသုံးအများဆုံးပါ။ Feature Selection ကတော့ relevant မဟုတ်တဲ့/redundant feature ကို ဖယ်ရှားခြင်းပါ (noise လျှော့ချ, model ကို ပိုမြန်စေဖို့).

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

House data ထဲမှာ 'purchase_date' column ကို တိုက်ရိုက် feature အနေနဲ့ သုံးမယ့်အစား, 'house_age' (current_year - built_year) ဆိုတဲ့ feature အသစ်ကို engineer လုပ်ရင် model ကို ပိုအထောက်အကူ ဖြစ်စေနိုင်ပါတယ် — `pd.get_dummies(df['neighborhood'])` လို့ run ရင် 'neighborhood' categorical column ကို One-Hot Encoding ဖြင့် binary column အများ (neighborhood_A, neighborhood_B, ...) ဆီ ပြောင်းလဲပေးပါတယ်.

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

python
import pandas as pd

# Feature engineering: derive house_age from built_year
df['house_age'] = 2026 - df['built_year']

# One-hot encode a categorical column
df_encoded = pd.get_dummies(df, columns=['neighborhood'])
print(df_encoded.columns.tolist())
You should see
['size', 'built_year', 'price', 'house_age', 'neighborhood_A', 'neighborhood_B', 'neighborhood_C']

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

Sample dataset (categorical column တစ်ခု, date column တစ်ခု ပါတဲ့) ကို ကိုယ်တိုင် create ပြီး, feature engineering (age derive) + One-Hot Encoding ၂ ခုလုံးကို run ကြည့်ပါ။

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

Feature engineering ကို test data leak ဖြစ်စေမယ့်ပုံစံနဲ့ မလုပ်ပါနှင့် (ဥပမာ - dataset တစ်ခုလုံးရဲ့ average ကို feature အနေနဲ့ ဖန်တီးခြင်း, test data ရဲ့ information ကို indirect ပါဝင်သွားနိုင်) — training data ကနေသာ statistic ကို ဆွဲယူပြီး test data ကို apply လုပ်ရပါမယ်.

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

  • One-Hot Encoding ကို category အလွန်များတဲ့ column (ဥပမာ - user ID, ZIP code 10,000+ unique value) မှာ blindly သုံးခြင်း — column အရေအတွက် explosion ဖြစ်ပြီး (curse of dimensionality) model training slow/inefficient ဖြစ်နိုင်ပါတယ်
  • Feature Engineering ကို 'algorithm ရွေးချယ်မှုထက် အရေးမကြီးဘူး' လို့ ရှုပ်ထွေးထင်ခြင်း — real-world practice မှာ feature engineering က model performance ကို algorithm ရွေးချယ်မှုထက် ပိုသက်ရောက်လေ့ရှိပါတယ်

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

Sample dataset (categorical column တစ်ခု, date column တစ်ခု ပါတဲ့) ကို ကိုယ်တိုင် create ပြီး, feature engineering (age derive) + One-Hot Encoding ၂ ခုလုံးကို run ကြည့်ပါ။

You'll know it worked when: ['size', 'built_year', 'price', 'house_age', 'neighborhood_A', 'neighborhood_B', 'neighborhood_C']

Feature Engineering | Thuta Learning