# NOT RUN {
## using numeric input
wts_in <- c(13.12, 1.49, 0.16, -0.11, -0.19, -0.16, 0.56, -0.52, 0.81)
struct <- c(2, 2, 1) #two inputs, two hidden, one output
garson(wts_in, struct)
## using nnet
library(nnet)
data(neuraldat)
set.seed(123)
mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5)
garson(mod)
# }
# NOT RUN {
## using RSNNS, no bias layers
library(RSNNS)
x <- neuraldat[, c('X1', 'X2', 'X3')]
y <- neuraldat[, 'Y1']
mod <- mlp(x, y, size = 5)
garson(mod)
## using neuralnet
library(neuralnet)
mod <- neuralnet(Y1 ~ X1 + X2 + X3, data = neuraldat, hidden = 5)
garson(mod)
## using caret
library(caret)
mod <- train(Y1 ~ X1 + X2 + X3, method = 'nnet', data = neuraldat, linout = TRUE)
garson(mod)
## modify the plot using ggplot2 syntax
library(ggplot2)
mod <- nnet(Y1 ~ X1 + X2 + X3, data = neuraldat, size = 5)
cols <- heat.colors(10)
garson(mod) +
scale_y_continuous('Rel. Importance', limits = c(-1, 1)) +
scale_fill_gradientn(colours = cols) +
scale_colour_gradientn(colours = cols)
# }
Run the code above in your browser using DataLab