Learn R Programming

elmNN (version 1.0)

elmtrain: Training of a SLFN (Single Hidden-layer Feedforward Neural Network)

Description

Training of a generic SLFN using ELM algorithm. First it generates input weights and hidden layer bias ( both randomly choosen ), then calculates the output from the hidden layer ( given a particular activation function as a parameter ) and at the end calculates output weights of the neural network. It returns an ELM model ( an object of class elmNN ) representing the trained neural network.

Usage

elmtrain(x, ...) "elmtrain"(formula, data, nhid, actfun, ...) "elmtrain"(x, y, nhid, actfun, ...)

Arguments

formula
a symbolic description of the model to be fitted.
data
training data frame containing the variables specified in formula.
x
training dataset.
y
target output of the training dataset.
nhid
number of hidden neurons. Must be >= 1.
actfun
type of activation function. Furthermore a list of the implemented activation functions. - sig: sigmoid - sin: sine - radbas: radial basis - hardlim: hard-limit - hardlims: symmetric hard-limit - satlins: satlins - tansig: tan-sigmoid - tribas: triangular basis - poslin: positive linear - purelin: linear
...
not used.

Value

returns the trained neural network, an object of class elmNN.
nhid
number of hidden neurons selected
actfun
activation function used
inpweight
matrix of input weights ( randomly choosen )
biashid
vector of hidden layer bias ( randomly choosen )
outweight
matrix of output weights ( calculated by the algorithm )

Details

Note: since part of ELM algorithm is random ( setting of the input weights and hidden layer bias ), output results of same activation function and same number of hidden neurons may change. To find the most accurate error rate for a fixed setting, it is convenient to make various test on the datasets (i.e. 20 times) using the same settings and calculate the mean error from these tests.

References

see elmNN-package documentation.

See Also

elmtrain.formula,elmtrain.default,predict.elmNN,elmNN-package

Examples

Run this code
set.seed(1234)
##'formula' version
Var1 <- runif(50, 0, 100) 
sqrt.data <- data.frame(Var1, Sqrt=sqrt(Var1))
model <- elmtrain(Sqrt~Var1, data=sqrt.data, nhid=10, actfun="sig")
new <- data.frame(Sqrt=0,Var1 = runif(50,0,100))
p <- predict(model,newdata=new)

##Default version
Var2 <- runif(50, 0, 10) 
quad.data <- data.frame(Var2, Quad=(Var2)^2)
model <- elmtrain(x=quad.data$Var2, y=quad.data$Quad, nhid=10, actfun="sig")
new <- data.frame(Quad=0,Var2 = runif(50,0,10))
p <- predict(model,newdata=new$Var2)

## The function is currently defined as
function (x, ...) 
UseMethod("elmtrain")

Run the code above in your browser using DataLab