Expand description
High-performance Tree-structured Parzen Estimator optimization.
use parzen::{
CategoricalDistribution, Direction, Distribution, SearchSpace, Study,
TpeSampler, TpeSamplerConfig,
};
let mut space = SearchSpace::new();
space.add("x", Distribution::Categorical(CategoricalDistribution::new(5)?))?;
let sampler = TpeSampler::new(TpeSamplerConfig::performance(42).startup_trials(5))?;
let mut study = Study::new(Direction::Maximize, sampler, space)?;
for _ in 0..20 {
let x = study.suggest_categorical("x")?;
study.complete_trial(if x == 2 { 1.0 } else { 0.1 })?;
}
assert!(study.best_value().is_some_and(|value| value > 0.5));Explicit parameter groups use one trial-aligned mixture component for the
entire vector. Their joint likelihood is
logsumexp(log(weight[k]) + sum_d log(kernel[d][k](x[d]))), preserving
correlations that independent marginal models discard. Integer and stepped
distributions integrate each Gaussian kernel over the selected grid cell
instead of treating a discrete value as a continuous point.
HistoryPolicy::Bounded keeps a fixed-size exact best set, recent bad
observations, and a deterministic reservoir, so estimator state and
incremental update work do not grow with completed-trial count. Raw trial
records remain complete. HistoryPolicy::Full retains exact full-history
ranking and therefore has linear storage and model-construction costs.
Structs§
- Categorical
Distribution - A categorical distribution represented by choice indices.
- Float
Distribution - A bounded floating-point distribution.
- GroupId
- Stable explicit multivariate-group identifier.
- IntDistribution
- A bounded integer distribution.
- ParamId
- Stable parameter identifier within one search space.
- Parameter
Ref - Read-only information about a registered parameter.
- Params
- Iterator over one trial’s parameter names and values.
- Search
Space - A validated collection of parameter distributions, conditions, and groups.
- Study
- A sequential Bayesian optimization study.
- TpeSampler
- Seeded Tree-structured Parzen Estimator sampler.
- TpeSampler
Config - Validated sampler configuration.
- TrialId
- Stable identifier assigned to a completed trial.
- Trial
Input - Owned input for injecting a completed trial.
- Trial
Record - Owned, serializable representation of a completed trial.
- Trial
Ref - Borrowed, allocation-free view of a completed trial.
- Trials
- Exact-size, double-ended iterator over completed trials.
Enums§
- Condition
- A condition controlling whether a parameter is active.
- Direction
- Optimization direction.
- Distribution
- A categorical, floating-point, or integer search distribution.
- Float
Scale - Scale used by a floating-point distribution.
- Gamma
Strategy - Strategy mapping applicable observation count to good-trial count.
- History
Policy - Amount of estimator history retained.
- IntScale
- Scale used by an integer distribution.
- Model
Strategy - Independent or explicit-group multivariate modeling.
- Param
Value - A typed parameter value.
- Parzen
Error - An invalid configuration, search space, trial, or study operation.
- Weight
Strategy - Observation weighting strategy.