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

mlxtend के साथ पहला प्रयास

अब mlxtend के साथ काम शुरू करने का समय है! आप ऐप रेटिंग्स डेटासेट का ही उपयोग जारी रखेंगे। आपने scikit-learn की मदद से पहले ही एक स्टैक्ड एन्सेम्बल मॉडल बनाया है, इसलिए अब mlxtend से बनाए गए मॉडल की तुलना करने के लिए आपके पास एक आधार मौजूद है.

डेटासेट लोड किया जा चुका है और apps के रूप में उपलब्ध है.

आइए देखें कि क्या mlxtend scikit-learn एन्सेम्बल क्लासिफायर जितना अच्छा या उससे बेहतर मॉडल बना सकता है.

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

Python में Ensemble Methods

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

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

  • min_samples_leaf = 3 और min_samples_split = 9 के साथ एक decision tree classifier बनाएँ.
  • 'ball_tree' एल्गोरिदम का उपयोग करते हुए एक 5-nearest neighbors classifier इंस्टैंशिएट करें.
  • एक StackingClassifier बनाएँ, जिसमें पास करें: क्लासिफायर्स की लिस्ट, मेटा क्लासिफायर, use_probas=True (probabilities उपयोग करने के लिए), और use_features_in_secondary = False (ताकि केवल individual predictions का उपयोग हो).
  • accuracy score निकालकर परफॉर्मेंस का आकलन करें.

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

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

# Instantiate the first-layer classifiers
clf_dt = ____(____, ____, random_state=500)
clf_knn = ____

# Instantiate the second-layer meta classifier
clf_meta = LogisticRegression()

# Build the Stacking classifier
clf_stack = ____
clf_stack.____

# Evaluate the performance of the Stacking classifier
pred_stack = ____
print("Accuracy: {:0.4f}".format(accuracy_score(y_test, pred_stack)))
कोड संपादित करें और चलाएँ