3
$\begingroup$

I didn't find any similar question so I just post the question here.

Suppose after training and validation, the model performs poorly on the test set. Then what we do is to consider another model (Is it true? correct me if I'm wrong). When it still performs poor on the test set after training and validation, we head to another model. If we continue this process, does it result in overfitting on the test set in terms of model selection?

Thanks.

$\endgroup$
2
$\begingroup$

Yes this will result in overfitting to the train + "test" set.

  • Data-driven model selection is part of the training process: any kind of data used in order to obtain the final model is involved in training.

  • The fact that you select the model manually (instead of letting an optimization routing select a model) does not change this.

You'll find lots of questions and answers about this under the topics of (data-driven) model optimization and model selection.

$\endgroup$
2
$\begingroup$

Yes, if you will repeat this process multiple times you will overfit the test set. It happens in many Kaggel competitions when the group submit their results multiple times and try to tweak their models to produce better results on the public test set. Then when the competition ends and the private test set scores are calculated, their score drops dramatically. This is because their model overfits the public test set and can't generalize to new datasets.

A better approach is first split to train and test. Then derive your conclusion as much as you can on the train set. Means:

  1. Perform nested-cross validation on the train set to hypertune parameters and to evaluate your models (inner loop - hyperparameter tunning, outer loop - model selection). Notice that the same model with different hyperparameters is considered as two different models for the model selection phase.

  2. For the 1-3 best models: Analyze the difference in the results between the inner loop to the outer loop. Treat the outer loop scores as the test scores and the inner loop as the validation score.

*If the mean error of the inner loop is not satisfactory for you (compare it to the state-of-the-art or to human level), you have a bias problem. You'll want to build a more complex model (more trees, more layers in NN, train NN longer), feature engineering, feature selection.

*If the error std of the outer loop is high, or the mean error of the outer loop is higher than the inner loop means you have a variance problem. Your model is not stable and you may overfit to noise. You'll want to build a simpler model (i.e fewer trees in RF, simpler NN), add more data, regularization, check if splits are representative enough, etc.

  1. Fix these issues and do these steps again and again until you are satisfied with the results. Only then, when you think there is nothing else to do, fit the model over all the train data and predict on the test data.
  2. Now, if you are not pleased with the results, you should do error analysis, understand what is missing in your model (more\less features, more\less complexity) and you are back to the drawing board. Start this all process all over again. The best scenario will have a new test set in this case. I know it's not always available, that's why you should invest most of your time in the nested CV results analysis and improvements and delay predicting on the test set as much as you can.
$\endgroup$
-4
$\begingroup$

It will not result in the over-fitting of the test set as the test set has not been used in training the model.

$\endgroup$
4
  • 2
    $\begingroup$ This is incorrect. Using the test set to select between competing candidate models is, in effect, using it to train the model. $\endgroup$ Apr 22 '16 at 4:59
  • $\begingroup$ @Mathew Drury, I answered the question under a different context. It should have been a comment but I cannot add comments as I do not have the required number of points. Perhaps you can elaborate your answer a bit. Having two different data sets for training and testing negates your comment above. $\endgroup$
    – user111093
    Apr 22 '16 at 6:54
  • $\begingroup$ @user111093 Do you mean using different testing/validation/training sets for different models instead of the same sets for different models? I appreciate if you can also give the link to your mentioned comment. $\endgroup$
    – ZhuShY
    Apr 23 '16 at 17:31
  • $\begingroup$ @SZhu I meant partitioning the data set into training and test sets and not two different data sets. HTH. $\endgroup$
    – user111093
    Apr 24 '16 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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