I'm reading an article about building a Random Forests algorithm which can predict which patients will respond to Immunotherapy (therapy named ICB) , based on collected data from the patients.

The scientists who conducted this research stratified the data randomly into 80% training set and 20% test set, and then they used 5-Fold cross validation on the training set.

I'll quote from the article so that it would be completely clear: "A random forest model was trained on multiple genomic, molecular, demographic and clinical features on the training data using five-fold cross-validation to predict ICB response, The resulting trained model with the best hyperparameters was evaluated using various performance metrics using the test set".

I'm very confused of how and why would they do the cross validation method over the training data and not the whole data ? how is it helpful for a random forest model ?

I really tried searching for an answer before coming here but found no helpful explanation. Thank you.


1 Answer 1


The training set is used to select the best predictive model using cross validation. The test set is used to assess the performance of the best model selected from the training set. You need a data set which is not used in training the model so that you can see how a model will perform in predicting future values. That's why a test set is needed.

  • $\begingroup$ I get it, but they could have trained the model on the training set in order to get the best predictive model, without using cross validation. In the classic case that I know, cross validation is used so that all the data is used as training and all the data is used as test after running it K times, then we take the average of the recorded scores. I don't get how this implies here. $\endgroup$
    – Loui
    Commented Dec 22, 2021 at 14:05
  • $\begingroup$ Actually you can just train the model on the training set without cross validation, but that would give you one measure of predictive performance. Different data sets may lead to different measures of predictability, so cross validation provides a way to utilize data to obtain more measures of predictability whose average may give us a better understanding of different predictive models. In this sense, cross validation should be used. $\endgroup$ Commented Dec 22, 2021 at 14:11
  • $\begingroup$ Thank you so much my friend. $\endgroup$
    – Loui
    Commented Dec 22, 2021 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.