Skip to content

Commit f49ff09

Browse files
committed
Move functions for finding args to /man/rmd, redocument
1 parent d7b371b commit f49ff09

17 files changed

+91
-82
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export(boost_tree)
100100
export(check_empty_ellipse)
101101
export(check_final_param)
102102
export(control_parsnip)
103-
export(convert_args)
104103
export(convert_stan_interval)
105104
export(decision_tree)
106105
export(eval_args)

R/aaa.R

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,56 +30,6 @@ convert_stan_interval <- function(x, level = 0.95, lower = TRUE) {
3030
res
3131
}
3232

33-
#' Find args for documentation
34-
#' @rdname convert_args
35-
#' @keywords internal
36-
#' @export
37-
convert_args <- function(model_name) {
38-
envir <- get_model_env()
39-
40-
args <-
41-
ls(envir) %>%
42-
tibble::tibble(name = .) %>%
43-
dplyr::filter(grepl("args", name)) %>%
44-
dplyr::mutate(model = sub("_args", "", name),
45-
args = purrr::map(name, ~envir[[.x]])) %>%
46-
dplyr::filter(grepl(model_name, model)) %>%
47-
tidyr::unnest(args) %>%
48-
dplyr::select(model:original) %>%
49-
full_join(get_arg_defaults(model_name),
50-
by = c("model", "engine", "parsnip", "original")) %>%
51-
mutate(original = dplyr::if_else(!is.na(default),
52-
paste0(original, " (", default, ")"),
53-
original)) %>%
54-
select(-default)
55-
56-
convert_df <- args %>%
57-
dplyr::select(-model) %>%
58-
tidyr::pivot_wider(names_from = engine, values_from = original)
59-
60-
convert_df %>%
61-
knitr::kable(col.names = paste0("**", colnames(convert_df), "**"))
62-
63-
}
64-
65-
#' @rdname convert_args
66-
#' @keywords internal
67-
#' @export
68-
get_arg_defaults <- function(model) {
69-
check_model_exists(model)
70-
gdf <- get(paste0("get_defaults_", model))
71-
gdf()
72-
}
73-
74-
#' @rdname convert_args
75-
#' @keywords internal
76-
#' @export
77-
get_arg <- function(ns, f, arg) {
78-
args <- formals(getFromNamespace(f, ns))
79-
args <- as.list(args)
80-
as.character(args[[arg]])
81-
}
82-
8333
# ------------------------------------------------------------------------------
8434
# nocov
8535

man/boost_tree.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/convert_args.Rd

Lines changed: 0 additions & 18 deletions
This file was deleted.

man/rmd/boost-tree.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Engine Details
22

3+
```{r, child = "setup.Rmd", include = FALSE}
4+
```
5+
36
Engines may have pre-set default arguments when executing the model fit call. For this type of model, the template of the fit calls are below:
47

58
## xgboost
@@ -76,7 +79,7 @@ get_defaults_boost_tree <- function() {
7679
7780
)
7881
}
79-
parsnip::convert_args("boost_tree")
82+
convert_args("boost_tree")
8083
```
8184

8285
For spark, the default `mtry` is the square root of the number of predictors for classification, and one-third of the predictors for regression.

man/rmd/decision-tree.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Engine Details
22

3+
```{r, child = "setup.Rmd", include = FALSE}
4+
```
5+
36
Engines may have pre-set default arguments when executing the model fit call. For this type of model, the template of the fit calls are below:
47

58
## rpart
@@ -66,6 +69,6 @@ get_defaults_decision_tree <- function() {
6669
"decision_tree", "spark", "min_n", "min_instances_per_node", get_arg("sparklyr", "ml_decision_tree", "min_instances_per_node"),
6770
)
6871
}
69-
parsnip::convert_args("decision_tree")
72+
convert_args("decision_tree")
7073
```
7174

man/rmd/linear-reg.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Engine Details
22

3+
```{r, child = "setup.Rmd", include = FALSE}
4+
```
5+
36
Engines may have pre-set default arguments when executing the model fit call. For this type of model, the template of the fit calls are below.
47

58
## lm
@@ -82,6 +85,6 @@ get_defaults_linear_reg <- function() {
8285
"linear_reg", "keras", "penalty", "penalty", get_arg("parsnip", "keras_mlp", "penalty"),
8386
)
8487
}
85-
parsnip::convert_args("linear_reg")
88+
convert_args("linear_reg")
8689
```
8790

man/rmd/logistic-reg.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Engine Details
22

3+
```{r, child = "setup.Rmd", include = FALSE}
4+
```
5+
36
Engines may have pre-set default arguments when executing the model fit call.
47
For this type of model, the template of the fit calls are below.
58

@@ -83,6 +86,6 @@ get_defaults_logistic_reg <- function() {
8386
"logistic_reg", "keras", "penalty", "penalty", get_arg("parsnip", "keras_mlp", "penalty"),
8487
)
8588
}
86-
parsnip::convert_args("logistic_reg")
89+
convert_args("logistic_reg")
8790
```
8891

man/rmd/mars.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Engine Details
22

3+
```{r, child = "setup.Rmd", include = FALSE}
4+
```
5+
36
Engines may have pre-set default arguments when executing the model fit call.
47
For this type of model, the template of the fit calls are below.
58

@@ -37,6 +40,6 @@ get_defaults_mars <- function() {
3740
"mars", "earth", "prune_method", "pmethod", get_arg("earth", "earth.fit", "pmethod")[2]
3841
)
3942
}
40-
parsnip::convert_args("mars")
43+
convert_args("mars")
4144
```
4245

man/rmd/mlp.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Engine Details
22

3+
```{r, child = "setup.Rmd", include = FALSE}
4+
```
5+
36
Engines may have pre-set default arguments when executing the model fit call.
47
For this type of model, the template of the fit calls are below:
58

@@ -57,6 +60,6 @@ get_defaults_mlp <- function() {
5760
"mlp", "nnet", "epochs", "maxit", get_arg("nnet", "nnet.default", "maxit"),
5861
)
5962
}
60-
parsnip::convert_args("mlp")
63+
convert_args("mlp")
6164
```
6265

0 commit comments

Comments
 (0)