NNetIterations: Neural Network algorithm using iterations.

Description Usage Arguments Value Examples

View source: R/NNetIterations.R

Description

This neural network algorithm has one output and one hidden layer, and stops when max.iterations is reached.

Usage

1
2
NNetIterations(X.mat, y.vec, max.iterations, step.size, n.hidden.units,
  is.train)

Arguments

X.mat

numeric feature matrix of size [n_observations x n_features].

y.vec

numeric label vector of length n_observations.

max.iterations

integer scalar greater than 1.

step.size

numeric positive scalar.

n.hidden.units

number of hidden units, greater than or equal to 1.

is.train

logical vector of length n_observations, TRUE if the observation is for training, FALSE for validation

Value

result.list with named elements: pred.mat, n_observations x max.iterations matrix of predicted values. V.mat final weight matrix (n_features+1 x n.hidden.units). w.vec final weight vector (n.hidden.units+1). predict(testX.mat) a function that takes a test features matrix and returns a vector of predictions.

Examples

1
2
3
4
5
6
7
8
9
data(spam, package = "ElemStatLearn")
X.mat <- data.matrix(spam[,-ncol(spam)])
y.vec <- as.vector(ifelse(spam$spam == 'spam',1,0))
max.iteration <- 50L
step.size <- 0.02
n.hidden.units = 20L
temp <- sample(rep(1:2,l=length(y.vec)))
is.train <- (temp == 1)
result.list <- NNetIterations(X.mat, y.vec, max.iteration, step.size, n.hidden.units, is.train = is.train)

SixianZhang/CS499-Coding-Project-3 documentation built on May 21, 2019, 1:42 p.m.