avNNet | R Documentation |

Aggregate several neural network models

```
avNNet(x, ...)
## S3 method for class 'formula'
avNNet(
formula,
data,
weights,
...,
repeats = 5,
bag = FALSE,
allowParallel = TRUE,
seeds = sample.int(1e+05, repeats),
subset,
na.action,
contrasts = NULL
)
## Default S3 method:
avNNet(
x,
y,
repeats = 5,
bag = FALSE,
allowParallel = TRUE,
seeds = sample.int(1e+05, repeats),
...
)
## S3 method for class 'avNNet'
print(x, ...)
## S3 method for class 'avNNet'
predict(object, newdata, type = c("raw", "class", "prob"), ...)
```

`x` |
matrix or data frame of |

`...` |
arguments passed to |

`formula` |
A formula of the form |

`data` |
Data frame from which variables specified in |

`weights` |
(case) weights for each example - if missing defaults to 1. |

`repeats` |
the number of neural networks with different random number seeds |

`bag` |
a logical for bagging for each repeat |

`allowParallel` |
if a parallel backend is loaded and available, should the function use it? |

`seeds` |
random number seeds that can be set prior to bagging (if done) and network creation. This helps maintain reproducibility when models are run in parallel. |

`subset` |
An index vector specifying the cases to be used in the training sample. (NOTE: If given, this argument must be named.) |

`na.action` |
A function to specify the action to be taken if |

`contrasts` |
a list of contrasts to be used for some or all of the factors appearing as variables in the model formula. |

`y` |
matrix or data frame of target values for examples. |

`object` |
an object of class |

`newdata` |
matrix or data frame of test examples. A vector is considered to be a row vector comprising a single case. |

`type` |
Type of output, either: |

Following Ripley (1996), the same neural network model is fit using different random number seeds. All the resulting models are used for prediction. For regression, the output from each network are averaged. For classification, the model scores are first averaged, then translated to predicted classes. Bagging can also be used to create the models.

If a parallel backend is registered, the foreach package is used to train the networks in parallel.

For `avNNet`

, an object of `"avNNet"`

or `"avNNet.formula"`

. Items of interest in #' the output are:

`model ` |
a list of the models generated from |

`repeats ` |
an echo of the model input |

`names ` |
if any predictors had only one distinct value, this is a character string of the #' remaining columns. Otherwise a value of |

These are heavily based on the `nnet`

code from Brian Ripley.

Ripley, B. D. (1996)
*Pattern Recognition and Neural Networks.* Cambridge.

`nnet`

, `preProcess`

```
data(BloodBrain)
## Not run:
modelFit <- avNNet(bbbDescr, logBBB, size = 5, linout = TRUE, trace = FALSE)
modelFit
predict(modelFit, bbbDescr)
## End(Not run)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.