-
Notifications
You must be signed in to change notification settings - Fork 88
/
mlp_nnet.Rmd
84 lines (56 loc) · 1.79 KB
/
mlp_nnet.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
```{r, child = "aaa.Rmd", include = FALSE}
```
`r descr_models("mlp", "nnet")`
## Tuning Parameters
```{r nnet-param-info, echo = FALSE}
defaults <-
tibble::tibble(parsnip = c("hidden_units", "penalty", "epochs"),
default = c("none", "0.0", "100L"))
param <-
mlp() %>%
set_engine("nnet") %>%
make_parameter_list(defaults)
```
This model has `r nrow(param)` tuning parameters:
```{r nnet-param-list, echo = FALSE, results = "asis"}
param$item
```
Note that, in [nnet::nnet()], the maximum number of parameters is an argument with a fairly low value of `maxit = 1000`. For some models, you may need to pass this value in via [set_engine()] so that the model does not fail.
## Translation from parsnip to the original package (regression)
```{r nnet-reg}
mlp(
hidden_units = integer(1),
penalty = double(1),
epochs = integer(1)
) %>%
set_engine("nnet") %>%
set_mode("regression") %>%
translate()
```
Note that parsnip automatically sets linear activation in the last layer.
## Translation from parsnip to the original package (classification)
```{r nnet-cls}
mlp(
hidden_units = integer(1),
penalty = double(1),
epochs = integer(1)
) %>%
set_engine("nnet") %>%
set_mode("classification") %>%
translate()
```
## Preprocessing requirements
```{r child = "template-makes-dummies.Rmd"}
```
```{r child = "template-same-scale.Rmd"}
```
## Case weights
```{r child = "template-no-case-weights.Rmd"}
```
## Saving fitted model objects
```{r child = "template-butcher.Rmd"}
```
## Examples
The "Fitting and Predicting with parsnip" article contains [examples](https://parsnip.tidymodels.org/articles/articles/Examples.html#mlp-nnet) for `mlp()` with the `"nnet"` engine.
## References
- Kuhn, M, and K Johnson. 2013. _Applied Predictive Modeling_. Springer.