NNetIterations: Neural networks for regression with backprop on the weight

Description Usage Arguments Value Examples

View source: R/NN.R

Description

Training by using nerual network with gradient descending ( real numbers for regression ).

Usage

1
2
3
4
5
6
7
8
NNetIterations(
  X.mat,
  y.vec,
  max.iterations,
  step.size,
  n.hidden.units,
  is.train
)

Arguments

X.mat

(feature matrix, n_observations x n_features)

y.vec

(label vector, n_observations x 1)

max.iterations

(int scalar > 1)

step.size

(the steps size used when decending)

n.hidden.units

(number of hidden units)

is.train

(logical vector of size n_observations, TRUE if the observation is in the train set, FALSE for the validation set)

Value

pred.mat (n_observations x max.iterations matrix of predicted values or n x k)

W.mat:final weight matrix (n_features+1 x n.hidden.units or p+1 x u)

v.vec: final weight vector (n.hidden.units+1 or u+1).

predict (testX.mat): a function that takes a test features matrix and returns a vector of predictions ( real numbers for regression ) The first row of W.mat should be the intercept terms; the first element of v.vec should be the intercept term.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Hard coded example
------------------
hard_incidence <- as.numeric(c(84.106289446623, 55.328513822534, 38.106289446623, 45.345737285, 24.324, 30.324))
hard_emission <- as.numeric(c(38.288719431206, 0.13392142633291, 4.573728543534, 23.737285372, 54.345, 14.4))
hard_phase <- as.numeric(c(120.59515694473, 55.329415379509, 100.1339214473, 154.9728542, 55.57, 47.00))

NNtestX.mat <- as.matrix(data.frame(hard_incidence, hard_emission, hard_phase))
NNtestY.vec <- as.numeric(c(0.0607816, 0.078306 , 0.098325, 0.052368, .0163620, 0.0757853))
max.iterations <- as.integer(10)
step.size <- as.numeric(0.05)
NNtest.is.train <- as.logical(c(TRUE, FALSE, TRUE, FALSE, TRUE, FALSE))

# 3 hidden units
results <- NNetIterations(NNtestX.mat, NNtestY.vec, max.iterations, step.size, as.integer(5), NNtest.is.train)
results$prediction(NNtestX.mat)

need other example that works for modern R

ChaddFrasier/lunarLearningAlgorithms documentation built on May 17, 2020, 6:50 p.m.