Random_Brains: Random Brains: Neural Network Implementation of Random Forest

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/Personal_Functions.R

Description

Creates a random forest style collection of neural networks for classification

Usage

1
2
3
4
Random_Brains(data, y, x_test,
variables = ceiling(ncol(data)/10),
brains = floor(sqrt(ncol(data))),
hiddens = c(3, 4))

Arguments

data

The data that holds the predictors ONLY.

y

The responce variable

x_test

The testing predictors

variables

The number of predictors to select for each brain in 'data'. The default is one tenth of the number of columns in 'data'.

brains

The number of neural networks to create. The default is the square root of the number of columns in 'data'.

hiddens

The is a vector with length equal to the desired number of hidden layers. Each entry in the vector corresponds to the number of nodes in that layer. The default is c(3, 4) which is a two layer network with 3 and 4 nodes in the layers respectively.

Details

This function is meant to mirror the classic random forest function exctly. The only difference being that it uses shallow neural networks to build the forest instead of decision trees.

Value

predictions

The predictions for x_test.

num_brains

The number of neural networks used to decide the predictions.

predictors_per_brain

The number of variabled used for the neural networks used to decide the predictions.

hidden_layers

The vector describing the number of layers, as well as how many there were.

preds_per_brain

This matrix describes which columns where selected by each brain. Each row is a new brain. each column describes the index of the column used.

raw_results

The matrix of raw predictions from the brains. Each row is the cummulative predictions of all the brains. Which prediciton won by majority vote can be seen in 'predictions

Note

The neural networks are created using the neuralnet package!

Author(s)

Travis Barton

Examples

1
2
3
4
5
6
7
8
9
dat = Cross_val_maker(iris, .2)

train = dat$Train
test = dat$Test

Final_Test = Random_Brains(train[,-5],
  train$Species, as.matrix(test[,-5]),
  variables = 3, brains = 2)
table(Final_Test$predictions, as.numeric(test$Species))

LilRhino documentation built on Oct. 31, 2019, 4:59 p.m.