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] support customizing Dataset creation in Booster.refit() (fixes #3038) #4894

Merged
merged 12 commits into from
Jan 22, 2022

Conversation

TremaMiguel
Copy link
Contributor

Context:
This PR aims to close #3038

Changes

  • refit method accepts kwargs_for_dataset parameter to pass weight parameter to Dataset initialization inside refit().
  • refit method accepts kwargs_for_predict parameter to pass original params to predict method.

Tests:
Based on @jtilly example on issue #3038 test that refit method returns a valid prediction value when passing kwargs_for_dataset or kwargs_for_predict.

@ghost
Copy link

ghost commented Dec 19, 2021

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! I left some initial comments based on the format of what you're proposing, but I'm not the best person to comment on whether or not #3038 should be adopted at all.

For example, I don't know if the comment mentioned at #3038 (comment) means that init_score, weight, and group is still true.

Hopefully @guolinke @shiyu1994 or @StrikerRUS can comment on whether we should proceed with this feature.

python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
@shiyu1994
Copy link
Collaborator

For example, I don't know if the comment mentioned at #3038 (comment) means that init_score, weight, and group is still true.

I think it is useful that we want to change the weights of data points when refit. If we see weight, init_score and group as properties of a dataset, then when refitting on a new dataset, it is very meaningful to allow new settings of these properties.

For example, a new ranking dataset can have totally different group.

@shiyu1994
Copy link
Collaborator

@TremaMiguel Thanks for working on this!

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the testing changes. Please see a few more suggestions I've provided.

python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much. Please see some additional suggestions to make the tests a bit stronger.

tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Show resolved Hide resolved
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks very much!

I've edited the PR description so it will be a bit more informative when it's used as a bullet point in the release notes.

Before this is merged, I'd like another Python maintainer like @jmoralez or @StrikerRUS to review.

@jameslamb jameslamb changed the title [python-package] refit support weights (fixes #3038) [python-package] support customizing Dataset creation in Booster.refit() (fixes #3038) Dec 29, 2021
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! Generally LGTM, just few minor fixes for the docstring.

python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
python-package/lightgbm/basic.py Show resolved Hide resolved
python-package/lightgbm/basic.py Show resolved Hide resolved
python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
python-package/lightgbm/basic.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
tests/python_package_test/test_engine.py Outdated Show resolved Hide resolved
@TremaMiguel
Copy link
Contributor Author

@StrikerRUS @jameslamb @jmoralez is there any pending change to close this PR?

@jmoralez jmoralez requested review from jmoralez and removed request for chivee January 15, 2022 18:16
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you so much for your contribution!

@StrikerRUS StrikerRUS merged commit e6a2f71 into microsoft:master Jan 22, 2022
@jameslamb jameslamb mentioned this pull request Oct 7, 2022
40 tasks
@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 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refit in Python does not support weights
5 participants