Nested cross validation using random forests I would like to tune the hyperparameters of a random forest and then obtain an unbiased score of its performance. 
As I understand, the natural way would be to use nested cross validation. However, it seems to me that with this method the best hyperparameters found in each inner loop might differ across loops, which then creates a problem when you want to report the hyperparameter settings for which the average score was obtained. Ideally, I would like to first settle on a hyperparameter setting, then get an error measure specific to that setting.
I came up with the following procedure:


*

*Separate the dataset into a validation and a train+test set. 

*Perform a grid search using cross validation on the validation set to find optimal hyperparameterst.

*Fit the random forest with the optimal hyperparameters on the train+test set, and report the out-of-bag error.


Point 3. rests on the fact that cross validation is essentially not needed with random forests, as the out-of-bag error is unbiased.
I would like to make sure that this is a sound approach, or whether perhaps there is a more natural way of doing this. 
 A: I think you got it quite right but not exactly. Here my suggestion:


*

*Separate the dataset into a test and a train+validation set.

*Perform a grid search using cross validation on the train set to find optimal hyperparameters optimized on the validation set (for random forest, this would be defining your mtry).

*Use the entire train+validation with the optimal hyperparameters and report the error using the test set.


Only this way, you ensure that the performance is measured on a part of the data the model has never seen. I recommend splitting Nr. 1 a few times, for example with the 10-fold CV, to make the performance measure less prone to variance.
The mlr package has good explanations on this nested cross-validation https://mlr-org.github.io/mlr-tutorial/devel/html/nested_resampling/index.html
A: You use nested cross-validation just to get an unbiased performance measure and use that choose an algorithm among a set of algorithms. After choosing an algorithm, you use the whole dataset with k-fold cv to tune your hyper-parameters specific to that algorithm. You use this final model to apply on data that you have never seen before. So, for performance measure -> neseted cv, for the final hyper-parameter tuning -> k-fold cv
