Skip to content

Commit 8b73b3b

Browse files
authored
Merge pull request #272 from juliasilge/engine-specific-parameters
Tables for engine specific params in model docs
2 parents 670e75d + 63b6b5e commit 8b73b3b

27 files changed

+230
-9
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Imports:
3131
prettyunits,
3232
vctrs (>= 0.2.0)
3333
Roxygen: list(markdown = TRUE)
34-
RoxygenNote: 7.0.2.9000
34+
RoxygenNote: 7.1.0
3535
Suggests:
3636
testthat,
3737
knitr,

R/aaa.R

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ convert_stan_interval <- function(x, level = 0.95, lower = TRUE) {
2424
res
2525
}
2626

27+
convert_args <- function(model_name) {
28+
envir <- get_model_env()
29+
30+
args <-
31+
ls(envir) %>%
32+
tibble::tibble(name = .) %>%
33+
dplyr::filter(grepl("args", name)) %>%
34+
dplyr::mutate(model = sub("_args", "", name),
35+
args = purrr::map(name, ~envir[[.x]])) %>%
36+
tidyr::unnest(args) %>%
37+
dplyr::select(model:original)
38+
39+
convert_df <- args %>%
40+
dplyr::filter(grepl(model_name, model)) %>%
41+
dplyr::select(-model) %>%
42+
tidyr::pivot_wider(names_from = engine, values_from = original)
43+
44+
convert_df %>%
45+
knitr::kable(col.names = paste0("**", colnames(convert_df), "**"))
46+
47+
}
48+
49+
2750
# ------------------------------------------------------------------------------
2851
# nocov
2952

@@ -32,8 +55,8 @@ utils::globalVariables(
3255
c('.', '.label', '.pred', '.row', 'data', 'engine', 'engine2', 'group',
3356
'lab', 'original', 'predicted_label', 'prediction', 'value', 'type',
3457
"neighbors", ".submodels", "has_submodel", "max_neighbor", "max_penalty",
35-
"max_terms", "max_tree", "name", "num_terms", "penalty", "trees",
58+
"max_terms", "max_tree", "model", "name", "num_terms", "penalty", "trees",
3659
"sub_neighbors", ".pred_class")
37-
)
60+
)
3861

3962
# nocov end

R/boost_tree.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@
6161
#'
6262
#' @section Engine Details:
6363
#'
64+
#' The standardized parameter names in parsnip can be mapped to their original
65+
#' names in each engine:
66+
#'
67+
#' ```{r echo = FALSE}
68+
#' convert_args("boost_tree")
69+
#' ```
70+
#'
6471
#' Engines may have pre-set default arguments when executing the
6572
#' model fit call. For this type of model, the template of the
6673
#' fit calls are:

R/decision_tree.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
#'
4747
#' @section Engine Details:
4848
#'
49+
#' The standardized parameter names in parsnip can be mapped to their original
50+
#' names in each engine:
51+
#'
52+
#' ```{r echo = FALSE}
53+
#' convert_args("decision_tree")
54+
#' ```
55+
#'
4956
#' Engines may have pre-set default arguments when executing the
5057
#' model fit call. For this type of
5158
#' model, the template of the fit calls are::

R/linear_reg.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@
4444
#'
4545
#' @section Engine Details:
4646
#'
47+
#' The standardized parameter names in parsnip can be mapped to their original
48+
#' names in each engine:
49+
#'
50+
#' ```{r echo = FALSE}
51+
#' convert_args("linear_reg")
52+
#' ```
53+
#'
4754
#' Engines may have pre-set default arguments when executing the
4855
#' model fit call. For this type of
4956
#' model, the template of the fit calls are:

R/logistic_reg.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
#'
4343
#' @section Engine Details:
4444
#'
45+
#' The standardized parameter names in parsnip can be mapped to their original
46+
#' names in each engine:
47+
#'
48+
#' ```{r echo = FALSE}
49+
#' convert_args("logistic_reg")
50+
#' ```
51+
#'
4552
#' Engines may have pre-set default arguments when executing the
4653
#' model fit call. For this type of
4754
#' model, the template of the fit calls are:

R/mars.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
#'
3939
#' @section Engine Details:
4040
#'
41+
#' The standardized parameter names in parsnip can be mapped to their original
42+
#' names in each engine:
43+
#'
44+
#' ```{r echo = FALSE}
45+
#' convert_args("mars")
46+
#' ```
47+
#'
4148
#' Engines may have pre-set default arguments when executing the
4249
#' model fit call. For this type of
4350
#' model, the template of the fit calls are:

R/mlp.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@
5656
#'
5757
#' @section Engine Details:
5858
#'
59+
#' The standardized parameter names in parsnip can be mapped to their original
60+
#' names in each engine:
61+
#'
62+
#' ```{r echo = FALSE}
63+
#' convert_args("mlp")
64+
#' ```
65+
#'
5966
#' Engines may have pre-set default arguments when executing the
6067
#' model fit call. For this type of
6168
#' model, the template of the fit calls are:

R/multinom_reg.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
#'
4242
#' @section Engine Details:
4343
#'
44+
#' The standardized parameter names in parsnip can be mapped to their original
45+
#' names in each engine:
46+
#'
47+
#' ```{r echo = FALSE}
48+
#' convert_args("multinom_reg")
49+
#' ```
50+
#'
4451
#' Engines may have pre-set default arguments when executing the
4552
#' model fit call. For this type of
4653
#' model, the template of the fit calls are:

R/nearest_neighbor.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
#'
4949
#' @section Engine Details:
5050
#'
51+
#' The standardized parameter names in parsnip can be mapped to their original
52+
#' names in each engine:
53+
#'
54+
#' ```{r echo = FALSE}
55+
#' convert_args("nearest_neighbor")
56+
#' ```
57+
#'
5158
#' Engines may have pre-set default arguments when executing the
5259
#' model fit call. For this type of
5360
#' model, the template of the fit calls are:

R/rand_forest.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
#'
4141
#' @section Engine Details:
4242
#'
43+
#' The standardized parameter names in parsnip can be mapped to their original
44+
#' names in each engine:
45+
#'
46+
#' ```{r echo = FALSE}
47+
#' convert_args("rand_forest")
48+
#' ```
49+
#'
4350
#' Engines may have pre-set default arguments when executing the
4451
#' model fit call. For this type of
4552
#' model, the template of the fit calls are::

R/surv_reg.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
#'
4242
#' @section Engine Details:
4343
#'
44+
#' The standardized parameter names in parsnip can be mapped to their original
45+
#' names in each engine:
46+
#'
47+
#' ```{r echo = FALSE}
48+
#' convert_args("surv_reg")
49+
#' ```
50+
#'
4451
#' Engines may have pre-set default arguments when executing the
4552
#' model fit call. For this type of
4653
#' model, the template of the fit calls are:

R/svm_poly.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
#'
3939
#' @section Engine Details:
4040
#'
41+
#' The standardized parameter names in parsnip can be mapped to their original
42+
#' names in each engine:
43+
#'
44+
#' ```{r echo = FALSE}
45+
#' convert_args("svm_poly")
46+
#' ```
47+
#'
4148
#' Engines may have pre-set default arguments when executing the
4249
#' model fit call. For this type of
4350
#' model, the template of the fit calls are::

R/svm_rbf.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
#'
3838
#' @section Engine Details:
3939
#'
40+
#' The standardized parameter names in parsnip can be mapped to their original
41+
#' names in each engine:
42+
#'
43+
#' ```{r echo = FALSE}
44+
#' convert_args("svm_rbf")
45+
#' ```
46+
#'
4047
#' Engines may have pre-set default arguments when executing the
4148
#' model fit call. For this type of
4249
#' model, the template of the fit calls are::

man/boost_tree.Rd

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/decision_tree.Rd

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/linear_reg.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/logistic_reg.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mars.Rd

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlp.Rd

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/multinom_reg.Rd

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/nearest_neighbor.Rd

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rand_forest.Rd

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/surv_reg.Rd

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/svm_poly.Rd

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)