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

Decision tree मॉडल fit करें

अब आप telecom डेटासेट के training सेट पर एक decision tree fit करेंगे, फिर अनदेखे testing डेटा पर लेबल्स predict करेंगे, और अपने मॉडल की predictions की accuracy निकालेंगे. आप इसकी performance की तुलना logistic regression से कर पाएँगे.

accuracy_score फंक्शन इम्पोर्ट किया जा चुका है. साथ ही, आपने पहले जो training और testing डेटासेट बनाए थे, वे features के लिए train_X और test_X, और target वैरिएबल्स के लिए train_Y और test_Y के रूप में लोड हैं.

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

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

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

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

  • एक decision tree classifier initialize करें.
  • training डेटा पर decision tree को fit करें.
  • testing डेटा पर churn लेबल्स predict करें.
  • testing डेटा पर accuracy score निकालकर प्रिंट करें.

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

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

# Initialize decision tree classifier
mytree = tree.___()

# Fit the decision tree on training data
mytree.___(___, ___)

# Predict churn labels on testing data
pred_test_Y = ___.___(___)

# Calculate accuracy score on testing data
test_accuracy = ___(___, ___)

# Print test accuracy
print('Test accuracy:', round(___, 4))
कोड संपादित करें और चलाएँ