Learn R Programming

BiodiversityR (version 1.5)

nnetrandom: Calculate the NNET Result with the Smallest Value from Various Random Starts

Description

This function provides the best solution from various calls to the nnet feed-forward artificial neural networks function (nnet).

Usage

nnetrandom(formula,data,tries=10,leave.one.out=F,...)

Arguments

formula
Formula as passed to nnet.
data
Data as passed to nnet.
tries
Number of calls to nnet to obtain the best solution.
leave.one.out
Calculate leave-one-out predictions.
...
Other arguments passed to nnet.

Value

  • The function returns the same components as nnet, but adds the following components:
  • rangeSummary of the observed "values".
  • triesNumber of different attempts to iterate an ANN.
  • CVPredicted class when not using the respective sample unit for iterating ANN.
  • succesfulTest whether leave-one-out statistics provided the same class as the original class.

Details

This function makes various calls to nnet. If desired by the user, leave-one-out statistics are provided that report the prediction if one particular sample unit was not used for iterating the networks.

Examples

Run this code
data(faramea)
faramea <- na.omit(faramea)
faramea$presence <- as.numeric(faramea$Faramea.occidentalis > 0)
attach(faramea)
library(nnet)
result <- nnetrandom(presence ~ Elevation, data=faramea, size=2, 
    skip=FALSE, entropy=TRUE, trace=FALSE, maxit=1000, tries=100, 
    leave.one.out=FALSE)
summary(result)
result$fitted.values
result$value
result2 <- nnetrandom(presence ~ Elevation, data=faramea, size=2, 
    skip=FALSE, entropy=TRUE, trace=FALSE, maxit=1000, tries=50, 
    leave.one.out=TRUE)
result2$range
result2$CV
result2$successful

Run the code above in your browser using DataLab