{_before_kwargs}client : dask.distributed.Client or None, optional (default=None)
{_before_kwargs}client : dask.distributed.Client or None, optional (default=None)
{' ':4}Dask client. If ``None``, ``distributed.default_client()`` will be used at runtime. The Dask client used by this class will not be saved if the model object is pickled.
{' ':4}Dask client. If ``None``, ``distributed.default_client()`` will be used at runtime. The Dask client used by this class will not be saved if the model object is pickled.
...
@@ -1220,7 +1184,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
...
@@ -1220,7 +1184,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
@@ -1278,7 +1240,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
...
@@ -1278,7 +1240,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
pred_leaf:bool=False,
pred_leaf:bool=False,
pred_contrib:bool=False,
pred_contrib:bool=False,
validate_features:bool=False,
validate_features:bool=False,
**kwargs:Any
**kwargs:Any,
)->dask_Array:
)->dask_Array:
"""Docstring is inherited from the lightgbm.LGBMClassifier.predict."""
"""Docstring is inherited from the lightgbm.LGBMClassifier.predict."""
return_predict(
return_predict(
...
@@ -1292,7 +1254,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
...
@@ -1292,7 +1254,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
pred_leaf=pred_leaf,
pred_leaf=pred_leaf,
pred_contrib=pred_contrib,
pred_contrib=pred_contrib,
validate_features=validate_features,
validate_features=validate_features,
**kwargs
**kwargs,
)
)
predict.__doc__=_lgbmmodel_doc_predict.format(
predict.__doc__=_lgbmmodel_doc_predict.format(
...
@@ -1301,7 +1263,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
...
@@ -1301,7 +1263,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
output_name="predicted_result",
output_name="predicted_result",
predicted_result_shape="Dask Array of shape = [n_samples] or shape = [n_samples, n_classes]",
predicted_result_shape="Dask Array of shape = [n_samples] or shape = [n_samples, n_classes]",
X_leaves_shape="Dask Array of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]",
X_leaves_shape="Dask Array of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]",
X_SHAP_values_shape="Dask Array of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or (if multi-class and using sparse inputs) a list of ``n_classes`` Dask Arrays of shape = [n_samples, n_features + 1]"
X_SHAP_values_shape="Dask Array of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or (if multi-class and using sparse inputs) a list of ``n_classes`` Dask Arrays of shape = [n_samples, n_features + 1]",
)
)
defpredict_proba(
defpredict_proba(
...
@@ -1313,7 +1275,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
...
@@ -1313,7 +1275,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
pred_leaf:bool=False,
pred_leaf:bool=False,
pred_contrib:bool=False,
pred_contrib:bool=False,
validate_features:bool=False,
validate_features:bool=False,
**kwargs:Any
**kwargs:Any,
)->dask_Array:
)->dask_Array:
"""Docstring is inherited from the lightgbm.LGBMClassifier.predict_proba."""
"""Docstring is inherited from the lightgbm.LGBMClassifier.predict_proba."""
return_predict(
return_predict(
...
@@ -1327,7 +1289,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
...
@@ -1327,7 +1289,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
@@ -1336,7 +1298,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
...
@@ -1336,7 +1298,7 @@ class DaskLGBMClassifier(LGBMClassifier, _DaskLGBMModel):
output_name="predicted_probability",
output_name="predicted_probability",
predicted_result_shape="Dask Array of shape = [n_samples] or shape = [n_samples, n_classes]",
predicted_result_shape="Dask Array of shape = [n_samples] or shape = [n_samples, n_classes]",
X_leaves_shape="Dask Array of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]",
X_leaves_shape="Dask Array of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]",
X_SHAP_values_shape="Dask Array of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or (if multi-class and using sparse inputs) a list of ``n_classes`` Dask Arrays of shape = [n_samples, n_features + 1]"
X_SHAP_values_shape="Dask Array of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or (if multi-class and using sparse inputs) a list of ``n_classes`` Dask Arrays of shape = [n_samples, n_features + 1]",
)
)
defto_local(self)->LGBMClassifier:
defto_local(self)->LGBMClassifier:
...
@@ -1355,7 +1317,7 @@ class DaskLGBMRegressor(LGBMRegressor, _DaskLGBMModel):
...
@@ -1355,7 +1317,7 @@ class DaskLGBMRegressor(LGBMRegressor, _DaskLGBMModel):
def__init__(
def__init__(
self,
self,
boosting_type:str='gbdt',
boosting_type:str="gbdt",
num_leaves:int=31,
num_leaves:int=31,
max_depth:int=-1,
max_depth:int=-1,
learning_rate:float=0.1,
learning_rate:float=0.1,
...
@@ -1363,19 +1325,19 @@ class DaskLGBMRegressor(LGBMRegressor, _DaskLGBMModel):
...
@@ -1363,19 +1325,19 @@ class DaskLGBMRegressor(LGBMRegressor, _DaskLGBMModel):
{_before_kwargs}client : dask.distributed.Client or None, optional (default=None)
{_before_kwargs}client : dask.distributed.Client or None, optional (default=None)
{' ':4}Dask client. If ``None``, ``distributed.default_client()`` will be used at runtime. The Dask client used by this class will not be saved if the model object is pickled.
{' ':4}Dask client. If ``None``, ``distributed.default_client()`` will be used at runtime. The Dask client used by this class will not be saved if the model object is pickled.
...
@@ -1424,7 +1386,7 @@ class DaskLGBMRegressor(LGBMRegressor, _DaskLGBMModel):
...
@@ -1424,7 +1386,7 @@ class DaskLGBMRegressor(LGBMRegressor, _DaskLGBMModel):
{_before_kwargs}client : dask.distributed.Client or None, optional (default=None)
{_before_kwargs}client : dask.distributed.Client or None, optional (default=None)
{' ':4}Dask client. If ``None``, ``distributed.default_client()`` will be used at runtime. The Dask client used by this class will not be saved if the model object is pickled.
{' ':4}Dask client. If ``None``, ``distributed.default_client()`` will be used at runtime. The Dask client used by this class will not be saved if the model object is pickled.
...
@@ -1597,7 +1556,7 @@ class DaskLGBMRanker(LGBMRanker, _DaskLGBMModel):
...
@@ -1597,7 +1556,7 @@ class DaskLGBMRanker(LGBMRanker, _DaskLGBMModel):
raiseImportError('You must install matplotlib and restart your session to plot metric.')
raiseImportError("You must install matplotlib and restart your session to plot metric.")
ifisinstance(booster,LGBMModel):
ifisinstance(booster,LGBMModel):
eval_results=deepcopy(booster.evals_result_)
eval_results=deepcopy(booster.evals_result_)
elifisinstance(booster,dict):
elifisinstance(booster,dict):
eval_results=deepcopy(booster)
eval_results=deepcopy(booster)
elifisinstance(booster,Booster):
elifisinstance(booster,Booster):
raiseTypeError("booster must be dict or LGBMModel. To use plot_metric with Booster type, first record the metrics using record_evaluation callback then pass that to plot_metric as argument `booster`")
raiseTypeError(
"booster must be dict or LGBMModel. To use plot_metric with Booster type, first record the metrics using record_evaluation callback then pass that to plot_metric as argument `booster`"
)
else:
else:
raiseTypeError('booster must be dict or LGBMModel.')
raiseTypeError("booster must be dict or LGBMModel.")
@@ -932,16 +943,20 @@ class LGBMModel(_LGBMModelBase):
...
@@ -932,16 +943,20 @@ class LGBMModel(_LGBMModelBase):
deltrain_set,valid_sets
deltrain_set,valid_sets
returnself
returnself
fit.__doc__=_lgbmmodel_doc_fit.format(
fit.__doc__=(
X_shape="numpy array, pandas DataFrame, H2O DataTable's Frame , scipy.sparse, list of lists of int or float of shape = [n_samples, n_features]",
_lgbmmodel_doc_fit.format(
y_shape="numpy array, pandas DataFrame, pandas Series, list of int or float of shape = [n_samples]",
X_shape="numpy array, pandas DataFrame, H2O DataTable's Frame , scipy.sparse, list of lists of int or float of shape = [n_samples, n_features]",
sample_weight_shape="numpy array, pandas Series, list of int or float of shape = [n_samples] or None, optional (default=None)",
y_shape="numpy array, pandas DataFrame, pandas Series, list of int or float of shape = [n_samples]",
init_score_shape="numpy array, pandas DataFrame, pandas Series, list of int or float of shape = [n_samples] or shape = [n_samples * n_classes] (for multi-class task) or shape = [n_samples, n_classes] (for multi-class task) or None, optional (default=None)",
sample_weight_shape="numpy array, pandas Series, list of int or float of shape = [n_samples] or None, optional (default=None)",
group_shape="numpy array, pandas Series, list of int or float, or None, optional (default=None)",
init_score_shape="numpy array, pandas DataFrame, pandas Series, list of int or float of shape = [n_samples] or shape = [n_samples * n_classes] (for multi-class task) or shape = [n_samples, n_classes] (for multi-class task) or None, optional (default=None)",
eval_sample_weight_shape="list of array (same types as ``sample_weight`` supports), or None, optional (default=None)",
group_shape="numpy array, pandas Series, list of int or float, or None, optional (default=None)",
eval_init_score_shape="list of array (same types as ``init_score`` supports), or None, optional (default=None)",
eval_sample_weight_shape="list of array (same types as ``sample_weight`` supports), or None, optional (default=None)",
eval_group_shape="list of array (same types as ``group`` supports), or None, optional (default=None)"
eval_init_score_shape="list of array (same types as ``init_score`` supports), or None, optional (default=None)",
)+"\n\n"+_lgbmmodel_doc_custom_eval_note
eval_group_shape="list of array (same types as ``group`` supports), or None, optional (default=None)",
)
+"\n\n"
+_lgbmmodel_doc_custom_eval_note
)
defpredict(
defpredict(
self,
self,
...
@@ -952,7 +967,7 @@ class LGBMModel(_LGBMModelBase):
...
@@ -952,7 +967,7 @@ class LGBMModel(_LGBMModelBase):
pred_leaf:bool=False,
pred_leaf:bool=False,
pred_contrib:bool=False,
pred_contrib:bool=False,
validate_features:bool=False,
validate_features:bool=False,
**kwargs:Any
**kwargs:Any,
):
):
"""Docstring is set after definition, using a template."""
"""Docstring is set after definition, using a template."""
ifnotself.__sklearn_is_fitted__():
ifnotself.__sklearn_is_fitted__():
...
@@ -961,9 +976,11 @@ class LGBMModel(_LGBMModelBase):
...
@@ -961,9 +976,11 @@ class LGBMModel(_LGBMModelBase):
@@ -997,42 +1019,44 @@ class LGBMModel(_LGBMModelBase):
...
@@ -997,42 +1019,44 @@ class LGBMModel(_LGBMModelBase):
output_name="predicted_result",
output_name="predicted_result",
predicted_result_shape="array-like of shape = [n_samples] or shape = [n_samples, n_classes]",
predicted_result_shape="array-like of shape = [n_samples] or shape = [n_samples, n_classes]",
X_leaves_shape="array-like of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]",
X_leaves_shape="array-like of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]",
X_SHAP_values_shape="array-like of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or list with n_classes length of such objects"
X_SHAP_values_shape="array-like of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or list with n_classes length of such objects",
)
)
@property
@property
defn_features_(self)->int:
defn_features_(self)->int:
""":obj:`int`: The number of features of fitted model."""
""":obj:`int`: The number of features of fitted model."""
ifnotself.__sklearn_is_fitted__():
ifnotself.__sklearn_is_fitted__():
raiseLGBMNotFittedError('No n_features found. Need to call fit beforehand.')
raiseLGBMNotFittedError("No n_features found. Need to call fit beforehand.")
returnself._n_features
returnself._n_features
@property
@property
defn_features_in_(self)->int:
defn_features_in_(self)->int:
""":obj:`int`: The number of features of fitted model."""
""":obj:`int`: The number of features of fitted model."""
ifnotself.__sklearn_is_fitted__():
ifnotself.__sklearn_is_fitted__():
raiseLGBMNotFittedError('No n_features_in found. Need to call fit beforehand.')
raiseLGBMNotFittedError("No n_features_in found. Need to call fit beforehand.")
returnself._n_features_in
returnself._n_features_in
@property
@property
defbest_score_(self)->_LGBM_BoosterBestScoreType:
defbest_score_(self)->_LGBM_BoosterBestScoreType:
""":obj:`dict`: The best score of fitted model."""
""":obj:`dict`: The best score of fitted model."""
ifnotself.__sklearn_is_fitted__():
ifnotself.__sklearn_is_fitted__():
raiseLGBMNotFittedError('No best_score found. Need to call fit beforehand.')
raiseLGBMNotFittedError("No best_score found. Need to call fit beforehand.")
returnself._best_score
returnself._best_score
@property
@property
defbest_iteration_(self)->int:
defbest_iteration_(self)->int:
""":obj:`int`: The best iteration of fitted model if ``early_stopping()`` callback has been specified."""
""":obj:`int`: The best iteration of fitted model if ``early_stopping()`` callback has been specified."""
ifnotself.__sklearn_is_fitted__():
ifnotself.__sklearn_is_fitted__():
raiseLGBMNotFittedError('No best_iteration found. Need to call fit with early_stopping callback beforehand.')
raiseLGBMNotFittedError(
"No best_iteration found. Need to call fit with early_stopping callback beforehand."
description="Return the predicted probability for each class for each sample.",
description="Return the predicted probability for each class for each sample.",
...
@@ -1303,21 +1330,21 @@ class LGBMClassifier(_LGBMClassifierBase, LGBMModel):
...
@@ -1303,21 +1330,21 @@ class LGBMClassifier(_LGBMClassifierBase, LGBMModel):
output_name="predicted_probability",
output_name="predicted_probability",
predicted_result_shape="array-like of shape = [n_samples] or shape = [n_samples, n_classes]",
predicted_result_shape="array-like of shape = [n_samples] or shape = [n_samples, n_classes]",
X_leaves_shape="array-like of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]",
X_leaves_shape="array-like of shape = [n_samples, n_trees] or shape = [n_samples, n_trees * n_classes]",
X_SHAP_values_shape="array-like of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or list with n_classes length of such objects"
X_SHAP_values_shape="array-like of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or list with n_classes length of such objects",
)
)
@property
@property
defclasses_(self)->np.ndarray:
defclasses_(self)->np.ndarray:
""":obj:`array` of shape = [n_classes]: The class label array."""
""":obj:`array` of shape = [n_classes]: The class label array."""
ifnotself.__sklearn_is_fitted__():
ifnotself.__sklearn_is_fitted__():
raiseLGBMNotFittedError('No classes found. Need to call fit beforehand.')
raiseLGBMNotFittedError("No classes found. Need to call fit beforehand.")
returnself._classes# type: ignore[return-value]
returnself._classes# type: ignore[return-value]
@property
@property
defn_classes_(self)->int:
defn_classes_(self)->int:
""":obj:`int`: The number of classes."""
""":obj:`int`: The number of classes."""
ifnotself.__sklearn_is_fitted__():
ifnotself.__sklearn_is_fitted__():
raiseLGBMNotFittedError('No classes found. Need to call fit beforehand.')
raiseLGBMNotFittedError("No classes found. Need to call fit beforehand.")
returnself._n_classes
returnself._n_classes
...
@@ -1345,10 +1372,10 @@ class LGBMRanker(LGBMModel):
...
@@ -1345,10 +1372,10 @@ class LGBMRanker(LGBMModel):