Skip to content

Commit b89c6f6

Browse files
committed
overdue examples for brulee
1 parent b6e5848 commit b89c6f6

File tree

2 files changed

+263
-6
lines changed

2 files changed

+263
-6
lines changed

DESCRIPTION

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
Package: parsnip
22
Title: A Common API to Modeling and Analysis Functions
3-
Version: 1.2.1.9004
3+
Version: 1.3.0
44
Authors@R: c(
55
person("Max", "Kuhn", , "[email protected]", role = c("aut", "cre")),
66
person("Davis", "Vaughan", , "[email protected]", role = "aut"),
77
person("Emil", "Hvitfeldt", , "[email protected]", role = "ctb"),
8-
person("Posit Software, PBC", role = c("cph", "fnd"), comment = c(ROR = "03wc8by49"))
8+
person("Posit Software, PBC", role = c("cph", "fnd"),
9+
comment = c(ROR = "03wc8by49"))
910
)
1011
Maintainer: Max Kuhn <[email protected]>
1112
Description: A common interface is provided to allow users to specify a
@@ -70,10 +71,10 @@ Suggests:
7071
VignetteBuilder:
7172
knitr
7273
ByteCompile: true
73-
Config/Needs/website: C50, dbarts, earth, glmnet, keras, kernlab, kknn,
74-
LiblineaR, mgcv, nnet, parsnip, quantreg, randomForest, ranger, rpart,
75-
rstanarm, tidymodels/tidymodels, tidyverse/tidytemplate, rstudio/reticulate,
76-
xgboost, rmarkdown
74+
Config/Needs/website: brulee, C50, dbarts, earth, glmnet, keras, kernlab,
75+
kknn, LiblineaR, mgcv, nnet, parsnip, quantreg, randomForest, ranger,
76+
rpart, rstanarm, tidymodels/tidymodels, tidyverse/tidytemplate,
77+
rstudio/reticulate, xgboost, rmarkdown
7778
Config/rcmdcheck/ignore-inconsequential-notes: true
7879
Config/testthat/edition: 3
7980
Encoding: UTF-8

vignettes/articles/Examples.Rmd

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,41 @@ The following examples use consistent data sets throughout. For regression, we u
631631
```
632632

633633
</details>
634+
635+
<details id="linear-reg-brulee">
636+
637+
<summary>With the `"brulee"` engine</summary>
638+
639+
<h3>Regression Example (`brulee`)</h3>
640+
641+
```{r echo=FALSE}
642+
knitr::spin_child("template-reg-chicago.R")
643+
```
644+
645+
We can define the model with specific parameters:
646+
647+
```{r}
648+
linreg_reg_spec <-
649+
linear_reg() %>%
650+
set_engine("brulee")
651+
linreg_reg_spec
652+
```
653+
654+
Now we create the model fit object:
655+
656+
```{r}
657+
set.seed(1)
658+
linreg_reg_fit <- linreg_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
659+
linreg_reg_fit
660+
```
661+
662+
The holdout data can be predicted:
663+
664+
```{r}
665+
predict(linreg_reg_fit, Chicago_test)
666+
```
667+
668+
</details>
634669

635670
## `logistic_reg()` models
636671

@@ -828,6 +863,45 @@ The following examples use consistent data sets throughout. For regression, we u
828863

829864
</details>
830865

866+
867+
<details id="logistic-reg-brulee">
868+
869+
<summary>With the `"brulee"` engine</summary>
870+
871+
<h3>Classification Example (`brulee`)</h3>
872+
873+
```{r echo=FALSE}
874+
knitr::spin_child("template-cls-two-class.R")
875+
```
876+
877+
We can define the model with specific parameters:
878+
879+
```{r}
880+
logreg_cls_spec <-
881+
logistic_reg() %>%
882+
set_engine("brulee")
883+
logreg_cls_spec
884+
```
885+
886+
Now we create the model fit object:
887+
888+
```{r}
889+
set.seed(1)
890+
logreg_cls_fit <- logreg_cls_spec %>% fit(Class ~ ., data = data_train)
891+
logreg_cls_fit
892+
```
893+
894+
The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
895+
896+
```{r}
897+
bind_cols(
898+
predict(logreg_cls_fit, data_test),
899+
predict(logreg_cls_fit, data_test, type = "prob")
900+
)
901+
```
902+
903+
</details>
904+
831905
## `mars()` models
832906

833907
<details id="mars-earth">
@@ -1047,6 +1121,149 @@ The following examples use consistent data sets throughout. For regression, we u
10471121

10481122
</details>
10491123

1124+
1125+
<details id="mlp-brulee">
1126+
1127+
<summary>With the `"brulee"` engine</summary>
1128+
1129+
<h3>Regression Example (`brulee`)</h3>
1130+
1131+
```{r echo=FALSE}
1132+
knitr::spin_child("template-reg-chicago.R")
1133+
```
1134+
1135+
We can define the model with specific parameters:
1136+
1137+
```{r}
1138+
mlp_reg_spec <-
1139+
mlp(penalty = 0, epochs = 100) %>%
1140+
# This model can be used for classification or regression, so set mode
1141+
set_mode("regression") %>%
1142+
set_engine("brulee")
1143+
mlp_reg_spec
1144+
```
1145+
1146+
Now we create the model fit object:
1147+
1148+
```{r}
1149+
set.seed(1)
1150+
mlp_reg_fit <- mlp_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
1151+
mlp_reg_fit
1152+
```
1153+
1154+
The holdout data can be predicted:
1155+
1156+
```{r}
1157+
predict(mlp_reg_fit, Chicago_test)
1158+
```
1159+
1160+
<h3>Classification Example (`brulee`)</h3>
1161+
1162+
```{r echo=FALSE}
1163+
knitr::spin_child("template-cls-two-class.R")
1164+
```
1165+
1166+
We can define the model with specific parameters:
1167+
1168+
```{r}
1169+
mlp_cls_spec <-
1170+
mlp(penalty = 0, epochs = 100) %>%
1171+
# This model can be used for classification or regression, so set mode
1172+
set_mode("classification") %>%
1173+
set_engine("brulee")
1174+
mlp_cls_spec
1175+
```
1176+
1177+
Now we create the model fit object:
1178+
1179+
```{r}
1180+
set.seed(1)
1181+
mlp_cls_fit <- mlp_cls_spec %>% fit(Class ~ ., data = data_train)
1182+
mlp_cls_fit
1183+
```
1184+
1185+
The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
1186+
1187+
```{r}
1188+
bind_cols(
1189+
predict(mlp_cls_fit, data_test),
1190+
predict(mlp_cls_fit, data_test, type = "prob")
1191+
)
1192+
```
1193+
1194+
</details>
1195+
1196+
<details id="mlp-brulee_two_layer_two_layer">
1197+
1198+
<summary>With the `"brulee_two_layer"` engine</summary>
1199+
1200+
<h3>Regression Example (`brulee_two_layer`)</h3>
1201+
1202+
```{r echo=FALSE}
1203+
knitr::spin_child("template-reg-chicago.R")
1204+
```
1205+
1206+
We can define the model with specific parameters:
1207+
1208+
```{r}
1209+
mlp_reg_spec <-
1210+
mlp(penalty = 0, epochs = 10) %>%
1211+
# This model can be used for classification or regression, so set mode
1212+
set_mode("regression") %>%
1213+
set_engine("brulee_two_layer", hidden_units_2 = 2)
1214+
mlp_reg_spec
1215+
```
1216+
1217+
Now we create the model fit object:
1218+
1219+
```{r}
1220+
set.seed(13)
1221+
mlp_reg_fit <- mlp_reg_spec %>% fit(ridership ~ ., data = Chicago_train)
1222+
mlp_reg_fit
1223+
```
1224+
1225+
The holdout data can be predicted:
1226+
1227+
```{r}
1228+
predict(mlp_reg_fit, Chicago_test)
1229+
```
1230+
1231+
<h3>Classification Example (`brulee_two_layer`)</h3>
1232+
1233+
```{r echo=FALSE}
1234+
knitr::spin_child("template-cls-two-class.R")
1235+
```
1236+
1237+
We can define the model with specific parameters:
1238+
1239+
```{r}
1240+
mlp_cls_spec <-
1241+
mlp(penalty = 0, epochs = 10) %>%
1242+
# This model can be used for classification or regression, so set mode
1243+
set_mode("classification") %>%
1244+
set_engine("brulee_two_layer", hidden_units_2 = 2)
1245+
mlp_cls_spec
1246+
```
1247+
1248+
Now we create the model fit object:
1249+
1250+
```{r}
1251+
set.seed(12)
1252+
mlp_cls_fit <- mlp_cls_spec %>% fit(Class ~ ., data = data_train)
1253+
mlp_cls_fit
1254+
```
1255+
1256+
The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
1257+
1258+
```{r}
1259+
bind_cols(
1260+
predict(mlp_cls_fit, data_test),
1261+
predict(mlp_cls_fit, data_test, type = "prob")
1262+
)
1263+
```
1264+
1265+
</details>
1266+
10501267

10511268
## `multinom_reg()` models
10521269

@@ -1167,6 +1384,45 @@ The following examples use consistent data sets throughout. For regression, we u
11671384
</details>
11681385

11691386

1387+
<details id="multinom-reg-brulee">
1388+
1389+
<summary>With the `"brulee"` engine</summary>
1390+
1391+
<h3>Classification Example (`brulee`)</h3>
1392+
1393+
```{r echo=FALSE}
1394+
knitr::spin_child("template-cls-multi-class.R")
1395+
```
1396+
1397+
We can define the model with specific parameters:
1398+
1399+
```{r}
1400+
mr_cls_spec <-
1401+
multinom_reg(penalty = 0.1) %>%
1402+
set_engine("brulee")
1403+
mr_cls_spec
1404+
```
1405+
1406+
Now we create the model fit object:
1407+
1408+
```{r}
1409+
set.seed(1)
1410+
mr_cls_fit <- mr_cls_spec %>% fit(island ~ ., data = penguins_train)
1411+
mr_cls_fit
1412+
```
1413+
1414+
The holdout data can be predicted for both hard class predictions and probabilities. We'll bind these together into one tibble:
1415+
1416+
```{r}
1417+
bind_cols(
1418+
predict(mr_cls_fit, penguins_test),
1419+
predict(mr_cls_fit, penguins_test, type = "prob")
1420+
)
1421+
```
1422+
1423+
</details>
1424+
1425+
11701426
## `nearest_neighbor()` models
11711427

11721428
<details id="nearest-neighbor-kknn">

0 commit comments

Comments
 (0)