Models and Registry API¶
See the Custom Models and Search Spaces guide for usage.
make_classifier¶
h2ml.core.step.make_classifier(estimator, name=None, requires_scaling=False)
¶
make_regressor¶
h2ml.core.step.make_regressor(estimator, name=None, requires_scaling=False)
¶
ModelWrapper¶
h2ml.core.step.ModelWrapper
¶
Bases: BaseClassifier, BaseRegressor
Wraps any sklearn-compatible classifier or regressor into a BaseStep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimator
|
Any
|
A fitted or unfitted sklearn estimator. |
required |
name
|
Optional[str]
|
Optional display name. Defaults to class name. |
None
|
requires_scaling
|
bool
|
Whether this model needs StandardScaler applied before fitting. The CV engine reads this flag. |
False
|
verbose
|
bool
|
Print fit/predict progress. |
False
|
Examples:
ModelEntry¶
h2ml.utils.registry.ModelEntry
dataclass
¶
Unified descriptor for a single model in the h2ml registry.
Attributes:
| Name | Type | Description |
|---|---|---|
model_cls |
type
|
Sklearn estimator class. |
default_kwargs |
dict
|
Constructor args for the default (non-optimized) instance. |
requires_scaling |
bool
|
Whether StandardScaler must be applied before fitting. |
param_fn |
Optional[Callable]
|
Optuna trial function returning a hyperparameter dict. None means optimization is disabled for this model. |
opt_enabled |
bool
|
Set False to exclude from optimization even if param_fn exists. |
supports_class_weight |
bool
|
Whether the estimator accepts class_weight="balanced". When True, PipelineConfig.handle_imbalance can inject it. |
build_model()
¶
Instantiate a ModelWrapper with default kwargs and scaling flag.
build_models¶
h2ml.utils.registry.build_models(task)
¶
Build a ModelWrapper list from the registry for a given task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
str
|
'classification' or 'regression'. |
required |
Returns:
| Type | Description |
|---|---|
list['ModelWrapper']
|
List of ModelWrapper instances with correct scaling flags and default kwargs. |