simulate_classification_data: Simulate data for a Neural Network Structure.

Description Usage Arguments Value Examples

View source: R/simulate_classification_data.R

Description

Simulate data for a Neural Network Structure.

Usage

1
2
simulate_classification_data(rows = 1000L, N = 5L, U = 5L, C = 0L,
  matrices, activations)

Arguments

rows

An integer scaler. The number of rows in simulated data.

N

An integer scaler. The number of normal random variables in X.

U

An integer scaler. The number of uniform random variables in X.

C

An integer scaler. The number of binary random variables in X.

matrices

A list. Each element is a matrix defining the structure the layer.

activations

A list. Each element is a activation function.

Value

A matrix containing predictor variables and a response variable.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
library(NeuralNetworkSimulatoR)

# Network with no hidden layers.
# Logistic regression with weights .1, .2, and .3
M <- list(matrix(c(.1, .2, .3), nrow = 3, ncol = 1))
A <- list(sigmoid_R)
simData <- simulate_classification_data(
  rows = 1000L,
  N = 3L, U = 0L, C = 0L,
  matrices = M, activations = A
)
rm(A, M, simData)

# Network with 1 hidden layer.
# 10 nodes in first layer. Activation relu
# 5 nodes in second layer.  Activation sigmoid_R (hidden layer)
M <- list(
  matrix(1:10, nrow = 10, ncol = 5),
  matrix(1:5, nrow = 5, ncol = 1)
)
A <- list(relu_R, sigmoid_R)
simData <- simulate_classification_data(
  rows = 1000L,
  N = 5L, U = 5L, C = 0L,
  matrices = M, activations = A
)
rm(A, M, simData)

# Network with 2 hidden layers.
# 10 nodes in first layer. Activation relu
# 5 nodes in second layer.  Activation linear_R  (hidden layer)
# 3 nodes in third layer.  Activation sigmoid_R  (hidden layer)
M <- list(
  matrix(1:10, nrow = 10, ncol = 5),
  matrix(1:5, nrow = 5, ncol = 3),
  matrix(1:3, nrow = 3, ncol = 1)
)
A <- list(relu_R, linear_R, sigmoid_R)
simData <- simulate_classification_data(
  rows = 1000L,
  N = 5L, U = 5L, C = 0L,
  matrices = M, activations = A
)
rm(A, M, simData)

gmcmacran/NeuralNetworkSimulatoR documentation built on March 23, 2020, 12:51 a.m.