tempor.methods.preprocessing.imputation.static.plugin_static_tabular_imputer module

Impute static covariates using any tabular imputer from the hyperimpute library.

class tempor.methods.preprocessing.imputation.static.plugin_static_tabular_imputer.StaticTabularImputerParams(imputer: typing_extensions.Literal[mean, missforest, EM, hyperimpute, sinkhorn, median, sklearn_missforest, miracle, softimpute, mice, gain, sklearn_ice, miwae, ice, most_frequent] = 'ice', random_state: int = 0, imputer_params: ~typing.Dict[str, ~typing.Any] = <factory>)[source]

Bases: object

Initialization parameters for StaticTabularImputer.

imputer : Literal[mean] | Literal[missforest] | Literal[EM] | Literal[hyperimpute] | Literal[sinkhorn] | Literal[median] | Literal[sklearn_missforest] | Literal[miracle] | Literal[softimpute] | Literal[mice] | Literal[gain] | Literal[sklearn_ice] | Literal[miwae] | Literal[ice] | Literal[most_frequent] = 'ice'

Which imputer to use for static covariate imputation.

random_state : int = 0

Random seed. Will be passed on to the underlying imputer.

imputer_params : dict[str, Any]

Parameters to pass to the underlying imputer as a keyword arguments dictionary. Defaults to {}.

class tempor.methods.preprocessing.imputation.static.plugin_static_tabular_imputer.StaticTabularImputer(**params: Any)[source]

Bases: BaseImputer

Impute the static covariates using any tabular imputer from the hyperimpute library.

Parameters:
**params : Any

Parameters and defaults as defined in StaticTabularImputerParams.

Example

>>> from tempor import plugin_loader
>>>
>>> dataset = plugin_loader.get(
...     "prediction.one_off.sine",
...     plugin_type="datasource",
...     with_missing=True,
... ).load()
>>> assert dataset.static.dataframe().isna().sum().sum() != 0
>>>
>>> # Load the model:
>>> model = plugin_loader.get("preprocessing.imputation.static.static_tabular_imputer")
>>>
>>> # Train:
>>> model.fit(dataset)
StaticTabularImputer(...)
>>>
>>> # Impute:
>>> imputed = model.transform(dataset)
>>> assert imputed.static.dataframe().isna().sum().sum() == 0
ParamsDefinition

alias of StaticTabularImputerParams

params : StaticTabularImputerParams
category : ClassVar[plugin_typing.PluginCategory] = 'preprocessing.imputation.static'

Plugin category, such as 'prediction.one_off.classification'. Must be set by the plugin class using @register_plugin.

name : ClassVar[plugin_typing.PluginName] = 'static_tabular_imputer'

Plugin name, such as 'my_nn_classifier'. Must be set by the plugin class using @register_plugin.

plugin_type : ClassVar[plugin_typing.PluginTypeArg] = 'method'

Plugin type, such as 'method'. May be optionally set by the plugin class using @register_plugin, else will set the default plugin type.

static hyperparameter_space(*args: Any, **kwargs: Any) list[Params][source]

The hyperparameter search domain, used for tuning.

Can provide variadics *args and **kwargs, these will be received from sample_hyperparameters.