autoprognosis.plugins.prediction.regression.plugin_neural_nets_regression module
- class BasicNet(*args: Any, **kwargs: Any)
Bases:
torch.nn.Module
Basic neural net.
- Parameters
n_unit_in (int) – Number of features
n_layers_hidden (int) – Number of hypothesis layers (n_layers_hidden x n_units_hidden + 1 x Linear layer)
n_units_hidden (int) – Number of hidden units in each hypothesis layer
nonlin (string, default 'elu') – Nonlinearity to use in NN. Can be ‘elu’, ‘relu’, ‘selu’ or ‘leaky_relu’.
lr (float) – learning rate for optimizer. step_size equivalent in the JAX version.
weight_decay (float) – l2 (ridge) penalty for the weights.
n_iter (int) – Maximum number of iterations.
batch_size (int) – Batch size
n_iter_print (int) – Number of iterations after which to print updates and check the validation loss.
val_split_prop (float) – Proportion of samples used for validation split (can be 0)
patience (int) – Number of iterations to wait before early stopping after decrease in validation loss
n_iter_min (int) – Minimum number of iterations to go through before starting early stopping
clipping_value (int, default 1) – Gradients clipping value
- forward(X: torch.Tensor) torch.Tensor
- train(X: torch.Tensor, y: torch.Tensor) autoprognosis.plugins.prediction.regression.plugin_neural_nets_regression.BasicNet
- class NeuralNetsRegressionPlugin(n_layers_hidden: int = 1, n_units_hidden: int = 100, nonlin: str = 'relu', lr: float = 0.001, weight_decay: float = 0.001, n_iter: int = 1000, batch_size: int = 512, n_iter_print: int = 10, patience: int = 10, n_iter_min: int = 100, dropout: float = 0.1, clipping_value: int = 1, batch_norm: bool = True, early_stopping: bool = True, random_state: int = 0, hyperparam_search_iterations: Optional[int] = None, **kwargs: Any)
Bases:
autoprognosis.plugins.prediction.regression.base.RegressionPlugin
Regression plugin based on Neural networks.
- Parameters
n_layers_hidden (int) – Number of hypothesis layers (n_layers_hidden x n_units_hidden + 1 x Linear layer)
n_units_hidden (int) – Number of hidden units in each hypothesis layer
nonlin (string, default 'elu') – Nonlinearity to use in NN. Can be ‘elu’, ‘relu’, ‘selu’ or ‘leaky_relu’.
lr (float) – learning rate for optimizer. step_size equivalent in the JAX version.
weight_decay (float) – l2 (ridge) penalty for the weights.
n_iter (int) – Maximum number of iterations.
batch_size (int) – Batch size
n_iter_print (int) – Number of iterations after which to print updates and check the validation loss.
val_split_prop (float) – Proportion of samples used for validation split (can be 0)
patience (int) – Number of iterations to wait before early stopping after decrease in validation loss
n_iter_min (int) – Minimum number of iterations to go through before starting early stopping
clipping_value (int, default 1) – Gradients clipping value
random_state (int) – Random seed
Example –
>>> from autoprognosis.plugins.prediction import Predictions >>> plugin = Predictions(category="regression").get("neural_nets_regression", n_iter = 100) >>> from sklearn.datasets import load_iris >>> X, y = load_iris(return_X_y=True) >>> plugin.fit_predict(X, y) # returns the probabilities for each class
- 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_neural_nets_regression.NeuralNetsRegressionPlugin
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