autoprognosis.plugins.core.base_plugin module

class Plugin

Bases: object

Base class for all plugins. Each derived class must implement the following methods:

  • type() - a static method that returns the type of the plugin. e.g., imputation, preprocessing, prediction, etc.

  • subtype() - optional method that returns the subtype of the plugin. e.g. Potential subtypes:

    • preprocessing: feature_scaling, dimensionality reduction

    • prediction: classifiers, prediction, survival analysis

  • name() - a static method that returns the name of the plugin. e.g., EM, mice, etc.

  • hyperparameter_space() - a static method that returns the hyperparameters that can be tuned during the optimization. The method will return a list of Params derived objects.

  • _fit() - internal method, called by fit on each training set.

  • _transform() - internal method, called by transform. Used by imputation or preprocessing plugins.

  • _predict() - internal method, called by predict. Used by classification/prediction plugins.

  • load/save - serialization methods

If any method implementation is missing, the class constructor will fail.

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

abstract 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

abstract classmethod load(buff: bytes) autoprognosis.plugins.core.base_plugin.Plugin

Load the plugin from bytes

abstract 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.

abstract save() bytes

Save the plugin to bytes

abstract 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

abstract static type() str

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

class PluginLoader(plugins: list, expected_type: Type)

Bases: object

add(name: str, cls: Type) autoprognosis.plugins.core.base_plugin.PluginLoader
get(name: str, *args: Any, **kwargs: Any) Any
get_type(name: str) Type
list() List[str]
list_available() List[str]
reload() autoprognosis.plugins.core.base_plugin.PluginLoader
types() List[Type]