Finding the optimal hyperparameters through a grid search