35. Decision Trees and Random Forests in Python
35.5 Practice, Tip and Close
Why. Close when you can explain tree vs forest and fit both on a tiny table.
How.
Chapter practice
- Build a 16-row fictional “refund risk” table for Amazon Now-style orders (distance_km, price_inr, is_fragile).
- Fit DecisionTreeClassifier(max_depth=2) and print export_text.
- Fit RandomForestClassifier(n_estimators=30) and print feature_importances_.
- Write two lines: when you would show the tree to a store manager, and when you would ship the forest.
Thodkyaat sangaycha tar (quick recap)
- Tree = readable if/else rules
- Forest = many trees voting — usually stronger
- Control depth / n_estimators on small laptops
- Still use train/test split
Samajla ka? Next: Chapter 36 — K-Means Clustering (groups without labels).