Skip to content

Commit d83e78f

Browse files
committed
document remainder of bonsai engines, translate bug fix
1 parent 06d6f75 commit d83e78f

7 files changed

+294
-1
lines changed

R/translate.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ deharmonize <- function(args, key) {
166166
merged <-
167167
dplyr::left_join(parsn, key, by = "parsnip") %>%
168168
dplyr::arrange(order)
169-
# TODO correct for bad merge?
169+
170+
merged <- merged[!duplicated(merged$order),]
170171

171172
names(args) <- merged$original
172173
args[!is.na(merged$original)]

man/rmd/boost_tree_lightgbm.Rmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ The "Introduction to bonsai" article contains [examples](https://github.com/tidy
8181
## References
8282

8383
- [LightGBM: A Highly Efficient Gradient Boosting Decision Tree](https://papers.nips.cc/paper/2017/hash/6449f44a102fde848669bdd9eb6b76fa-Abstract.html)
84+
85+
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.

man/rmd/boost_tree_lightgbm.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,5 @@ The "Introduction to bonsai" article contains [examples](https://github.com/tidy
120120
## References
121121

122122
- [LightGBM: A Highly Efficient Gradient Boosting Decision Tree](https://papers.nips.cc/paper/2017/hash/6449f44a102fde848669bdd9eb6b76fa-Abstract.html)
123+
124+
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.

man/rmd/decision_tree_partykit.Rmd

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
```{r, child = "aaa.Rmd", include = FALSE}
2+
```
3+
4+
`r descr_models("decision_tree", "partykit")`
5+
6+
## Tuning Parameters
7+
8+
```{r partykit-param-info, echo = FALSE}
9+
defaults <-
10+
tibble::tibble(parsnip = c("tree_depth", "min_n"),
11+
default = c("see below", "20L"))
12+
13+
param <-
14+
decision_tree() %>%
15+
set_engine("partykit") %>%
16+
set_mode("regression") %>%
17+
make_parameter_list(defaults)
18+
```
19+
20+
This model has `r nrow(param)` tuning parameters:
21+
22+
```{r partykit-param-list, echo = FALSE, results = "asis"}
23+
param$item
24+
```
25+
26+
The `tree_depth` parameter defaults to `0` which means no restrictions are applied to tree depth.
27+
28+
An engine-specific parameter for this model is:
29+
30+
* `mtry`: the number of predictors, selected at random, that are evaluated for splitting. The default is to use all predictors.
31+
32+
## Translation from parsnip to the original package (regression)
33+
34+
`r uses_extension("decision_tree", "partykit", "regression")`
35+
36+
```{r partykit-creg}
37+
decision_tree(tree_depth = integer(1), min_n = integer(1)) %>%
38+
set_engine("partykit") %>%
39+
set_mode("regression") %>%
40+
translate()
41+
```
42+
43+
## Translation from parsnip to the original package (classification)
44+
45+
`r uses_extension("decision_tree", "partykit", "classification")`
46+
47+
```{r partykit-class}
48+
decision_tree(tree_depth = integer(1), min_n = integer(1)) %>%
49+
set_engine("partykit") %>%
50+
set_mode("classification") %>%
51+
translate()
52+
```
53+
54+
`parsnip::ctree_train()` is a wrapper around [partykit::ctree()] (and other functions) that makes it easier to run this model.
55+
56+
## Preprocessing requirements
57+
58+
```{r child = "template-tree-split-factors.Rmd"}
59+
```
60+
61+
## References
62+
63+
- [partykit: A Modular Toolkit for Recursive Partytioning in R](https://jmlr.org/papers/v16/hothorn15a.html)
64+
65+
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.

man/rmd/decision_tree_partykit.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
3+
4+
For this engine, there are multiple modes: censored regression, regression, and classification
5+
6+
## Tuning Parameters
7+
8+
9+
10+
This model has 3 tuning parameters:
11+
12+
- `tree_depth`: Tree Depth (type: integer, default: see below)
13+
14+
- `min_n`: Minimal Node Size (type: integer, default: 20L)
15+
16+
- `min_n`: Minimal Node Size (type: integer, default: 20L)
17+
18+
The `tree_depth` parameter defaults to `0` which means no restrictions are applied to tree depth.
19+
20+
An engine-specific parameter for this model is:
21+
22+
* `mtry`: the number of predictors, selected at random, that are evaluated for splitting. The default is to use all predictors.
23+
24+
## Translation from parsnip to the original package (regression)
25+
26+
27+
28+
29+
```r
30+
decision_tree(tree_depth = integer(1), min_n = integer(1)) %>%
31+
set_engine("partykit") %>%
32+
set_mode("regression") %>%
33+
translate()
34+
```
35+
36+
```
37+
## Decision Tree Model Specification (regression)
38+
##
39+
## Main Arguments:
40+
## tree_depth = integer(1)
41+
## min_n = integer(1)
42+
##
43+
## Computational engine: partykit
44+
##
45+
## Model fit template:
46+
## parsnip::ctree_train(formula = missing_arg(), data = missing_arg(),
47+
## weights = missing_arg(), maxdepth = integer(1), minsplit = min_rows(0L,
48+
## data))
49+
```
50+
51+
## Translation from parsnip to the original package (classification)
52+
53+
54+
55+
56+
```r
57+
decision_tree(tree_depth = integer(1), min_n = integer(1)) %>%
58+
set_engine("partykit") %>%
59+
set_mode("classification") %>%
60+
translate()
61+
```
62+
63+
```
64+
## Decision Tree Model Specification (classification)
65+
##
66+
## Main Arguments:
67+
## tree_depth = integer(1)
68+
## min_n = integer(1)
69+
##
70+
## Computational engine: partykit
71+
##
72+
## Model fit template:
73+
## parsnip::ctree_train(formula = missing_arg(), data = missing_arg(),
74+
## weights = missing_arg(), maxdepth = integer(1), minsplit = min_rows(0L,
75+
## data))
76+
```
77+
78+
`parsnip::ctree_train()` is a wrapper around [partykit::ctree()] (and other functions) that makes it easier to run this model.
79+
80+
## Preprocessing requirements
81+
82+
83+
This engine does not require any special encoding of the predictors. Categorical predictors can be partitioned into groups of factor levels (e.g. `{a, c}` vs `{b, d}`) when splitting at a node. Dummy variables are not required for this model.
84+
85+
## References
86+
87+
- [partykit: A Modular Toolkit for Recursive Partytioning in R](https://jmlr.org/papers/v16/hothorn15a.html)
88+
89+
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.

man/rmd/rand_forest_partykit.Rmd

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
```{r, child = "aaa.Rmd", include = FALSE}
2+
```
3+
4+
`r descr_models("rand_forest", "partykit")`
5+
6+
## Tuning Parameters
7+
8+
```{r partykit-param-info, echo = FALSE}
9+
defaults <-
10+
tibble::tibble(parsnip = c("trees", "min_n", "mtry"),
11+
default = c("500L", "20L", "5L"))
12+
13+
param <-
14+
rand_forest() %>%
15+
set_engine("partykit") %>%
16+
set_mode("regression") %>%
17+
make_parameter_list(defaults)
18+
```
19+
20+
This model has `r nrow(param)` tuning parameters:
21+
22+
```{r partykit-param-list, echo = FALSE, results = "asis"}
23+
param$item
24+
```
25+
26+
## Translation from parsnip to the original package (regression)
27+
28+
`r uses_extension("rand_forest", "partykit", "regression")`
29+
30+
```{r partykit-creg}
31+
rand_forest() %>%
32+
set_engine("partykit") %>%
33+
set_mode("regression") %>%
34+
translate()
35+
```
36+
37+
## Translation from parsnip to the original package (classification)
38+
39+
`r uses_extension("rand_forest", "partykit", "classification")`
40+
41+
```{r partykit-class}
42+
rand_forest() %>%
43+
set_engine("partykit") %>%
44+
set_mode("classification") %>%
45+
translate()
46+
```
47+
48+
`parsnip::cforest_train()` is a wrapper around [partykit::cforest()] (and other functions) that makes it easier to run this model.
49+
50+
## Preprocessing requirements
51+
52+
```{r child = "template-tree-split-factors.Rmd"}
53+
```
54+
55+
## References
56+
57+
- [partykit: A Modular Toolkit for Recursive Partytioning in R](https://jmlr.org/papers/v16/hothorn15a.html)
58+
59+
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.

man/rmd/rand_forest_partykit.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
3+
4+
For this engine, there are multiple modes: censored regression, regression, and classification
5+
6+
## Tuning Parameters
7+
8+
9+
10+
This model has 4 tuning parameters:
11+
12+
- `trees`: # Trees (type: integer, default: 500L)
13+
14+
- `min_n`: Minimal Node Size (type: integer, default: 20L)
15+
16+
- `mtry`: # Randomly Selected Predictors (type: integer, default: 5L)
17+
18+
- `min_n`: Minimal Node Size (type: integer, default: 20L)
19+
20+
## Translation from parsnip to the original package (regression)
21+
22+
23+
24+
25+
```r
26+
rand_forest() %>%
27+
set_engine("partykit") %>%
28+
set_mode("regression") %>%
29+
translate()
30+
```
31+
32+
```
33+
## Random Forest Model Specification (regression)
34+
##
35+
## Computational engine: partykit
36+
##
37+
## Model fit template:
38+
## parsnip::cforest_train(formula = missing_arg(), data = missing_arg(),
39+
## weights = missing_arg())
40+
```
41+
42+
## Translation from parsnip to the original package (classification)
43+
44+
45+
46+
47+
```r
48+
rand_forest() %>%
49+
set_engine("partykit") %>%
50+
set_mode("classification") %>%
51+
translate()
52+
```
53+
54+
```
55+
## Random Forest Model Specification (classification)
56+
##
57+
## Computational engine: partykit
58+
##
59+
## Model fit template:
60+
## parsnip::cforest_train(formula = missing_arg(), data = missing_arg(),
61+
## weights = missing_arg())
62+
```
63+
64+
`parsnip::cforest_train()` is a wrapper around [partykit::cforest()] (and other functions) that makes it easier to run this model.
65+
66+
## Preprocessing requirements
67+
68+
69+
This engine does not require any special encoding of the predictors. Categorical predictors can be partitioned into groups of factor levels (e.g. `{a, c}` vs `{b, d}`) when splitting at a node. Dummy variables are not required for this model.
70+
71+
## References
72+
73+
- [partykit: A Modular Toolkit for Recursive Partytioning in R](https://jmlr.org/papers/v16/hothorn15a.html)
74+
75+
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.

0 commit comments

Comments
 (0)