autoprognosis.plugins.imputers.plugin_softimpute module
- class SoftImputePlugin(random_state: int = 0, **kwargs: Any)
Bases:
autoprognosis.plugins.imputers.base.ImputerPlugin
- The SoftImpute algorithm fits a low-rank matrix approximation to a matrix with missing values via nuclear- norm regularization. The algorithm can be used to impute quantitative data.
To calibrate the the nuclear-norm regularization parameter(shrink_lambda), we perform cross- validation(_cv_softimpute)
- Args:
- maxit: int, default=500
maximum number of imputation rounds to perform.
- convergence_thresholdfloat, default=1e-5
Minimum ration difference between iterations before stopping.
- max_rankint, default=2
Perform a truncated SVD on each iteration with this value as its rank.
- shrink_lambda: float, default=0
Value by which we shrink singular values on each iteration. If it’s missing, it is calibrated using cross validation.
- cv_len: int, default=15
the length of the grid on which the cross-validation is performed.
Example
>>> import numpy as np >>> from autoprognosis.plugins.imputers import Imputers >>> plugin = Imputers().get("softimpute") >>> plugin.fit_transform([[1, 1, 1, 1], [np.nan, np.nan, np.nan, np.nan], [1, 2, 2, 1], [2, 2, 2, 2]]) 0 1 2 3 0 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1 3.820605e-16 1.708249e-16 1.708249e-16 3.820605e-16 2 1.000000e+00 2.000000e+00 2.000000e+00 1.000000e+00 3 2.000000e+00 2.000000e+00 2.000000e+00 2.000000e+00
Reference: “Spectral Regularization Algorithms for Learning Large Incomplete Matrices”, by Mazumder, Hastie, and Tibshirani.
- change_output(output: str) None
- fit(X: pandas.core.frame.DataFrame, *args: Any, **kwargs: Any) autoprognosis.plugins.core.base_plugin.Plugin
Train the plugin
- Parameters
X – pd.DataFrame
- fit_predict(X: pandas.core.frame.DataFrame, *args: Any, **kwargs: Any) pandas.core.frame.DataFrame
Fit the model and predict the training data. Used by predictors.
- fit_transform(X: pandas.core.frame.DataFrame, *args: Any, **kwargs: Any) pandas.core.frame.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[autoprognosis.plugins.core.params.Params]
The hyperparameter search domain, used for tuning.
- classmethod hyperparameter_space_fqdn(*args: Any, **kwargs: Any) List[autoprognosis.plugins.core.params.Params]
The hyperparameter domain using they fully-qualified name.
- is_fitted() bool
Check if the model was trained
- classmethod load(buff: bytes) autoprognosis.plugins.imputers.base.ImputerPlugin
Load the plugin from bytes
- static name() str
The name of the plugin, e.g.: xgboost
- predict(X: pandas.core.frame.DataFrame, *args: Any, **kwargs: Any) pandas.core.frame.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: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame
Transform the input. Used by imputers and preprocessors.
- Parameters
X – pd.DataFrame
- static type() str
The type of the plugin, e.g.: prediction