-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python-package] add type hints on cv() #5271
Conversation
params: Dict[str, Any], | ||
train_set: Dataset, | ||
num_boost_round: int = 100, | ||
folds: Optional[Union[Iterable[Tuple[np.ndarray, np.ndarray]], _LGBMBaseCrossValidator]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to https://docs.python.org/3/library/typing.html#typing.Generator, it's ok to use Iterable[return_type]
to document a generator or iterator. So it isn't necessary to use typing.Generator
or typing.Iterator
.
@@ -75,9 +75,9 @@ def __init__(self, *args, **kwargs): | |||
from sklearn.utils.validation import assert_all_finite, check_array, check_X_y | |||
try: | |||
from sklearn.exceptions import NotFittedError | |||
from sklearn.model_selection import GroupKFold, StratifiedKFold | |||
from sklearn.model_selection import BaseCrossValidator, GroupKFold, StratifiedKFold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sklearn.model_selection.BaseCrossValidator
has been in scikit-learn
for at least 7 years, so I don't think this will cause any portability issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two comments.
Co-authored-by: Nikita Titov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Contributes to #3756.
This PR proposes adding type hints to
lightgbm.cv()
, to improvemypy
's ability to catch issues.