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

सबसे बेहतर मॉडल विकसित करें और टेस्ट करें

Chapter 3 में, आपने पाया कि निम्न पैरामीटर बेहतर मॉडल देते हैं:

  • max_depth = 8,
  • min_samples_leaf = 150,
  • class_weight = "balanced"

इस chapter में, आपने देखा कि कुछ फीचर का प्रभाव बहुत कम है। आपको महसूस हुआ कि चुने हुए, प्रभावशाली कुछ फीचर के छोटे सेट से भी सटीक प्रेडिक्शन मिल सकते हैं, और आपने उसी अनुसार training और testing सेट अपडेट करके features_train_selected और features_test_selected वैरिएबल बनाए।

अब इन सारी जानकारियों के साथ, आप employee turnover की भविष्यवाणी के लिए सबसे बेहतर मॉडल विकसित करेंगे और उसे उपयुक्त मेट्रिक्स से evaluate करेंगे।

आपके workspace में features_train_selected और features_test_selected वैरिएबल उपलब्ध हैं, और recall_score तथा roc_auc_score फंक्शन आपके लिए इम्पोर्ट किए जा चुके हैं.

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

HR Analytics: Python में कर्मचारी churn की भविष्यवाणी

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

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

  • विवरण में दिए गए पैरामीटर के साथ best मॉडल initialize करें.
  • केवल training सेट के चुने हुए फीचर से मॉडल fit करें.
  • test सेट के चुने हुए फीचर के आधार पर प्रेडिक्शन करें.
  • मॉडल की accuracy, recall और ROC/AUC स्कोर प्रिंट करें.

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

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

# Initialize the best model using parameters provided in description
model_best = DecisionTreeClassifier(____=____, ____=____, ____=____, random_state=42)

# Fit the model using only selected features from training set: done
model_best.fit(____, target_train)

# Make prediction based on selected list of features from test set
prediction_best = model_best.____(____)

# Print the general accuracy of the model_best
print(____.score(features_test_selected, target_test) * 100)

# Print the recall score of the model predictions
print(____(target_test, prediction_best) * 100)

# Print the ROC/AUC score of the model predictions
print(roc_auc_score(target_test, ____) * 100)
कोड संपादित करें और चलाएँ