On Hyperparameter Tuning on the Test Set
Abstract
"Don't tune hyperparameters on the test set" is often stated in machine learning textbooks.
Violating it is considered a cardinal sin that produces misleadingly optimistic results, corrupts benchmark integrity, and thus can even be interpreted as scientific fraud.
Yet evidence suggests that test set hyperparameter tuning does occur in practice, making it all the more important to understand its actual consequences.
So how bad is it, really?
In this work we question this dogma and put it to an empirical test.
We systematically study the magnitude of the performance inflation caused by tuning the hyperparameters on the test set for MNIST-1D, CIFAR-10, and three tasks from the GLUE benchmark.
Our experiments show that while the effect is real and significant, it is frequently small relative to other sources of noise.
In many cases, we find that tuning all models on the test set recovers exactly the same model as when tuning all models on the validation set.
Most importantly, we find that the rankings of models remain essentially preserved after tuning on the test set and therefore that consistent test-set tuning may not invalidate benchmarks or model selection.
Our results call for a more nuanced view of tuning hyperparameters on the test set.
We do not aim to normalize test-tuning because it adds a clear bias, but we do hope that our results stimulate researchers to openly report that they do test tuning if it does occur.