Article Thumbnail

Hyperparameter Tuning (Virtual Recognition)

Examine the impact of hyperparameter tuning on a machine learning model

Florian Dahlitz
1 min
Sept. 10, 2019
Table of Contents

Overview

The question for this project was how hyperparameter tuning can influence the overall accuracy of a machine learning model. As an example a machine learning model was trained, which is able to classify four types of ships:

  • Container Ship
  • Cruiser
  • Frigate
  • Sailing Ship

Approach

After the base training of the model, the model needs to be retrained with each possible hyperparameter combination using the transfer learning approach. This can be done using a grid search. The scikit-learn library provides a grid search out of the box (sklearn.model_selection.GridSearchCV). However, the grid search class provided by scikit-learn is not compatible with the ImageGenerator class of Keras (at least not at the time of this project). Therefore, the grid search had to be implemented on its own. This can be achieved in three steps:

  1. Define the hyperparameters and their corresponding values
  2. Compute all possible combinations
  3. Transfer learning with each combination

After training the model with all possible hyperparameter combinations in the given ranges an evaluation needs to be done, where the results of all combinations need to be compared.

Conclusion

Hyperparameter tuning can have a significant influence on the accuracy of a machine learning model. Especially in branches, were each percentage point of accuracy is important.