View source: R/Personal_Functions.R
Random_Brains | R Documentation |
Creates a random forest style collection of neural networks for classification
Random_Brains(data, y, x_test, variables = ceiling(ncol(data)/10), brains = floor(sqrt(ncol(data))), hiddens = c(3, 4))
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. |
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.
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 |
The neural networks are created using the neuralnet package!
Travis Barton
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.