ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
Decision Tree က data ကို question (ဥပမာ - 'age > 30?') series ဖြင့် ခွဲခြားပြီး, leaf node ရောက်တဲ့အထိ decision ချသွားတဲ့ tree structure ပါ — human-readable ဖြစ်လို့ (Linear Regression ရဲ့ coefficient ထက်) 'ဘာကြောင့် ဒီ prediction ချသလဲ' ဆိုတာ ရှင်းရှင်းလင်းလင်း explain လုပ်နိုင်ပါတယ်။ Tree ရဲ့ depth (question layer အရေအတွက်) ကို ကန့်သတ်မထားရင် — training data ကို 'အလွတ်ကျက်' လောက်အောင် deep ဖြစ်သွားနိုင်ပါတယ် (overfitting risk), `max_depth` parameter ဖြင့် ကန့်သတ်ပေးရပါတယ်.
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
`from sklearn.tree import DecisionTreeClassifier; model = DecisionTreeClassifier(max_depth=5); model.fit(X_train, y_train)` လို့ ရေးရင် — tree depth ကို 5 layer ထိသာ ခွင့်ပြုထားလို့ overfitting ကို ကန့်သတ်ပေးပါတယ်, `from sklearn.tree import plot_tree; plot_tree(model)` ကို run ရင် tree structure ကို visual diagram အနေနဲ့ ကြည့်နိုင်ပါတယ် — 'ဘယ် feature ကို ဘယ် threshold မှာ ခွဲခြားလဲ' ဆိုတာ ရှင်းရှင်းလင်းလင်း တွေ့ရမှာပါ.
အတူတူ ကြည့်မယ်
from sklearn.tree import DecisionTreeClassifier, plot_tree
import matplotlib.pyplot as plt
model = DecisionTreeClassifier(max_depth=5, random_state=42)
model.fit(X_train, y_train)
print(f"Accuracy: {model.score(X_test, y_test):.2f}")
# Visualize the tree structure
plot_tree(model, feature_names=X.columns, filled=True)
plt.show()Accuracy: 0.84၅ မိနစ် စမ်းကြည့်
Decision Tree Classifier ကို sample dataset ဖြင့် train ကြည့်ပြီး, `max_depth` ကို 2, 5, None (unlimited) ဆိုပြီး ကွဲပြားစွာ ချကာ accuracy ကို compare ကြည့်ပါ — depth ကြီးလွန်းရင် ဘာဖြစ်လဲ observe လုပ်ကြည့်ပါ။
သတိလေးတစ်ချက်
Decision Tree ရဲ့ interpretability (ရှင်းလင်းပြီး explain လုပ်ရလွယ်ခြင်း) ကို prioritize ရမယ့် use case (ဥပမာ - loan approval, medical decision, regulation-heavy industry) မှာ Decision Tree က black-box algorithm (Neural Network) ထက် ပိုသင့်တော်နိုင်ပါတယ်.