Skip to content

[python-package] support customizing Dataset creation in Booster.refit() (fixes #3038) - #4894

Merged
StrikerRUS merged 12 commits into
lightgbm-org:masterfrom
TremaMiguel:feat/refit_support_weights
Jan 22, 2022
Merged

StrikerRUS merged 12 commits into
lightgbm-org:masterfrom
TremaMiguel:feat/refit_support_weights

Conversation

@TremaMiguel

Copy link
Copy Markdown
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

ghost commented Dec 19, 2021 •

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

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.

Comment thread python-package/lightgbm/basic.py Resolved
@shiyu1994

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

@TremaMiguel Thanks for working on this!

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

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.

Comment thread python-package/lightgbm/basic.py Resolved

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

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.

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

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

@StrikerRUS StrikerRUS left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread python-package/lightgbm/basic.py Resolved
Comment thread python-package/lightgbm/basic.py Resolved
Comment thread python-package/lightgbm/basic.py Resolved
Comment thread python-package/lightgbm/basic.py Resolved
Comment thread python-package/lightgbm/basic.py Resolved
Comment thread python-package/lightgbm/basic.py Resolved
Comment thread python-package/lightgbm/basic.py Resolved
Comment thread python-package/lightgbm/basic.py Resolved
@TremaMiguel

Copy link
Copy Markdown
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

@StrikerRUS StrikerRUS left a comment

Copy link
Copy Markdown
Collaborator

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 lightgbm-org:master Jan 22, 2022
@jameslamb jameslamb mentioned this pull request Oct 7, 2022
39 of 40 tasks
@github-actions

Copy link
Copy Markdown
Contributor

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