Learn R Programming

neuralnet (version 1.1)

compute: Computation of a specific covariate given a trained neural network

Description

compute, a method for objects of class nn, typically produced by neuralnet. Computes the neuron's output for a specific arbitrary covariate given a trained neural network. Please make sure that the order of the covariates is the same in the new matrix or dataframe as in the original neural network.

Usage

compute(x, covariate, rep = 1)

Arguments

x
an object of class nn.
covariate
a data.frame or matrix containing the variables to calculate the neural network.
rep
an integer indicating the neural network's repetition which should be used.

Value

  • compute returns a list containing the following components:
  • neuronsa list of the neuron's output for each layer of the neural network.
  • net.resulta matrix containing the overall result of the neural network.

Examples

Run this code
Var1 <- runif(50, 0, 100) 
sqrt.data <- data.frame(Var1, Sqrt=sqrt(Var1))
print(net.sqrt <- neuralnet( Sqrt~Var1,  sqrt.data, hidden=10, threshold=0.01))
compute(net.sqrt, (1:10)^2)$net.result

Run the code above in your browser using DataLab