autoprognosis.plugins.preprocessors.dimensionality_reduction.plugin_pca module
- class PCAPlugin(random_state: int = 0, model: Any | None = None, n_components: int = 2)
Bases:
PreprocessorPluginPreprocessing plugin for dimensionality reduction based on the PCA method.
- Method:
PCA is used to decompose a multivariate dataset in a set of successive orthogonal components that explain a maximum amount of the variance.
- Reference:
https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html
- Parameters:
n_components – int Number of components to use.
Example
>>> from autoprognosis.plugins.preprocessors import Preprocessors >>> plugin = Preprocessors(category="dimensionality_reduction").get("pca") >>> from sklearn.datasets import load_iris >>> X, y = load_iris(return_X_y=True) >>> plugin.fit_transform(X, y)
- change_output(output: str) None
- static components_interval(*args: Any, **kwargs: Any) Tuple[int, int]
- 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
- 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