ComeçarComece de graça

Build & evaluate the best model

Using cross-validation you were able to identify the best model for predicting life_expectancy using all the features in gapminder. Now that you've selected your model, you can use the independent set of data (testing_data) that you've held out to estimate the performance of this model on new data.

You will build this model using all training_data and evaluate using testing_data.

Este exercício faz parte do curso

Machine Learning in the Tidyverse

Ver curso

Instruções do exercício

  • Use ranger() to build the best performing model (mtry = 4) using all of the training data. Assign this to best_model.
  • Extract the life_expectancy column from testing_data and assign it to test_actual.
  • Predict life_expectancy using the best_model on the testing data and assign it to test_predicted.
  • Calculate the MAE using test_actual and test_predicted vectors.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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(___, ___)
Editar e executar o código