-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
[R] Document handling of indexes #10019
Conversation
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.
Thank you for writing the document, I think this would be useful to users as well instead of being contributors only.
doc/contrib/coding_guide.rst
Outdated
- Categorical features are defined in R as a ``factor`` type which encodes with base-1 indexing. When categorical features are passed as R ``factor`` types, the conversion is done automatically to base-0 indexing, but if the user whishes to manually supply categorical features as already-encoded integers, then those integers need to already be in base-0 encoding. | ||
- Categorical labels for DMatrices do not undergo any extra processing - the user must supply base-0 encoded labels. | ||
- A function to retrieve class-specific coefficients when using the linear coefficients history callback takes a class index parameter, which also does not undergo any conversion (i.e. user must pass a base-0 index), in order to match with the label logic - that is, the same class index will refer to the class encoded with that number in the DMatrix ``label`` field. | ||
|
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.
How about evaluation output:
[0]: rmse ...
[1]: rmse ...
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.
Added.
doc/contrib/coding_guide.rst
Outdated
- Categorical labels for DMatrices do not undergo any extra processing - the user must supply base-0 encoded labels. | ||
- A function to retrieve class-specific coefficients when using the linear coefficients history callback takes a class index parameter, which also does not undergo any conversion (i.e. user must pass a base-0 index), in order to match with the label logic - that is, the same class index will refer to the class encoded with that number in the DMatrix ``label`` field. | ||
|
||
New additions to the R interface that take on indexable elements should be mindful of these conventions and try to mimic R's behavior as much as possible. |
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.
How about the feature index from the tree plot and JSON model? I think for the JSON model, the output will continue to be 0-based, not sure about what to do with the plot. In addition, the categorical features in tree dump and plot.
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.
Added, alongside with other cases that were missing.
Co-authored-by: Jiaming Yuan <jm.yuan@outlook.com>
Do you suggest to move this to some other file? |
Yes, perhaps somewhere as part of the R document like a vignette since it's quite R-specific; otherwise, creating a new file like |
Moved it to a new file under Also added a few notes about base-0 encodings in the DMatrix docs. |
@trivialfis @hcho3 Looks like the docs didn't render correctly, and didn't include this page in the index. I am not familiar with RST format. Could you look into it? |
I will look into it tomorrow night. |
@trivialfis I am looking at this now. |
@david-cortes #10030 should fix the doc. |
ref #9810
This PR adds some notes about handling of index numbers in R, as requested in previous comment.