Code Monkey home page Code Monkey logo

paramopt's Introduction

ParamOpt

Python Library for Easy Bayesian Optimization.

Install

pip install git+https://github.com/blue-no/paramopt.git

Demo - 2D Exploration

from pathlib import Path
from paramopt import UCB, BayesianOptimizer
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import RBF, ConstantKernel as C


folder = Path('demo_2d')
folder.mkdir(exist_ok=True)

def obj_func(X):
    return -(X[0]-5)**2-(X[1]-50)**2/50

optimizer = BayesianOptimizer(
    regressor=GaussianProcessRegressor(
        kernel=C()*RBF(length_scale_bounds='fixed'),
        normalize_y=True),
    exp_space=[('Distance', 'mm', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
               ('Temperature', '°C', [0, 20, 40, 50, 60, 80, 100])],
    eval_name='Quality',
    acq_func=UCB(c=2.0),
    obj_func=obj_func,
    normalize_X=True)

next_params = optimizer.suggest()
for i in range(10):
    y = obj_func(next_params)
    optimizer.update(X=next_params, y=y, label=i)
    optimizer.save_history(folder.joinpath('history.csv'))
    next_params = optimizer.suggest()
    optimizer.plot_distribution(save_as=folder.joinpath(f'dist-{i}.png'))
    optimizer.plot_transition(save_as=folder.joinpath(f'trans-{i}.png'))

Result:

Author: Kota AONO
License: MIT License

paramopt's People

Contributors

blue-no avatar

Watchers

 avatar

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.