0
$\begingroup$

I've trained my artificial neural network, and, as per standard practice, I've picked out the one neural network throughout training that did the best on my validation dataset. That is, the neural network learned from the training data, and generalized to the validation data.

However, when I run the neural network on the test data, it performs poorly. What should I do next?

From my understanding of the theoretical framework, the goal of validation is to ensure that that the network's parameters don't overfit to the training set. (If they do, we'll detect it because the validation score will be bad.) However, the goal of an additional test dataset set beyond the validation dataset is to ensure that our hyperparameters don't overfit. In most scenarios, we train multiple models with different learning rates, etc., and pick the one that does the best on the validation dataset. However, we might just be cherry picking the one that does the best for that validation dataset and doesn't generalize to a test set. So, we add an extra test set to detect if that happens.

My question is about an analogous case, except for that my hyperparameter is just the training step of the model. I picked out the model that's checkpointed as having the highest validation score. But, when I run it on the test set, it does poorly, showing that I've cherry picked the model with the highest validation score but it still doesn't generalize.

What do I do next in this scenario? Do I just follow the same advice from these questions about overfitting, or is this a special case because the model does seem to generalize to the validation dataset?

(Note: this question is different than regular overfitting because it's about hyperparameters overfitting the validation set, not regular parameters overfitting the train set. I've also looked at these guidelines but they don't seem to apply to this more general theoretical question.)

$\endgroup$

2 Answers 2

2
$\begingroup$

When splitting a dataset into a train, validation & test-set you make an important assumption on the data you have. This is called the i.i.d assumption. You assume that all observations are:

  1. sampled independently
  2. identically distributed

Let's explore further:

Independence assumption:
There should be no known correlations between samples in train and test set. If there are known correlations in the subsets, then account for this! An example of this could be: a model that predicts the job-satisfaction for Twitterusers (so per user a prediction). If a user has tweets present in all subsets, then there is a 'information leakage', so the test-score will be significantly higher (but unreliable).

Identically Distributed assumption:
Your train, validation & test set should be identically distributed, so all samples should come from the same distribution. If this is not the case, then your model will not generalise well to your test set. In your case, I believe your train & validation set to be identically distributed, but your test set is not. Another example: Let's say we train a model that wants to predict how many people take their bike to work on a given weekday (so the only feature of this model is: the day of the week). If our train set only contains data from the summer and our test set only contains data from the winter, then the model will probably not generalise well to the test data. During the winter people would be less likely to take their bike to work than during the summer, so the underlying distributions are not the same. To have a better performance you could for example:

  • Add data, which is not always possible (e.g. a dummy variable 'season')
  • Change the split

Changing the split
Note that if the actual problem is that your test data does not come from the same distribution as 'real, unseen data' (but your train & validation data do), then doing this might make your model less powerful to generalise to unseen data then it is right now.

So in your case, it could be a violation of the identically distributed assumption. It could be useful to elaborate further on the nature of the data you are using. I believe this might help you to get a clear answer.

$\endgroup$
1
$\begingroup$

Check if the CV and test are Temporaly stable or they change with time. Additionally check if they both follow the same distribution or not

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .