Andreas Bollig
4y ago
I write about freelancing, solopreneurship, web dev and data science.
You'll learn about the three main strategies for automated hyperparameter tuning and how to choose between them.
One way to improve the performance of a machine learning model is to tune its hyperparameters. Of course, you can do this manually, but as you might have painfully experienced, that can be a very time and resource-consuming exercise. Automate it to get results faster and have the freedom to spend your time on less boring things.
The three main strategies are grid search, random search, and Bayesian optimization. For all three, you define a search space (parameters and their possible values) and let the algorithm find the optimal parameter set by itself. Below I'll briefly describe them and give you their pros and cons, so you know when to choose which.
Grid Search
This approach tries every possible combination of values for your parameters and picks the one with the best performance. For continuous value parameters, it picks values at regular intervals (that's where the word "grid" comes from). With a sufficiently fine-grained grid, this is guaranteed to find the best parameter set. However, as you can imagine, the number of possible parameter value combinations is huge. This means that the grid search will run for a long time and be expensive.
Random Search
As the name suggests, this method tries one random parameter value combination after the other. It will do this for as long as you let it. After you stop it, you can collect the combination with the best performance. This might sound ludicrous, but if you let it run long enough, the chance that it hasn't tried a combination that is close to the optimum is low. It is a good way to find "good enough" parameters quickly, but will very slowly converge to the true optimum.
Bayesian Optimization
The idea here is to iteratively model the relationship between the parameter values and the performance. At each step, the algorithm balances "exploration" (looking at parts of the parameter space that haven't been covered, yet) and "exploitation" (moving towards the direction, where the model expects to find the optimum) to converge to the optimum as quickly as possible. Note, that you need to do a fair number of iterations before it produces any meaningful parameter sets. Also, it can get stuck in local optima.