MOFA Algorithm¶
orion.algo.mofa.mofa
– MOFA¶
MOdular FActorial Design (MOFA)
- class orion.algo.mofa.mofa.MOFA(space: Space, seed: int | Sequence[int] | None = None, index: int = 1, n_levels: int = 5, strength: int = 2, threshold: float = 0.1)[source]¶
MOdular FActorial Design (MOFA).
For more information on the algorithm, see original paper: MOFA: Modular Factorial Design for Hyperparameter Optimization https://arxiv.org/abs/2011.09545
Xiong, Bo, Yimin Huang, Hanrong Ye, Steffen Staab, and Zhenguo Li. “MOFA: Modular Factorial Design for Hyperparameter Optimization.” arXiv preprint arXiv:2011.09545 (2020).
- Parameters
- space: `orion.algo.space.Space`
Optimisation space with priors for each dimension.
- seed: None, int or sequence of int
Seed for the random number generator used to sample new trials. Default:
None
- index: int, optional
This is the lambda parameter in the paper. Default:
1
- n_levels: int, optional
Number of levels in the orthogonal Latin hypercube (OLH) table. Should be set to a prime number. This is the l parameter in the paper. Default:
5
- strength: int, optional
Strength parameter. This is the t parameter in the paper. Default:
2
- threshold: float, optional
The threshold to determine is a dimension was explored enough and can be fixed. Default: 0.1
Notes
Default values for the index, n_levels, and strength (t) parameter are set to the empirically obtained optimal values described in section 5.2 of the paper.
The number of trials N for a single MOFA iteration is set to
N = index * n_levels^t
. The--exp-max-trials
should be a multiple of N.MOFA requires Python v3.8 or greater and scipy v1.8 or greater.
- Attributes
is_done
Return True, if an algorithm holds that there can be no further improvement.
state_dict
Return a state dict that can be used to reset the state of the algorithm.
Methods
observe
(trials)Observe the trials new state of result.
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
suggest
(num)Suggest a number of new sets of parameters.
- property is_done: bool¶
Return True, if an algorithm holds that there can be no further improvement.
- observe(trials: list[Trial]) None [source]¶
Observe the trials new state of result.
Collects the completed trials until all trials for the current MOFA iteration have been provided. Then runs the MOFA transformer, analysis and region-of-interest generation stages to prepare for the next iteration, or stops if all parameters have been frozen.
- Parameters
- trials: list of ``orion.core.worker.trial.Trial``
Trials from a
orion.algo.space.Space
.
- seed_rng(seed: int) None [source]¶
Seed the state of the random number generator.
- Parameters
- seed: int
Integer seed for the random number generator.
- set_state(state_dict: dict) None [source]¶
Reset the state of the algorithm based on the given state_dict
- Parameters
- state_dict: dict
Dictionary representing state of an algorithm
- property state_dict: dict¶
Return a state dict that can be used to reset the state of the algorithm.
- suggest(num: int) list[Trial] [source]¶
Suggest a number of new sets of parameters.
Draws points from a prepared set of samples from an orthonal Latin hypercube.
- Parameters
- num: int, optional
Number of trials to suggest. The algorithm may return less than the number of trials requested.
- Returns
- list of trials
A list of trials representing values suggested by the algorithm. The algorithm may opt out if it cannot make a good suggestion at the moment (it may be waiting for other trials to complete), in which case it will return an empty list.
Notes
New parameters must be compliant with the problem’s domain
orion.algo.space.Space
.
- orion.algo.mofa.mofa.get_factorial_importance_analysis(factorial_performance_analysis: DataFrame, space: int) DataFrame [source]¶
Compute the factorial importance analysis
- orion.algo.mofa.mofa.get_factorial_performance_analysis(oa_table: DataFrame, space: Space, n_levels: int) DataFrame [source]¶
Compute the factorial performance analysis
- orion.algo.mofa.mofa.select_new_region_of_interest(factorial_importance_analysis: pd.DataFrame, space: Space, threshold: float, n_levels: int) tuple[Space, dict] [source]¶
Select new region of interest and frozen parameter values based on factorial analysis.
- Parameters
- factorial_importance_analysis: dict
Marginal variance ratios on best levels of the factorial performance analysis. Should have format {‘dim-name’: <marginal variance ratio>, …}
- space: ``orion.algo.space.Space``
Space object representing the current region of interest.
- threshold: float
Threshold of marginal variance ratio below which we should freeze a dimension.