Elm.cross.valid: Training ELM with cross validation.

Description Usage Arguments Value Examples

Description

A k-fold cross validation on the training data is performed.

Usage

1
2
3
4
Elm.cross.valid(X.fit, Y.fit, Number.hn=10, n.blocks=5, returnmodels = FALSE, 
                            autorangeweight=FALSE, rangeweight=1, 
                            activation='TANH',outputBias = FALSE,
                            rangebias = 1)

Arguments

X.fit

Data matrix (numeric) containing the input values (predictors) used to train the model.

Y.fit

Response vector (numeric) used to train the model.

Number.hn

Number of units in the hidden layer. Default is 10.

n.blocks

an integer specifying the desired number of cross-validation folds. Default is 5.

returnmodels

whether to return the trained models. Default is FALSE.

autorangeweight

Option whether to use the automated range used for the weights. Default is FALSE.

rangeweight

Initial random weights on [-rangeweight,rangeweight]. The default is 1

activation

Activation function of the hidden layer neurons. Available functions are: 'TANH' (default) and 'SIG'.

outputBias

Option whether to use the bias parameter in the output layer

rangebias

Initial random bias on [-rangebias,rangebias]. The default is 1

Value

If returnmodels=FALSE (default), it returns the fitted values. If returnmodels=TRUE, it returns a list containing:.

predictionTrain

The fitted values for the training data.

trained.elms

A list containing the k models used.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
set.seed(123)
attach(wtloss)
library("scales")

#scaling the inputs/outputs
x.train <- rescale(as.matrix(wtloss$Days), to=c(-1,1))
y.train <- rescale(as.matrix(wtloss$Weight), to=c(-1,1))

#training the ELM
elm.fit.values <- rescale(Elm.cross.valid(x.train,y.train,Number.hn=5,n.blocks=5),
                          to= range(as.matrix(wtloss$Weight)),from=c(-1,1))

oldpar <- par(mar = c(5.1, 4.1, 4.1, 4.1))
plot(wtloss$Days, wtloss$Weight, type = "p", ylab = "Weight (kg)",
      main="Weight Reduction",pch=20)
points(wtloss$Days, elm.fit.values,col=2,type='p',pch=20)

ForAI documentation built on May 2, 2019, 6:14 p.m.