autoprognosis.plugins.prediction.regression.plugin_kneighbors_regressor module

class KNeighborsRegressorPlugin(n_neighbors: int = 5, weights: int = 0, algorithm: int = 0, leaf_size: int = 30, p: int = 2, random_state: int = 0, hyperparam_search_iterations: Optional[int] = None, model: Optional[Any] = None, **kwargs: Any)

Bases: autoprognosis.plugins.prediction.regression.base.RegressionPlugin

Regression plugin based on the KNeighborsRegressor.

Parameters
  • n_neighbors – int Number of neighbors to use

  • weights – str Weight function used in prediction. Possible values: “uniform”, “distance”

  • algorithm – int index Algorithm used to compute the nearest neighbors: “ball_tree”, “kd_tree”, “brute” or “auto”.

  • leaf_size – int Leaf size passed to BallTree or KDTree.

  • p – int Power parameter for the Minkowski metric.

  • random_state – int, default 0 Random seed

Example

>>> from autoprognosis.plugins.prediction import Predictions
>>> plugin = Predictions(category="regression").get("kneighbors_regressor")
>>> from sklearn.datasets import load_iris
>>> X, y = load_iris(return_X_y=True)
>>> plugin.fit_predict(X, y)
algorithm = ['auto', 'ball_tree', 'kd_tree', 'brute']
change_output(output: str) None
explain(X: pandas.core.frame.DataFrame, *args: Any, **kwargs: Any) pandas.core.frame.DataFrame
fit(X: pandas.core.frame.DataFrame, *args: Any, **kwargs: Any) autoprognosis.plugins.prediction.regression.base.RegressionPlugin

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

get_args() dict
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.prediction.regression.plugin_kneighbors_regressor.KNeighborsRegressorPlugin

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

predict_proba(X: pandas.core.frame.DataFrame, *args: Any, **kwargs: Any) pandas.core.frame.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

score(X: pandas.core.frame.DataFrame, y: pandas.core.frame.DataFrame, metric: str = 'aucroc') float
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

weights = ['uniform', 'distance']
plugin

alias of autoprognosis.plugins.prediction.regression.plugin_kneighbors_regressor.KNeighborsRegressorPlugin