Fits a single-hidden-layer neural network regression on a 'tidyFit' R6 class.
The function can be used with regress and classify.
# S3 method for class 'nnet'
.fit(self, data = NULL)A fitted 'tidyFit' class model.
Hyperparameters:
size (number of units in the hidden layer)
decay (parameter for weight decay)
maxit (maximum number of iterations)
Important method arguments (passed to m)
The function provides a wrapper for nnet::nnet.formula. See ?nnet for more details.
Implementation
For regress, linear output units (linout=True) are used, while classify implements
the default logic of nnet (entropy=TRUE for 2 target classes and softmax=TRUE for more classes).
# Load data
data <- tidyfit::Factor_Industry_Returns
# Stand-alone function
fit <- m("nnet", Return ~ ., data)
fit
#> # A tibble: 1 × 5
#> estimator_fct `size (MB)` grid_id model_object settings
#> <chr> <dbl> <chr> <list> <list>
#> 1 nnet::nnet 1.84 #0010000 <tidyFit> <tibble [1 × 3]>
# Within 'regress' function
fit <- regress(data, Return ~ ., m("nnet", decay=0.5, size = 8),
.mask = c("Date", "Industry"))
# Within 'classify' function
fit <- classify(iris, Species ~ ., m("nnet", decay=0.5, size = 8))