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

सैंपल साइज सीमित करना

ओवरफिटिंग से बचने का एक और तरीका है Decision Tree में किसी पत्ती (या नोड) को बढ़ने के लिए आवश्यक न्यूनतम observations की संख्या तय करना।

इस अभ्यास में, आप:

  • इस न्यूनतम सीमा को 100 पर सेट करेंगे
  • नए मॉडल को employee डेटा पर फिट करेंगे
  • training और test सेट दोनों पर prediction परिणामों का परीक्षण करेंगे

features_train, target_train, features_test और target_test वैरिएबल आपके कार्यक्षेत्र में पहले से उपलब्ध हैं।

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

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

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

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

  • DecisionTreeClassifier को initialize कीजिए और पत्ती के लिए न्यूनतम सीमा 100 observations पर सेट करें
  • decision tree मॉडल को training डेटा पर फिट करें.
  • training और test दोनों सेट पर की गई predictions की accuracy जाँचें.

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

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

# Initialize the DecisionTreeClassifier while limiting the sample size in leaves to 100
model_sample_100 = DecisionTreeClassifier(____, random_state=42)

# Fit the model
____.fit(features_train,____)

# Print the accuracy of the prediction (in percentage points) for the training set
print(____.score(features_train,target_train)*100)

# Print the accuracy of the prediction (in percentage points) for the test set
print(____.____(features_test,target_test)*100)
कोड संपादित करें और चलाएँ