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
enabled quantile regression in gbm #2603
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
962a038
enabled quantile regression in gbm
bthieurmel b8b2fe9
add requires quantile for alpha
bthieurmel f28c1f1
style guide
bthieurmel 25e8a74
mutualize
bthieurmel 55fc7c4
Rm quantile note
bthieurmel 9e9718b
Update NEWS
bthieurmel d48b9ee
gbm : add quantile test
bthieurmel 532d97a
add name + PR
bthieurmel cd91cd5
fix typo using weights (and so error on tests...)
bthieurmel 6bc9eac
Merge branch 'master' into gbm_quantile
pat-s 305e84a
space after if + simplify condition
bthieurmel 2f61177
Merge branch 'gbm_quantile' of github.com:datastorm-open/mlr into gbm…
bthieurmel 225f2f7
Merge branch 'master' into gbm_quantile
pat-s eae8827
Merge branch 'master' into gbm_quantile
pat-s File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ makeRLearner.regr.gbm = function() { | |
cl = "regr.gbm", | ||
package = "gbm", | ||
par.set = makeParamSet( | ||
makeDiscreteLearnerParam(id = "distribution", default = "gaussian", values = c("gaussian", "laplace", "poisson", "tdist")), | ||
makeDiscreteLearnerParam(id = "distribution", default = "gaussian", values = c("gaussian", "laplace", "poisson", "tdist", "quantile")), | ||
# FIXME default for distribution in gbm() is bernoulli | ||
makeIntegerLearnerParam(id = "n.trees", default = 100L, lower = 1L), | ||
makeIntegerLearnerParam(id = "cv.folds", default = 0L), | ||
|
@@ -13,6 +13,8 @@ makeRLearner.regr.gbm = function() { | |
makeNumericLearnerParam(id = "shrinkage", default = 0.001, lower = 0), | ||
makeNumericLearnerParam(id = "bag.fraction", default = 0.5, lower = 0, upper = 1), | ||
makeNumericLearnerParam(id = "train.fraction", default = 1, lower = 0, upper = 1), | ||
makeNumericLearnerParam(id = "alpha", default = 0.5, lower = 0, upper = 1, | ||
requires = quote(distribution == "quantile")), | ||
makeLogicalLearnerParam(id = "keep.data", default = TRUE, tunable = FALSE), | ||
makeLogicalLearnerParam(id = "verbose", default = FALSE, tunable = FALSE) | ||
), | ||
|
@@ -28,13 +30,25 @@ makeRLearner.regr.gbm = function() { | |
#' @export | ||
trainLearner.regr.gbm = function(.learner, .task, .subset, .weights = NULL, ...) { | ||
f = getTaskFormula(.task) | ||
if (is.null(.weights)) { | ||
f = getTaskFormula(.task) | ||
gbm::gbm(f, data = getTaskData(.task, .subset), ...) | ||
|
||
params = list(...) | ||
if("alpha" %in% names(params)) { | ||
alpha = params$alpha | ||
params$alpha = NULL | ||
} else { | ||
f = getTaskFormula(.task) | ||
gbm::gbm(f, data = getTaskData(.task, .subset), weights = .weights, ...) | ||
alpha = 0.5 | ||
} | ||
if(params$distribution %in% "quantile") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space after if and should that check be simply |
||
params$distribution = list(name = "quantile", alpha = alpha) | ||
} | ||
params$formula = f | ||
params$data = getTaskData(.task, .subset) | ||
|
||
if (!is.null(.weights)) { | ||
params$weights = .weights | ||
} | ||
|
||
do.call(gbm::gbm, params) | ||
} | ||
|
||
pat-s marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#' @export | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Space after if and I would check whether
params$alpha
isNULL
for consistency with how it's set below.