Solved – Model selection: before or after nested cross-validation

cross-validationmodel selection

I want to build a neural network over a data set. My idea is to use cross-validation on a training set to select the "best" neural network (and evaluate it on a separate test set) and to use nested cross-validation to make some statistical predictions. I'd use nested CV to plot bias and variance of my grid search's hyper-parameters. This way I can estimate my method's performance.

If these assumptions are not wrong, what should I do first? Model selection or estimation?

Best Answer

I think you misunderstood something about the nested cross validation: Hyperparameter tuning / model selection is not done before nor after nested cross validation, it is done in the inner loop of the nested cross validation.

Probably related to the misunderstanding: grid hyperparameters in themselves do not cause a bias in generalization error erstimation. The (optimistic) bias is caused by the selection of the (apparently) best hyperparameter set.