In this question, the OP asked about a situation that he/she combined training and test datasets into an agumented dataset and then tuned the hyperparameters for best accuracy and then use the training dataset only to train the final model and check its accuracy on test dataset. My situation is somewhat similar to this question but the difference is that I DID NOT combine training and test datasets to form a agumented dataset. Furthermore, my training and test datasets are completely independent and more importantly test dataset is not subset of training dataset. In fact, my test dataset is given by another research group for the same phenomenon as my training dataset. In my situation I used only the training dataset to train the model for each set of the hyperparameters and then measure the accuracy on test dataset. My objective is oriented towards searching the hyperparameters space to have the highest accuracy on test dataset in each iteration of my search. So, to be precise, my model during hyperparameters tuning did not use test dataset for training task, but I stopped the searching of hyperparameters space, when I achieved the highest accuracy on test dataset. So, my question is: Am I overfitting because my final objective is to have the best generalization accuracy? or Do I have some sort of data leakage because of my hyperparameters searching objective is defined based on having the highest generalization accuracy? Any suggestion or thought is appreciated. Here, I created a pseudo-code to introduce my purpose more easily:
DEFINE HYPERPARAMETERS RANGE
DO HYPERPARAMETER TUNING:
FOR EACH HYPERPARAMETERS IN DEFINED RANGE:
TRAIN THE CLASSIFIER BY USING ONLY THE TRAINING DATASET
APPLY THE TRAINED MODEL ON TEST DATASET AND MEASURE THE ACCURACY
STOP THE SEARCHING IF YOU ACHIEVED THE HIGHEST ACCURACY FOR TEST DATASET