Description Usage Arguments Value Examples
View source: R/NNetIterations.R
This neural network algorithm has one output and one hidden layer, and stops when max.iterations is reached.
1 2 | NNetIterations(X.mat, y.vec, max.iterations, step.size, n.hidden.units,
is.train)
|
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 |
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.