autoprognosis.plugins.prediction.classifiers.plugin_lgbm module
- class LightGBMPlugin(n_estimators: int = 100, boosting_type: str = 'gbdt', learning_rate: float = 0.01, max_depth: int = 6, reg_lambda: float = 0.001, reg_alpha: float = 0.001, colsample_bytree: float = 0.1, subsample: float = 0.1, num_leaves: int = 31, min_child_samples: int = 1, calibration: int = 0, model: Optional[Any] = None, random_state: int = 0, **kwargs: Any)
Bases:
autoprognosis.plugins.prediction.classifiers.base.ClassifierPlugin
Classification plugin based on LightGBM.
- Method:
Gradient boosting is a machine learning technique for regression and classification problems, which produces a prediction model in the form of an ensemble of weak prediction models, typically decision trees. When a decision tree is the weak learner, the resulting algorithm is called gradient boosted trees, which usually outperforms random forest.
- Parameters
n_estimators – int The number of boosting stages to perform. Gradient boosting is fairly robust to over-fitting so a large number usually results in better performance.
learning_rate – float Learning rate shrinks the contribution of each tree by learning_rate. There is a trade-off between learning_rate and n_estimators.
max_depth – int The maximum depth of the individual regression estimators.
boosting_type – str ‘gbdt’, traditional Gradient Boosting Decision Tree. ‘dart’, Dropouts meet Multiple Additive Regression Trees. ‘goss’, Gradient-based One-Side Sampling. ‘rf’, Random Forest.
objective – str Specify the learning task and the corresponding learning objective or a custom objective function to be used.
reg_lambda – float L2 regularization term on weights.
reg_alpha – float L1 regularization term on weights.
colsample_bytree – float Subsample ratio of columns when constructing each tree.
subsample – float Subsample ratio of the training instance.
num_leaves – int Maximum tree leaves for base learners.
min_child_samples – int Minimum sum of instance weight (hessian) needed in a child (leaf).
calibration – int Enable/disable calibration. 0: disabled, 1 : sigmoid, 2: isotonic.
random_state – int, default 0 Random seed
Example
>>> from autoprognosis.plugins.prediction import Predictions >>> plugin = Predictions(category="classifiers").get("lgbm") >>> 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.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
- 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.classifiers.plugin_lgbm.LightGBMPlugin
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