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

सबसे अच्छा मॉडल बनाएँ और मूल्यांकन करें

Cross-validation का उपयोग करके आपने gapminder में मौजूद सभी फीचर्स से life_expectancy की भविष्यवाणी करने के लिए सबसे अच्छा मॉडल पहचाना। अब जब आपने अपना मॉडल चुन लिया है, तो आप अलग रखे गए स्वतंत्र डेटा सेट (testing_data) का उपयोग करके इस मॉडल का नए डेटा पर प्रदर्शन अनुमानित कर सकते हैं।

आप यह मॉडल पूरे training_data पर बनाएँगे और testing_data का उपयोग करके इसका मूल्यांकन करेंगे।

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

Tidyverse में मशीन लर्निंग

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

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

  • ranger() का उपयोग करके सभी training डेटा पर सबसे अच्छा प्रदर्शन करने वाला मॉडल (mtry = 4) बनाएँ। इसे best_model को असाइन करें।
  • testing_data से life_expectancy कॉलम निकालकर test_actual को असाइन करें।
  • best_model का उपयोग करके testing डेटा पर life_expectancy की भविष्यवाणी करें और इसे test_predicted को असाइन करें।
  • test_actual और test_predicted वेक्टर का उपयोग करके MAE की गणना करें।

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

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

# Build the model using all training data and the best performing parameter
best_model <- ranger(formula = ___, data = ___,
                     mtry = ___, num.trees = 100, seed = 42)

# Prepare the test_actual vector
test_actual <- testing_data$___

# Predict life_expectancy for the testing_data
test_predicted <- predict(___, ___)$predictions

# Calculate the test MAE
mae(___, ___)
कोड संपादित करें और चलाएँ