-
-
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
Use new predict function for R. #6819
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6819 +/- ##
==========================================
- Coverage 81.72% 81.71% -0.01%
==========================================
Files 13 13
Lines 3917 3916 -1
==========================================
- Hits 3201 3200 -1
Misses 716 716
Continue to review full report at Codecov.
|
R-package/R/xgb.Booster.R
Outdated
#' @param iterationrange Specifies which layer of trees are used in prediction. For example, if a | ||
#' random forest is trained with 100 rounds. Specifying `iteration_range=(0, | ||
#' 20)`, then only the forests built during [0, 20) (half open set) rounds are | ||
#' used in this prediction. It's 0 based index (unlike R vector). |
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.
Should we use 0-based index here?
@jameslamb What's the convention for R packages that wrap native code? Do users expect to use 1-based indexing?
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.
Also, please add a note that iteration_range=(0,0)
indicates the use of all trees.
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.
In general, I'm in favor of parameters like this being 1-based and having the documentation clearly indicate that. I think that's more friendly for R users.
But, to be fair, in {lightgbm}
we have not been very consistent about this. Keyword arguments in the package's interface expect 1-based values, but {lightgbm}
won't look inside parameters passed through a list params
and subtract 1 from any parameters that are indices.
So I think that there is not really a "right" answer to this, and that it's more important to:
- be consistent (as much as possible)
- over-communicate in the documentation (always say whether it is 1-based or 0-based)
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.
I will try to use 1 based index.
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.
Changed to use 1-based index. Thanks for the suggestions!
I recently found a segfault in version 1.4.1.1 of the R package when providing |
@Kodiologist Did you test it? I think I have error tests in Python with model slicing, but not 100 percent sure about R error handling. |
No, not with anything newer than 1.4.1.1. |
This is an early PR so I can get some suggestions from R experts. The primary change in R interface is the use of
iterationrange
and deprecation ofntreelimit
.TODOs:
ntreelimit
in internal code base.iterationrange
andstrict_shape
.best_iteration
.