pub trait ModelFactory: Send + Sync {
// Required methods
fn config_space(&self) -> SearchSpace;
fn create(
&self,
params: &ParamMap,
) -> Result<Box<dyn StreamingLearner>, FactoryError>;
fn name(&self) -> &str;
// Provided methods
fn warmup_hint(&self) -> usize { ... }
fn complexity_hint(&self) -> usize { ... }
fn n_features_hint(&self) -> usize { ... }
fn supports_auto_builder(&self) -> bool { ... }
}Expand description
Factory for creating streaming learner instances from hyperparameter configurations.
Implementations define the hyperparameter search space (a typed
SearchSpace) and how to construct a model from a sampled
ParamMap.
§Migration from positional HyperConfig
Pre-v10 factories returned a ConfigSpace of positional HyperParam
entries and consumed a HyperConfig (a Vec<f64> indexed by position).
That API is deprecated in favor of typed, named-access SearchSpace /
ParamMap. The legacy types remain for one release cycle behind
#[deprecated] to give downstream crates time to migrate.
Required Methods§
Sourcefn config_space(&self) -> SearchSpace
fn config_space(&self) -> SearchSpace
The hyperparameter search space for this model type.
Sourcefn create(
&self,
params: &ParamMap,
) -> Result<Box<dyn StreamingLearner>, FactoryError>
fn create( &self, params: &ParamMap, ) -> Result<Box<dyn StreamingLearner>, FactoryError>
Create a new model instance from a sampled parameter map.
The params are values drawn from Self::config_space. Factories
access them by name via ParamMap::float / ParamMap::int /
ParamMap::category. Conditional parameters whose gate did not fire
are absent from the map; factories must use the _optional variants
for those reads.
Returns Err(FactoryError) when the sampled hyperparameter combination
is structurally invalid. The AutoML racing layer catches this error,
logs a warning, and skips the offending arm rather than panicking.
Provided Methods§
Sourcefn warmup_hint(&self) -> usize
fn warmup_hint(&self) -> usize
Minimum samples a new model needs before its metrics are meaningful.
Candidates that have seen fewer than warmup_hint() samples are
protected from elimination during tournament rounds. This prevents
neural architectures with warmup phases (ESN, Mamba, SpikeNet) from
being prematurely killed by models that start predicting immediately.
The default is 0 (no warmup protection).
Sourcefn complexity_hint(&self) -> usize
fn complexity_hint(&self) -> usize
Approximate model complexity (effective parameter count).
Used for complexity-adjusted elimination: models with higher complexity are penalized more when evaluation data is scarce. This naturally favors simpler models on sparse data and lets complex models prove themselves when data is abundant.
The default is 100 (moderate complexity).
Sourcefn n_features_hint(&self) -> usize
fn n_features_hint(&self) -> usize
Number of input features this factory expects.
Used by the auto-builder to initialize the FeasibleRegion with
correct dimensionality, ensuring config bounds (especially grace period
and lambda) are properly calibrated.
The default is 1 (conservative estimate).
Sourcefn supports_auto_builder(&self) -> bool
fn supports_auto_builder(&self) -> bool
Return true if the SPSA auto-builder (FeasibleRegion + DiagnosticLearner)
is meaningful for this factory.
The auto-builder is designed for the SGBT family. Non-SGBT factories
should return false (the default) so that the AutoTuner can log a
warning and skip activating the adaptor rather than silently no-oping.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".