Skip to content

nnet objects are created from the nnet package, leveraged to fit multilayer perceptron models.

Usage

# S3 method for nnet
axe_call(x, verbose = FALSE, ...)

# S3 method for nnet
axe_env(x, verbose = FALSE, ...)

# S3 method for nnet
axe_fitted(x, verbose = FALSE, ...)

Arguments

x

A model object.

verbose

Print information each time an axe method is executed. Notes how much memory is released and what functions are disabled. Default is FALSE.

...

Any additional arguments related to axing.

Value

Axed nnet object.

Examples

# Load libraries
library(parsnip)
library(nnet)

# Create and fit model
nnet_fit <- mlp("classification", hidden_units = 2) %>%
  set_engine("nnet") %>%
  fit(Species ~ ., data = iris)

out <- butcher(nnet_fit, verbose = TRUE)
#>  Memory released: 13.22 kB

# Another nnet object
targets <- class.ind(c(rep("setosa", 50),
                       rep("versicolor", 50),
                       rep("virginica", 50)))

fit <- nnet(iris[,1:4],
            targets,
            size = 2,
            rang = 0.1,
            decay = 5e-4,
            maxit = 20)
#> # weights:  19
#> initial  value 112.784345 
#> iter  10 value 59.321119
#> iter  20 value 7.905400
#> final  value 7.905400 
#> stopped after 20 iterations

out <- butcher(fit, verbose = TRUE)
#>  Memory released: 4.95 kB
#>  Disabled: `fitted()`, `predict() with no new data`, and `dimnames(axed_object$fitted.values)`