Skip to content
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] [docs] complete type annotations for scikit-learn fit() methods #5816

Merged
merged 6 commits into from
Apr 11, 2023

Conversation

jameslamb
Copy link
Collaborator

Contributes to #3756.
Follow-up to #5757.

Adds type annotations on all remaining arguments to fit() methods in the scikit-learn interface.

Replaces all remaining uses of "array" or "array-like" in fit() docs with specific types, following @StrikerRUS 's suggestion from #3756 (comment).

This will hopefully make the docs a bit clearer for users, the code a bit easier to understand for contributors, and will improve mypy's ability to catch type issues (both in this project and in upstream projects that depend on lightgbm).

How I tested this

Added additional test cases in test_sklearn.py adding some other data types for init_score, sample_weight, and all the eval_* equivalents. Those tests don't cover every possible combination of all types for all arguments (that would be literally 1000s of tests), but every type in these type annotations is covered at least once by a test.

e.g., there isn't a "y is a list and init_score is a numpy array" test, but there is at least one "y is a list" test and at least one "init_score is a numpy array" test.

I also ran mypy to confirm that this PR does not add any new type-checking errors.

@jameslamb jameslamb merged commit 99daacf into master Apr 11, 2023
@jameslamb jameslamb deleted the sklearn-fit-annotations branch April 11, 2023 04:27
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants