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

डिफॉल्ट थ्रेशोल्डिंग

आप यह पक्का करना चाहते हैं कि DecisionTreeClassifier() वही डिफॉल्ट क्लासिफिकेशन थ्रेशोल्ड इस्तेमाल करता है जिसका ज़िक्र पिछली लesson में हुआ था, यानी 0.5. आपको यह अजीब लगता है कि सभी classifiers एक ही थ्रेशोल्ड लें. चलिए जाँचते हैं! आपके लिए एक fitted decision tree classifier clf पहले से लोड किया गया है, और training व test डेटा भी अपने usual नामों के साथ मौजूद है: X_train, X_test, y_train और y_test. आपको classifier से probability scores निकालने होंगे, .predict_proba() मेथड का उपयोग करके.

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

Python में मशीन लर्निंग वर्कफ़्लो डिज़ाइन करना

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

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

  • प्रीलोडेड classifier clf का इस्तेमाल करके test examples के लिए scores निकालें.
  • अब इन scores से labels निकालें. याद रखें कि प्रत्येक example के लिए आपके पास scores की एक जोड़ी होती है, कोई एकल score नहीं, और दूसरा एलिमेंट positive class की probability है.
  • अब standard .predict() मेथड का उपयोग करके test डेटा को label करें.
  • अंत में, पहले मिले predictions से तुलना करें. क्या वे एक समान हैं?

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

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

# Score the test data using the given classifier
scores = clf.____(____)

# Get labels from the scores using the default threshold
preds = [s[____] > ____ for s in scores]

# Use the predict method to label the test data again
preds_default = clf.____(____)

# Compare the two sets of predictions
____(preds == preds_default)
कोड संपादित करें और चलाएँ