All Projects β†’ vthorey β†’ benderopt

vthorey / benderopt

Licence: MIT license
Black-box optimization library

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to benderopt

Auto Sklearn
Automated Machine Learning with scikit-learn
Stars: ✭ 5,916 (+6942.86%)
Mutual labels:  automl, hyperparameter-search
Auto-Surprise
An AutoRecSys library for Surprise. Automate algorithm selection and hyperparameter tuning πŸš€
Stars: ✭ 19 (-77.38%)
Mutual labels:  automl, hyperparameter-search
maggy
Distribution transparent Machine Learning experiments on Apache Spark
Stars: ✭ 83 (-1.19%)
Mutual labels:  automl, hyperparameter-search
Ray
An open source framework that provides a simple, universal API for building distributed applications. Ray is packaged with RLlib, a scalable reinforcement learning library, and Tune, a scalable hyperparameter tuning library.
Stars: ✭ 18,547 (+21979.76%)
Mutual labels:  automl, hyperparameter-search
Python-MLOps-Cookbook
This is an example of a Containerized Flask Application that can deploy to many target environments including: AWS, GCP and Azure.
Stars: ✭ 269 (+220.24%)
Mutual labels:  mlops
serving-pytorch-models
Serving PyTorch models with TorchServe πŸ”₯
Stars: ✭ 91 (+8.33%)
Mutual labels:  mlops
monai-deploy
MONAI Deploy aims to become the de-facto standard for developing, packaging, testing, deploying and running medical AI applications in clinical production.
Stars: ✭ 56 (-33.33%)
Mutual labels:  mlops
mlops-case-study
MLOps Case Study
Stars: ✭ 23 (-72.62%)
Mutual labels:  mlops
mlreef
The collaboration workspace for Machine Learning
Stars: ✭ 1,409 (+1577.38%)
Mutual labels:  mlops
actions-ml-cicd
A Collection of GitHub Actions That Facilitate MLOps
Stars: ✭ 181 (+115.48%)
Mutual labels:  mlops
featuretoolsOnSpark
A simplified version of featuretools for Spark
Stars: ✭ 24 (-71.43%)
Mutual labels:  automl
sdsj-automl
Sberbank Data Science Jorney Auto-ML competition
Stars: ✭ 28 (-66.67%)
Mutual labels:  automl
great expectations action
A GitHub Action that makes it easy to use Great Expectations to validate your data pipelines in your CI workflows.
Stars: ✭ 66 (-21.43%)
Mutual labels:  mlops
qaboard
Algorithm engineering is hard enough: don't spend your time with logistics. QA-Board organizes your runs and lets you visualize, compare and share results.
Stars: ✭ 48 (-42.86%)
Mutual labels:  mlops
neptune-client
πŸ“’ Experiment tracking tool and model registry
Stars: ✭ 348 (+314.29%)
Mutual labels:  mlops
AutoTS
Automated Time Series Forecasting
Stars: ✭ 665 (+691.67%)
Mutual labels:  automl
EvolutionaryForest
An open source python library for automated feature engineering based on Genetic Programming
Stars: ✭ 56 (-33.33%)
Mutual labels:  automl
cli
Polyaxon Core Client & CLI to streamline MLOps
Stars: ✭ 18 (-78.57%)
Mutual labels:  mlops
chitra
A multi-functional library for full-stack Deep Learning. Simplifies Model Building, API development, and Model Deployment.
Stars: ✭ 210 (+150%)
Mutual labels:  mlops
HyperKeras
An AutoDL tool for Neural Architecture Search and Hyperparameter Optimization on Tensorflow and Keras
Stars: ✭ 29 (-65.48%)
Mutual labels:  automl

benderopt

benderopt is a black box optimization library.

For asynchronous use, a web client using this library is available in open access at bender.dreem.com

The algorithm implemented "parzen_estimator" is similar to TPE described in: Bergstra, James S., et al. β€œAlgorithms for hyper-parameter optimization.” Advances in Neural Information Processing Systems.

Installation

pip install benderopt

or from the sources

Demo

Here is a comparison on 200 evaluations of a function we want to minimize. First a random estimator is used to select random evaluation point. Then the parzen_estimator implemented in benderopt is used to select evaluation points.

The function to minimize is the following: cos(x) + cos(2 * x + 1) + cos(y).

The red point correspond to the location of the global minima between 0 and 2pi for x and y.

The code to generate the video can be found in benchmark/benchmark_sinus2D

We can observe on this example that the parzen estimator tends to explore more the local minimum than the random approach. This might lead to a better optimization given a fixed number of evaluations.

The goal

In Black box optimization, we have a function to optimize but cannot compute the gradient, and evaluation is expensive in term of time / ressource. So we want to find a good exploration-exploitation trade off to get the best hyperparameters in as few evaluations as possible. Use case are:

  • Optimization of a machine learning model (number of layers of a neural network, function of activation, etc.
  • Business optimization (marketing campain, a/b testing)

Code Minimal Example

One of the advantage of benderopt is that it uses JSON-like object representation making it easier for a user to define parameters to optimize. This also allows an easy to integratation with an asynchrounous system such as bender.dreem.com.

Here is a minimal example.

from benderopt import minimize
import numpy as np
import logging

logging.basicConfig(level=logging.DEBUG) # logging.INFO will print less information

# We want to minimize the sinus function between 0 and 2pi
def f(x):
    return np.sin(x)

# We define the parameters we want to optimize:
optimization_problem_parameters = [
    {
        "name": "x", 
        "category": "uniform",
        "search_space": {
            "low": 0,
            "high": 2 * np.pi,
        }
    }
]

# We launch the optimization
best_sample = minimize(f, optimization_problem_parameters, number_of_evaluation=50)

print(best_sample["x"], 3 * np.pi / 2)


> 4.710390692396651 4.71238898038469

Minimal Documentation:

Optimization Problem

An optimization problem contains:

  • A list of parameters (i.e. parameters with their search space)
  • A list of observation (i.e. values for each parameter of the list and a corresponding loss)

We use JSON-like representation for each of them e.g.

optimization_problem_data = {
    "parameters": [
        {
             "name": "parameter_1", 
             "category": "uniform",
             "search_space": {"low": 0, "high": 2 * np.pi, "step": 0.1}
        },
        {
            "name": "parameter_2", 
            "category": "categorical",
            "search_space": {"values": ["a", "b", "c"]}
        }
    ],
    "observations": [
        {
            "sample": {"parameter_1": 0.4, "parameter_2": "a"},
            "loss": 0.08
        },
        {
            "sample": {"parameter_1": 3.4, "parameter_2": "a"},
            "loss": 0.1
        },
        {
            "sample": {"parameter_1": 4.1, "parameter_2": "c"},
            "loss": 0.45
        },
    ]
}

Optimizer

An optimizer takes an optimization problem and suggest new_predictions. In other words, an optimizer takes a list of parameters with their search space and a history of past evaluations to suggest a new one.

Using the optimization_problem_data from the previous example:

from benderopt.base import OptimizationProblem, Observation
from benderopt.optimizer import optimizers

optimization_problem = OptimizationProblem.from_json(optimization_problem_data)
optimizer = optimizers["parzen_estimator"](optimization_problem)
sample = optimizer.suggest()

print(sample)

> {"parameter_1": 3.9, "parameter_2": "b"}

Optimizers currently available are random and parzen_estimator.

Benderopt allows to add a new optimizer really easily by inheriting an optimizer from BaseOptimizer class.

You can check benderopt/optimizer/random.py for a minimal example.

Minimize function

Minimize function shown above in the minimal example section implementation is quite strateforward:

optimization_problem = OptimizationProblem.from_list(optimization_problem_parameters)
optimizer = optimizers["parzen_estimator"](optimization_problem)
for _ in range(number_of_evaluation):
    sample = optimizer.suggest()
    loss = f(**sample)
    observation = Observation.from_dict({"loss": loss, "sample": sample})
    optimization_problem.add_observation(observation)

The optimization_problem's observation history list is extended with a new observations at each iteration. This allows the optimizer to take them into account for the next suggestion.

Uniform Parameter

parameter type default comments
low mandatory - lowest possible value: all values will be greater than or equal to low
high mandatory - highest value: all values will be stricly less than high
step optionnal None discretize the set of possible values: all values will follow 'value = low + k * step with k belonging to [0, K]'

e.g.

    {
        "name": "x", 
        "category": "uniform",
        "search_space": {
            "low": 0,
            "high": 2 * np.pi,
            # "step": np.pi / 8
        }
    }

Log-Uniform Parameter

parameter type default comments
low mandatory - lowest possible value: all values will be greater than or equal to low
high mandatory - highest value: all values will be stricly less than high
step optionnal None "discretize the set of possible values: all values will follow 'value = low + k * step with k belonging to [0, K]'"
base optional 10 logarithmic base to use

e.g.

    {
        "name": "x", 
        "category": "loguniform",
        "search_space": {
            "low": 1e-4,
            "high": 1e-2,
            # "step": 1e-5,
            # "base": 10,
        }
    }

Normal Parameter

parameter type default comments
low optionnal -inf lowest possible value: all values will be greater than or equal to low
high optionnal inf highest value: all values will be stricly less than high
mu mandatory - mean value: all values will be initially drawn following a gaussian centered at mu with sigma variance
sigma mandatory - sigma value: all values will be initially drawn following a gaussian centered at mu with sigma variance
step optionnal None "discretize the set of possible values: all values will follow 'value = low + k * step with k belonging to [0, K]'"

e.g.

    {
        "name": "x", 
        "category": "normal",
        "search_space": {
            # "low": 0,
            # "high": 10,
            "mu": 5,
            "sigma": 1
            # "step": 0.01,
        }
    }

Log-Normal Parameter

parameter type default comments
low optionnal -inf lowest possible value: all values will be greater than or equal to low
high optionnal inf highest value: all values will be stricly less than high
mu mandatory - mean value: all values will be initially drawn following a gaussian centered at mu with sigma variance
sigma mandatory - sigma value: all values will be initially drawn following a gaussian centered at mu with sigma variance
step optionnal None "discretize the set of possible values: all values will follow 'value = low + k * step with k belonging to [0, K]'"
base optional 10 logarithmic base to use

e.g.

    {
        "name": "x", 
        "category": "lognormal",
        "search_space": {
            # "low": 1e-6,
            # "high": 1e0,
            "mu": 1e-3,
            "sigma": 1e-2
            # "step": 1e-7,
            # "base": 10,
        }
    }

Categorical Parameter

parameter type default comments
values mandatory - list of categories: all values will be sampled from this list
probabilities optionnal number_of_values * [1 / number_of_values] list of probabilities: all values will be initially drawn following this probability list

e.g.

    {
        "name": "x", 
        "category": "categorical",
        "search_space": {
            "values": ["a", "b", "c", "d"],
            # "probabilities": [0.1, 0.2, 0.2, 0.2, 0.3]
        }
    }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].