GithubHelp home page GithubHelp logo

zie225 / bayesianoptimisation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mattcrooksbbc/bayesianoptimisation

0.0 0.0 1.0 1.16 MB

Code for a Bayesian hyper parameter optimisation algorithm for tuning of ML models

License: MIT License

Jupyter Notebook 96.65% Python 3.35%

bayesianoptimisation's Introduction

BayesianOptimisation

Code for a Bayesian hyper parameter optimisation algorithm for tuning of ML models

Overview

The method starts with a few randomly selected hyperparameter values to get started and trains the ML model on these values. It then trains a Gaussian process over these points in order to predict the accuracy/score metric. The Bayesian optimisation part begins at this point. Using expected improvement as the acquisition function, the algorithm selects new values of the hyperparameters to try based on the probability of the accuracy being higher at those points than the current maximum. This calculation is based off the Gaussian process and takes into account both the mean and uncertainty that the Gaussian process predicts at each point. After each new set of hyperparameters is chosen, the ML model is retrained on these values and the Gaussian process retrained on all sampled points so far including the new values. The process then repeats.

Hyperparameter definition

These are specified as a dictionary. The key of the dictionary should correspond to the name of the hyperparameter that is passed into the MLmodel such as "n_estimators" or "min_weight_fraction_leaf" in the case of an sklearn random forest. The values determine either the range, in the case of continuous hyperparameters, or a list of all values to be tested, in the case of a discrete hyperparameter. Providing a list of length 2 will be automatically interpreted as a continuous hyperparameter and should be of the form [lower_bound, upper_bound]. Discrete hyperparameter values can be provided in any order but much contain at least 3 elements otherwise it will be interpreted as continuous. For discrete hyperparameters with just 2 values, you should simply run the optimisation over the other hyperparameters twice with the 2-valued hyperparameter value hardcoded in each case.

Continuous vs discrete hyperparameters

The algorithm can now deal with both continuous and discrete valued hyperparameters. This is applicable to the optimization method used to find the maximum in the acquisition function. The default is the constrained optimiser scipy.optimize.minimize (we add a minus sign to the acquisition function so that it solves for th maximum) but this can only cope with continuous variables. If any of the hyperparameters are discrete the you should set optim_rout = 'random_search'. This applies random search to the discrete hyperparameters and for each random choice then applies scipy.optimize.minimize to the remaining continuous hyperparameters. NOTE: by random search we are referring to the method of optimising the acquisition function, the overall algorithm for finding the optimal hyperparameters is still Bayesian!

bayesianoptimisation's People

Contributors

mattcrooksbbc avatar

Forkers

hamed225

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.