35. Decision Trees आणि Random Forests — Python मध्ये
35.1 Decision Tree मधून वाचता येणारे Rules
का गरजेचे आहे. Managers वाचता येणारे rules आवडतात: “if complaints ≥ 2 and orders_last_30d < 3 → high churn risk.” Trees ही भाषा बोलतात.
हे काय आहे. Decision tree features वर yes/no प्रश्न विचारते आणि leaf prediction (class किंवा number) वर थांबते. Rules print करता येतात — शिकवताना coefs च्या ढिगाऱ्यापेक्षा सोपी.
कसे करायचे.
if/else मध्ये विचार करा
- वरून सुरू करा (root).
- Row ला जुळणारी शाखा फॉलो करा.
- Leaf वर थांबा — तेच prediction.
# Story tree (not fitted yet)
# if complaints >= 2:
# predict churn = 1
# else:
# if orders_last_30d < 3: predict 1
# else: predict 0
print("Trees = stacked if/else on features.")
Ravindra Bagale's Tip
A very deep tree can memorise the training data instead of learning general rules. This problem is called overfitting, and you will study it in Chapter 38. So learn how to control the depth of a tree, for example with the max_depth setting.
Ravindra Bagale's Tip – मराठी
खूप खोल tree सामान्य rules शिकण्याऐवजी training data पाठ करून टाकू शकते. या problem ला overfitting म्हणतात, आणि तो तुम्ही Chapter 38 मध्ये शिकाल. म्हणून tree ची depth control कशी करायची ते शिका, उदाहरणार्थ max_depth setting वापरून.
Ravindra Bagale's Tip – हिंदी
बहुत गहरा tree सामान्य rules सीखने के बजाय training data रट लेता है. इस problem को overfitting कहते हैं, और इसे आप Chapter 38 में पढ़ेंगे. इसलिए tree की depth को control करना सीखो, जैसे max_depth setting से.