From 0e6ed2f670675b27cdf16a5b446d461a3e99207b Mon Sep 17 00:00:00 2001 From: James Lamb Date: Sun, 26 Feb 2023 23:04:40 -0600 Subject: [PATCH] [python-package] add type hints on feature_name and categorical_feature in sklearn interface --- python-package/lightgbm/sklearn.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/python-package/lightgbm/sklearn.py b/python-package/lightgbm/sklearn.py index c00538992964..8633f0f937bd 100644 --- a/python-package/lightgbm/sklearn.py +++ b/python-package/lightgbm/sklearn.py @@ -8,7 +8,8 @@ import numpy as np from .basic import (Booster, Dataset, LightGBMError, _choose_param_value, _ConfigAliases, _LGBM_BoosterBestScoreType, - _LGBM_EvalFunctionResultType, _log_warning) + _LGBM_CategoricalFeatureConfiguration, _LGBM_EvalFunctionResultType, _LGBM_FeatureNameConfiguration, + _log_warning) from .callback import _EvalResultDict, record_evaluation from .compat import (SKLEARN_INSTALLED, LGBMNotFittedError, _LGBMAssertAllFinite, _LGBMCheckArray, _LGBMCheckClassificationTargets, _LGBMCheckSampleWeight, _LGBMCheckXY, _LGBMClassifierBase, @@ -708,8 +709,8 @@ def fit( eval_init_score=None, eval_group=None, eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None, - feature_name='auto', - categorical_feature='auto', + feature_name: _LGBM_FeatureNameConfiguration = 'auto', + categorical_feature: _LGBM_CategoricalFeatureConfiguration = 'auto', callbacks=None, init_model: Optional[Union[str, Path, Booster, "LGBMModel"]] = None ): @@ -999,8 +1000,8 @@ def fit( # type: ignore[override] eval_sample_weight=None, eval_init_score=None, eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None, - feature_name='auto', - categorical_feature='auto', + feature_name: _LGBM_FeatureNameConfiguration = 'auto', + categorical_feature: _LGBM_CategoricalFeatureConfiguration = 'auto', callbacks=None, init_model: Optional[Union[str, Path, Booster, LGBMModel]] = None ): @@ -1046,8 +1047,8 @@ def fit( # type: ignore[override] eval_class_weight=None, eval_init_score=None, eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None, - feature_name='auto', - categorical_feature='auto', + feature_name: _LGBM_FeatureNameConfiguration = 'auto', + categorical_feature: _LGBM_CategoricalFeatureConfiguration = 'auto', callbacks=None, init_model: Optional[Union[str, Path, Booster, LGBMModel]] = None ): @@ -1216,8 +1217,8 @@ def fit( # type: ignore[override] eval_group=None, eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None, eval_at: Union[List[int], Tuple[int, ...]] = (1, 2, 3, 4, 5), - feature_name='auto', - categorical_feature='auto', + feature_name: _LGBM_FeatureNameConfiguration = 'auto', + categorical_feature: _LGBM_CategoricalFeatureConfiguration = 'auto', callbacks=None, init_model: Optional[Union[str, Path, Booster, LGBMModel]] = None ):