Session Ready
Exercise

Using KFold indices

You have already created splits, which contains indices for the candy-data dataset to complete 5-fold cross-validation. To get a better estimate for how well a colleague's random forest model will perform on a new data, you want to run this model on the five different training and validation indices you just created.

In this exercise, you will use these indices to check the accuracy of this model using the five different splits. A for loop has been provided to assist with this process.

Instructions
100 XP
  • Use train_index and val_index to call the correct indices of X and y when creating training and validation data.
  • Fit rfc using the training dataset
  • Use rfc to create predictions for validation dataset and print the validation accuracy