-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add quantile regression mode (#1209)
* add a quantile regression mode to test with * update type checkers * avoid confusion with global all_models object * add quantile_level argument to set_mode() * initial data for quantreg * some initial tests * fix some issues * enable quantile prediction * tests for quantreg * Quantile predictions output constructor (#1191) * small change to predict checks * add vctrs for quantiles and test, refactor *_rq_preds * revise tests * Apply some of the suggestions from code review Co-authored-by: Simon P. Couch <[email protected]> * rename tests on suggestion from code review * export missing funs from vctrs for formatting * convert errors to snapshot tests * pass call through input check * update snapshots for caller_env * rename to parsnip_quantiles, add format snapshot tests * Apply suggestions from @topepo Co-authored-by: Max Kuhn <[email protected]> * rename parsnip_quantiles to quantile_pred * rename parsnip_quantiles to quantile_pred and add vector probability check * fix: two bugs introduced earlier * add formatting tests for single quantile * replace walk with a loop to avoid "Error in map()" * remove row/col names * adjust quantile_pred format * as_tibble method * updated NEWS file * add PR number * small new update * helper methods * update docs * re-enable quantiles prediction for #1203 * update some tests * no longer needed * use tibble::new_tibble * braces * test as_tibble * remove print methods --------- Co-authored-by: Simon P. Couch <[email protected]> Co-authored-by: Max Kuhn <[email protected]> Co-authored-by: ‘topepo’ <‘[email protected]’> * quantile regression updates for new hardhat model (#1207) * bump hardhat version * remove parts now in hardhat * update for new hardhat version * quantile_levels (plural now) * news update * typo * rename helper function * run CI on PRs from branches * forgotten remote * actions for edited PRs * plural * expand branch list * export function for censored to use * updated snapshot * remake snapshot * Revert "remake snapshot" This reverts commit 954e326. * updated snapshot * Update R/arguments.R Co-authored-by: Hannah Frick <[email protected]> * typo * changes from reviewer feedback --------- Co-authored-by: ‘topepo’ <‘[email protected]’> Co-authored-by: Hannah Frick <[email protected]> * Change to `quantile` argument to `quantile levels` (#1208) * quantile -> quantile_levels for #1203 * defer test until censored updates in new PR * update docs for quantile_levels * update test * disable quantile predictions for surv_reg --------- Co-authored-by: ‘topepo’ <‘[email protected]’> * post conflict merge updates * update news * version bump and fix typo * revert GHA branches * small bug fix * Apply suggestions from code review Co-authored-by: Hannah Frick <[email protected]> Co-authored-by: Emil Hvitfeldt <[email protected]> * don't export median * add call arg * added documentation on model * add mode * convert error to warning * remove rankdeficient * added skip * add deprecated `quantile` arg back in * remove numeric prediction --------- Co-authored-by: ‘topepo’ <‘[email protected]’> Co-authored-by: Daniel McDonald <[email protected]> Co-authored-by: Simon P. Couch <[email protected]> Co-authored-by: Hannah Frick <[email protected]> Co-authored-by: Emil Hvitfeldt <[email protected]>
- Loading branch information
1 parent
5ce414e
commit 297320e
Showing
35 changed files
with
906 additions
and
108 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: parsnip | ||
Title: A Common API to Modeling and Analysis Functions | ||
Version: 1.2.1.9002 | ||
Version: 1.2.1.9003 | ||
Authors@R: c( | ||
person("Max", "Kuhn", , "[email protected]", role = c("aut", "cre")), | ||
person("Davis", "Vaughan", , "[email protected]", role = "aut"), | ||
|
@@ -25,7 +25,7 @@ Imports: | |
ggplot2, | ||
globals, | ||
glue, | ||
hardhat (>= 1.4.0), | ||
hardhat (>= 1.4.0.9002), | ||
lifecycle, | ||
magrittr, | ||
pillar, | ||
|
@@ -40,8 +40,8 @@ Imports: | |
vctrs (>= 0.6.0), | ||
withr | ||
Suggests: | ||
C50, | ||
bench, | ||
C50, | ||
covr, | ||
dials (>= 1.1.0), | ||
earth, | ||
|
@@ -69,16 +69,17 @@ Suggests: | |
xgboost (>= 1.5.0.1) | ||
VignetteBuilder: | ||
knitr | ||
Remotes: | ||
r-lib/sparsevctrs, | ||
tidymodels/hardhat | ||
ByteCompile: true | ||
Config/Needs/website: C50, dbarts, earth, glmnet, keras, kernlab, kknn, | ||
LiblineaR, mgcv, nnet, parsnip, randomForest, ranger, rpart, rstanarm, | ||
tidymodels/tidymodels, tidyverse/tidytemplate, rstudio/reticulate, | ||
LiblineaR, mgcv, nnet, parsnip, quantreg, randomForest, ranger, rpart, | ||
rstanarm, tidymodels/tidymodels, tidyverse/tidytemplate, rstudio/reticulate, | ||
xgboost | ||
Config/rcmdcheck/ignore-inconsequential-notes: true | ||
Config/testthat/edition: 3 | ||
Encoding: UTF-8 | ||
LazyData: true | ||
Roxygen: list(markdown = TRUE) | ||
Remotes: | ||
r-lib/sparsevctrs | ||
RoxygenNote: 7.3.2 |
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
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#' Reformat quantile predictions | ||
#' | ||
#' @param x A matrix of predictions with rows as samples and columns as quantile | ||
#' levels. | ||
#' @param object A parsnip `model_fit` object from a quantile regression model. | ||
#' @keywords internal | ||
#' @export | ||
matrix_to_quantile_pred <- function(x, object) { | ||
if (!is.matrix(x)) { | ||
x <- as.matrix(x) | ||
} | ||
rownames(x) <- NULL | ||
n_pred_quantiles <- ncol(x) | ||
quantile_levels <- object$spec$quantile_levels | ||
|
||
tibble::new_tibble(x = list(.pred_quantile = hardhat::quantile_pred(x, quantile_levels))) | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#' Linear quantile regression via the quantreg package | ||
#' | ||
#' [quantreg::rq()] optimizes quantile loss to fit models with numeric outcomes. | ||
#' | ||
#' @includeRmd man/rmd/linear_reg_quantreg.md details | ||
#' | ||
#' @name details_linear_reg_quantreg | ||
#' @keywords internal | ||
NULL | ||
|
||
# See inst/README-DOCS.md for a description of how these files are processed |
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
Oops, something went wrong.