#| child: aaa.Rmd
#| include: false

r descr_models("mlp", "nnet")

Tuning Parameters

#| label: 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:

#| label: 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)

#| label: 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)

#| label: nnet-cls
mlp(
  hidden_units = integer(1),
  penalty = double(1),
  epochs = integer(1)
) |> 
  set_engine("nnet") |> 
  set_mode("classification") |> 
  translate()

Preprocessing requirements

#| child: template-makes-dummies.Rmd
#| child: template-same-scale.Rmd

Case weights

#| child: template-no-case-weights.Rmd

Saving fitted model objects

#| child: template-butcher.Rmd

Examples

The "Fitting and Predicting with parsnip" article contains examples for mlp() with the "nnet" engine.

References



Try the parsnip package in your browser

Any scripts or data that you put into this service are public.

parsnip documentation built on June 8, 2025, 12:10 p.m.