BaşlayınÜcretsiz Başlayın

The test-train split

In a disciplined machine learning workflow it is crucial to withhold a portion of your data (testing data) from any decision-making process. This allows you to independently assess the performance of your model when it is finalized. The remaining data, the training data, is used to build and select the best model.

In this exercise, you will use the rsample package to split your data to perform the initial train-test split of your gapminder data.

Note: Since this is a random split of the data it is good practice to set a seed before splitting it.

Bu egzersiz

Machine Learning in the Tidyverse

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Split your data into 75% training and 25% testing using the initial_split() function and assign it to gap_split.
  • Extract the training data frame from gap_split using the training() function.
  • Extract the testing data frame from gap_split using the testing() function.
  • Ensure that the dimensions of your new data frames are what you expected by using the dim() function on training_data and testing_data.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

set.seed(42)

# Prepare the initial split object
gap_split <- initial_split(___, prop = ___)

# Extract the training data frame
training_data <- ___

# Extract the testing data frame
testing_data <- ___

# Calculate the dimensions of both training_data and testing_data
dim(___)
dim(___)
Kodu Düzenle ve Çalıştır