TPE Algorithm

orion.algo.tpe – Tree-structured Parzen Estimator Approach

class orion.algo.tpe.CategoricalSampler(tpe, observations, choices)[source]

Categorical Sampler for discrete integer and categorical choices

Parameters:
tpe: `TPE` algorithm

The tpe algorithm object which this sampler will be part of.

observations: list

Observed values in the dimension

choices: list

Candidate values for the dimension

Methods

get_loglikelis(points) Return the log likelihood for the points
sample([num]) Sample required number of points
get_loglikelis(points)[source]

Return the log likelihood for the points

sample(num=1)[source]

Sample required number of points

class orion.algo.tpe.GMMSampler(tpe, mus, sigmas, low, high, weights=None)[source]

Gaussian Mixture Model Sampler for TPE algorithm

Parameters:
tpe: `TPE` algorithm

The tpe algorithm object which this sampler will be part of.

mus: list

mus for each Gaussian components in the GMM. Default: None

sigmas: list

sigmas for each Gaussian components in the GMM.

low: real

Lower bound of the sampled points.

high: real

Upper bound of the sampled points.

weights: list

Weights for each Gaussian components in the GMM Default: None

Methods

get_loglikelis(points) Return the log likelihood for the points
sample([num]) Sample required number of points
get_loglikelis(points)[source]

Return the log likelihood for the points

sample(num=1)[source]

Sample required number of points

class orion.algo.tpe.TPE(space, seed=None, n_initial_points=20, n_ei_candidates=24, gamma=0.25, equal_weight=False, prior_weight=1.0, full_weight_num=25)[source]

Tree-structured Parzen Estimator (TPE) algorithm is one of Sequential Model-Based Global Optimization (SMBO) algorithms, which will build models to propose new points based on the historical observed trials.

Instead of modeling p(y|x) like other SMBO algorithms, TPE models p(x|y) and p(y), and p(x|y) is modeled by transforming that generative process, replacing the distributions of the configuration prior with non-parametric densities.

The TPE defines p(x|y) using two such densities l(x) and g(x) while l(x) is distribution of good points and g(x) is the distribution of bad points. New point candidates will be sampled with l(x) and Expected Improvement (EI) optimization scheme will be used to find the most promising point among the candidates.

For more information on the algorithm, see original papers at:

Parameters:
space: `orion.algo.space.Space`

Optimisation space with priors for each dimension.

seed: None, int or sequence of int

Seed to sample initial points and candidates points. Default: None

n_initial_points: int

Number of initial points randomly sampled. Default: 20

n_ei_candidates: int

Number of candidates points sampled for ei compute. Default: 24

gamma: real

Ratio to split the observed trials into good and bad distributions. Default: 0.25

equal_weight: bool

True to set equal weights for observed points. Default: False

prior_weight: int

The weight given to the prior point of the input space. Default: 1.0

full_weight_num: int

The number of the most recent trials which get the full weight where the others will be applied with a linear ramp from 0 to 1.0. It will only take effect if equal_weight is False.

Attributes:
configuration

Return tunable elements of this algorithm in a dictionary form appropriate for saving.

is_done

Return True, if an algorithm holds that there can be no further improvement.

should_suspend

Allow algorithm to decide whether a particular running trial is still worth to complete its evaluation, based on information provided by the judge method.

space

Domain of problem associated with this algorithm’s instance.

state_dict

Return a state dict that can be used to reset the state of the algorithm.

Methods

judge(point, measurements) Inform an algorithm about online measurements of a running trial.
observe(points, results) Observe evaluation results corresponding to list of points in space.
sample_one_dimension(dimension, shape_size, …) Sample values for a dimension
score(point) Allow algorithm to evaluate point based on a prediction about this parameter set’s performance.
seed_rng(seed) Seed the state of the random number generator.
set_state(state_dict) Reset the state of the algorithm based on the given state_dict
split_trials() Split the observed trials into good and bad ones based on the ratio gamma`
suggest([num]) Suggest a num of new sets of parameters.
observe(points, results)[source]

Observe evaluation results corresponding to list of points in space.

A simple random sampler though does not take anything into account.

sample_one_dimension(dimension, shape_size, below_points, above_points, sampler)[source]

Sample values for a dimension

Parameters:
  • dimension – Dimension.
  • shape_size – 1D Shape Size of the Real Dimension.
  • below_points – good points with shape (m, n), m=shape_size.
  • above_points – bad points with shape (m, n), m=shape_size.
  • sampler – method to sample one value for upon the dimension.
seed_rng(seed)[source]

Seed the state of the random number generator.

Parameters:seed – Integer seed for the random number generator.
set_state(state_dict)[source]

Reset the state of the algorithm based on the given state_dict

Parameters:state_dict – Dictionary representing state of an algorithm
split_trials()[source]

Split the observed trials into good and bad ones based on the ratio gamma`

state_dict

Return a state dict that can be used to reset the state of the algorithm.

suggest(num=1)[source]

Suggest a num of new sets of parameters. Randomly draw samples from the import space and return them.

Parameters:num – how many sets to be suggested.

Note

New parameters must be compliant with the problem’s domain orion.algo.space.Space.

orion.algo.tpe.adaptive_parzen_estimator(mus, low, high, prior_weight=1.0, equal_weight=False, flat_num=25)[source]

Return the sorted mus, the corresponding sigmas and weights with adaptive kernel estimator.

This adaptive parzen window estimator is based on the original papers and also refer the use of prior mean in this implementation.

Parameters:
  • mus – list of real values for observed mus.
  • low – real value for lower bound of points.
  • high – real value for upper bound of points.
  • prior_weight – real value for the weight of the prior mean.
  • equal_weight – bool value indicating if all points with equal weights.
  • flat_num – int value indicating the number of the most recent trials which get the full weight where the others will be applied with a linear ramp from 0 to 1.0. It will only take effect if equal_weight is False.
orion.algo.tpe.compute_max_ei_point(points, below_likelis, above_likelis)[source]

Compute ei among points based on their log likelihood and return the point with max ei.

Parameters:
  • points – list of point with real values.
  • below_likelis – list of log likelihood for each point in the good GMM.
  • above_likelis – list of log likelihood for each point in the bad GMM.
orion.algo.tpe.ramp_up_weights(total_num, flat_num, equal_weight)[source]

Adjust weights of observed trials.

Parameters:
  • total_num – total number of observed trials.
  • flat_num – the number of the most recent trials which get the full weight where the others will be applied with a linear ramp from 0 to 1.0. It will only take effect if equal_weight is False.
  • equal_weight – whether all the observed trails share the same weights.