Skip to contents

Single Layer Neural Network. Calls nnet::nnet.formula() from package nnet.

Note that modern neural networks with multiple layers are connected via package mlr3torch.

Dictionary

This mlr3::Learner can be instantiated via the dictionary mlr3::mlr_learners or with the associated sugar function mlr3::lrn():

mlr_learners$get("regr.nnet")
lrn("regr.nnet")

Meta Information

  • Task type: “regr”

  • Predict Types: “response”

  • Feature Types: “integer”, “numeric”, “factor”, “ordered”

  • Required Packages: mlr3, mlr3learners, nnet

Parameters

IdTypeDefaultLevelsRange
HesslogicalFALSETRUE, FALSE-
MaxNWtsinteger1000\([1, \infty)\)
Wtsuntyped--
abstolnumeric1e-04\((-\infty, \infty)\)
censoredlogicalFALSETRUE, FALSE-
contrastsuntypedNULL-
decaynumeric0\((-\infty, \infty)\)
maskuntyped--
maxitinteger100\([1, \infty)\)
na.actionuntyped--
rangnumeric0.7\((-\infty, \infty)\)
reltolnumeric1e-08\((-\infty, \infty)\)
sizeinteger3\([0, \infty)\)
skiplogicalFALSETRUE, FALSE-
subsetuntyped--
tracelogicalTRUETRUE, FALSE-
formulauntyped--

Initial parameter values

  • size:

    • Adjusted default: 3L.

    • Reason for change: no default in nnet().

Custom mlr3 parameters

  • formula: if not provided, the formula is set to task$formula().

References

Ripley BD (1996). Pattern Recognition and Neural Networks. Cambridge University Press. doi:10.1017/cbo9780511812651 .

See also

Other Learner: mlr_learners_classif.cv_glmnet, mlr_learners_classif.glmnet, mlr_learners_classif.kknn, mlr_learners_classif.lda, mlr_learners_classif.log_reg, mlr_learners_classif.multinom, mlr_learners_classif.naive_bayes, mlr_learners_classif.nnet, mlr_learners_classif.qda, mlr_learners_classif.ranger, mlr_learners_classif.svm, mlr_learners_classif.xgboost, mlr_learners_regr.cv_glmnet, mlr_learners_regr.glmnet, mlr_learners_regr.kknn, mlr_learners_regr.km, mlr_learners_regr.lm, mlr_learners_regr.ranger, mlr_learners_regr.svm, mlr_learners_regr.xgboost

Super classes

mlr3::Learner -> mlr3::LearnerRegr -> LearnerRegrNnet

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerRegrNnet$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (requireNamespace("nnet", quietly = TRUE)) {
# Define the Learner and set parameter values
learner = lrn("regr.nnet")
print(learner)

# Define a Task
task = tsk("mtcars")

# Create train and test set
ids = partition(task)

# Train the learner on the training ids
learner$train(task, row_ids = ids$train)

# print the model
print(learner$model)

# importance method
if("importance" %in% learner$properties) print(learner$importance)

# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)

# Score the predictions
predictions$score()
}
#> <LearnerRegrNnet:regr.nnet>: Single Layer Neural Network
#> * Model: -
#> * Parameters: size=3
#> * Packages: mlr3, mlr3learners, nnet
#> * Predict Types:  [response]
#> * Feature Types: logical, integer, numeric, factor, ordered
#> * Properties: weights
#> # weights:  37
#> initial  value 8445.242250 
#> iter  10 value 346.375403
#> iter  20 value 176.439132
#> iter  30 value 158.345415
#> iter  40 value 139.968094
#> iter  50 value 82.148219
#> iter  60 value 34.713929
#> iter  70 value 34.119941
#> iter  80 value 34.108462
#> iter  80 value 34.108462
#> iter  80 value 34.108462
#> final  value 34.108462 
#> converged
#> a 10-3-1 network with 37 weights
#> inputs: am carb cyl disp drat gear hp qsec vs wt 
#> output(s): mpg 
#> options were - linear output units 
#> regr.mse 
#> 11.74087