autoprognosis.plugins.imputers.plugin_gain module

class GainPlugin(random_state: int = 0, **kwargs: Any)

Bases: ImputerPlugin

GAIN Imputation for static data using Generative Adversarial Nets.
The training steps are:
  • The generato imputes the missing components conditioned on what is actually observed, and outputs a completed vector.

  • The discriminator takes a completed vector and attempts to determine which components were actually observed and which were imputed.

Args:

batch_size: int

The batch size for the training steps.

n_epochs: int

Number of epochs for training.

hint_rate: float

Percentage of additional information for the discriminator.

loss_alpha: int

Hyperparameter for the generator loss.

Paper: J. Yoon, J. Jordon, M. van der Schaar, “GAIN: Missing Data Imputation using Generative Adversarial Nets, “ ICML, 2018. Original code: https://github.com/jsyoon0823/GAIN

Example

>>> import numpy as np
>>> from autoprognosis.plugins.imputers import Imputers
>>> plugin = Imputers().get("gain")
>>> plugin.fit_transform([[1, 1, 1, 1], [np.nan, np.nan, np.nan, np.nan], [1, 2, 2, 1], [2, 2, 2, 2]])
change_output(output: str) None
fit(X: DataFrame, *args: Any, **kwargs: Any) Plugin

Train the plugin

Parameters:

X – pd.DataFrame

fit_predict(X: DataFrame, *args: Any, **kwargs: Any) DataFrame

Fit the model and predict the training data. Used by predictors.

fit_transform(X: DataFrame, *args: Any, **kwargs: Any) DataFrame

Fit the model and transform the training data. Used by imputers and preprocessors.

classmethod fqdn() str

The fully-qualified name of the plugin: type->subtype->name

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

The hyperparameter search domain, used for tuning.

classmethod hyperparameter_space_fqdn(*args: Any, **kwargs: Any) List[Params]

The hyperparameter domain using they fully-qualified name.

is_fitted() bool

Check if the model was trained

classmethod load(buff: bytes) ImputerPlugin

Load the plugin from bytes

static name() str

The name of the plugin, e.g.: xgboost

predict(X: DataFrame, *args: Any, **kwargs: Any) DataFrame

Run predictions for the input. Used by predictors.

Parameters:

X – pd.DataFrame

classmethod sample_hyperparameters(trial: optuna.trial.Trial, *args: Any, **kwargs: Any) Dict[str, Any]

Sample hyperparameters for Optuna.

classmethod sample_hyperparameters_fqdn(trial: optuna.trial.Trial, *args: Any, **kwargs: Any) Dict[str, Any]

Sample hyperparameters using they fully-qualified name.

classmethod sample_hyperparameters_np(random_state: int = 0, *args: Any, **kwargs: Any) Dict[str, Any]

Sample hyperparameters as a dict.

save() bytes

Save the plugin to bytes

static subtype() str

The type of the plugin, e.g.: classifier

transform(X: DataFrame) DataFrame

Transform the input. Used by imputers and preprocessors.

Parameters:

X – pd.DataFrame

static type() str

The type of the plugin, e.g.: prediction

plugin

alias of GainPlugin