Scikit hyperparameter optimizationScikit shines when it comes to hyperparameter optimization. Here the algorithm parameters are referred to as hyperparameters whereas the coefficients found by the machine learning algorithm itself are referred to as parameters. There are mainly two search strategies; systematic and stochastic. The systematic one tries all combinations within some given intervals while the random search, well, randomly searches for the optimized value.

 

Systematic search

Grid search is an approach to parameter tuning that will systematically build and evaluate a model for each combination of algorithm parameters specified in a grid.

The recipe below evaluates different alpha values for the Ridge Regression algorithm on the standard diabetes dataset. This is a one-dimensional grid search, you can have arbitrary dimensions;

For more information see the API for GridSearchCV and Exhaustive Grid Search section in the user guide.

Random search

Random search is an approach to parameter tuning that will sample algorithm parameters from a random distribution (i.e. uniform) for a fixed number of iterations. A model is constructed and evaluated for each combination of parameters chosen.

The recipe below evaluates different alpha random values between 0 and 1 for the Ridge Regression algorithm on the standard diabetes dataset.

For more information see the API for RandomizedSearchCV and the the Randomized Parameter Optimization section in the user guide. The user manual also gives very comprehensive info on how to specify the various hyperparameters of the tuning procedure.