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

[docs] document how to pass multi-value params from Python and R (fixes #4345) #4346

Merged
merged 5 commits into from
Jun 9, 2021

Conversation

jameslamb
Copy link
Collaborator

Fixed #4345

The documentation for monotone_constraints does not currently describe the expected data format for that parameter in the Python and R packages.

Changes in this PR:

  • adds documentation notes that [-1, 0, 1] is valid in the Python package and c(-1, 0, 1) is valid in the R package
  • adds R tests based on these tests in the Python package (to be sure the documentation changes proposed here are correct)

def test_monotone_constraints(test_with_interaction_constraints):

Notes for Reviewers

This PR is still a work in progress. Will finish getting the tests working before asking for reviews.

docs/Parameters.rst Outdated Show resolved Hide resolved
docs/Parameters.rst Outdated Show resolved Hide resolved
include/LightGBM/config.h Outdated Show resolved Hide resolved
@@ -471,6 +471,9 @@ struct Config {
// desc = used for constraints of monotonic features
// desc = ``1`` means increasing, ``-1`` means decreasing, ``0`` means non-constraint
// desc = you need to specify all features in order. For example, ``mc=-1,0,1`` means decreasing for 1st feature, non-constraint for 2nd feature and increasing for the 3rd feature
// desc = in the CLI or C++, use a string like ``"-1,0,1"``
// desc = in the Python package, can use either a string or a list like ``[-1, 0, 1]``
// desc = in the R package, can use either a string or a vector like ``c(-1, 0, 1)``
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// desc = in the R package, can use either a string or a vector like ``c(-1, 0, 1)``
// desc = in the R package, can use either a string as in the CLI or a vector like ``c(-1, 0, 1)``

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

based on #4346 (comment), I think we're going to add general documentation on the fact that you can use a list in Python / vector in R, instead of specifically adding notes like this on each parameter. So I've reverted the changes to the specific monotone_constraints docs.

@@ -514,6 +514,12 @@ Learning Control Parameters

- you need to specify all features in order. For example, ``mc=-1,0,1`` means decreasing for 1st feature, non-constraint for 2nd feature and increasing for the 3rd feature

- in the CLI or C++, use a string like ``"-1,0,1"``

- in the Python package, can use either a string or a list like ``[-1, 0, 1]``
Copy link
Collaborator

@StrikerRUS StrikerRUS Jun 7, 2021

Choose a reason for hiding this comment

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

@jameslamb I'd like to keep this important doc in a consistent state. Changes proposed in this this PR are actually applicable for any multi-***-type parameter. We have a lot of such params, e.g. max_bin_by_feature , cegb_penalty_feature_lazy, cegb_penalty_feature_coupled, categorical_feature, label_gain, etc. I think it will be better to write a separate paragraph about how multi-*** params can be passed to a program, if you think there should be some clarification for this.

Also, I'm against documenting internal string format for language wrappers. Actually, all params are passed via a string internally.
#4101 (comment)
I don't think we should expose this and it's better to encourage users to use native language structures to pass params.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, I agree with both of these points. I'll split the unit tests part of this into a separate PR.

if you think there should be some clarification for this.

I definitely do. If an expert LightGBM user like @mayer79 wasn't aware (#4345 (comment)) then I think many others will be unaware or will spend time trying to figure it out from unit tests / example code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I've changed this to just document the concept generally. I think it's ready for review.

image

@jameslamb jameslamb changed the title WIP: [R-package] add docs and tests on monotone constraints (fixes #4345) [docs] document how to pass multi-value params from Python and R fixes #4345) Jun 8, 2021
@jameslamb jameslamb added doc and removed maintenance labels Jun 8, 2021
@jameslamb jameslamb marked this pull request as ready for review June 8, 2021 01:43
@jameslamb jameslamb requested a review from StrikerRUS June 8, 2021 01:44
docs/Parameters.rst Outdated Show resolved Hide resolved
Co-authored-by: Nikita Titov <[email protected]>
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 a lot, very clear description!

@StrikerRUS StrikerRUS merged commit 24ac920 into master Jun 9, 2021
@StrikerRUS StrikerRUS deleted the docs/monotone-constraints branch June 9, 2021 17:08
@jameslamb jameslamb changed the title [docs] document how to pass multi-value params from Python and R fixes #4345) [docs] document how to pass multi-value params from Python and R (fixes #4345) Jun 9, 2021
@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.

Clarify how to specify monotonic constraints in docu
3 participants