knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

Overall, the process for classification is very similar to the regression process. The main difference is the last activation must have a range between 0 and 1.

Matrices and Activations

First a list of matrices must be made. The elements of each matrix are the Betas of the network. The dimensions are associated with the network's structure. Here is an example of creating ideal data for a network with 2 hidden layers. The first hidden layer has 8 nodes. The second hidden layer has 2 nodes.

library(NeuralNetworkSimulatoR)

set.seed(1)
M <- list(
  matrix(rnorm(12*10, mean = 0, sd = 1), nrow = 12, ncol = 8),
  matrix(rnorm(8*2, mean = 0, sd = 1), nrow = 8, ncol = 2),
  matrix(rnorm(2*1, mean = 0, sd = 1), nrow = 2, ncol = 1)
  )

nrow in the first matrix (12 in the above) is the number of columns in the data set (see below). ncol of the first matrix must be nrow of the second matrix (8 above). The last matrix must have only one column associated with the network's head.

Next activation functions for each hidden layer are selected. In this example, the first two activations are relu and the last is sigmoid. Note the last activation must have a range between 0 and 1.

A <- list(relu_R, 
          relu_R,
          sigmoid_R)

Creating Data

With the matrices and activations created, a data set containing 12 input variables following a normal distribution is made.

simData <- simulate_classification_data(
  rows = 1000L,
  N = 12L, U = 0L, C = 0L,
  matrices = M, activations = A
)

head(simData)

A data set with only categorical variables can also be created.

simData <- simulate_classification_data(
  rows = 1000L,
  N = 0L, U = 0L, C = 12L,
  matrices = M, activations = A
)

head(simData)

Or a mixture of normal, uniform and categorical variables.

simData <- simulate_classification_data(
  rows = 1000L,
  N = 6L, U = 3L, C = 3L,
  matrices = M, activations = A
)

head(simData)


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