शुरू करेंमुफ़्त में शुरू करें

Decision tree के rules को समझें

इस अभ्यास में आप decision tree से if-else rules निकालेंगे और उन्हें plot करेंगे ताकि churn के मुख्य drivers की पहचान कर सकें.

Fitted decision tree इंस्टेंस mytree के रूप में लोड है और scaled features train_X नाम की pandas DataFrame में उपलब्ध हैं. sklearn लाइब्रेरी के tree मॉड्यूल और graphviz लाइब्रेरी पहले से आपके लिए लोड किए गए हैं.

ध्यान दें कि आउटपुट देखना आसान बनाने के लिए हमने display(graph) के बजाय एक proprietary display_image() फंक्शन का इस्तेमाल किया है.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में मार्केटिंग के लिए मशीन लर्निंग

पाठ्यक्रम देखें

अभ्यास निर्देश

  • Trained decision tree से graphviz ऑब्जेक्ट एक्सपोर्ट करें.
  • Feature names असाइन करें.
  • Precision को 1 पर सेट करें और class names जोड़ें.
  • graphviz का Source() फंक्शन कॉल करें और एक्सपोर्ट किया गया graphviz ऑब्जेक्ट पास करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Export graphviz object from the trained decision tree 
exported = tree.___(decision_tree=mytree, 
			# Assign feature names
            out_file=None, ___=train_X.columns, 
			# Set precision to 1 and add class names
			precision=1, ___=['Not churn','Churn'], filled = True)

# Call the Source function and pass the exported graphviz object
graph = graphviz.___(exported)

# Display the decision tree
display_image("/usr/local/share/datasets/decision_tree_rules.png")
कोड संपादित करें और चलाएँ