knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
To begin, load the interpretnn
package.
library(interpretnn)
Also, load the package that we will use to fit the neural network.
Our package works with a number of popular R packages for neural networks, and
here we will use the nnet
package.
library(nnet)
Now, load the data.
# load data --------------------------------------------------------------- data(Boston)
Next, we fit a neural network.
We will fit a neural network on the respose variable, medv
, using all covariates and with two hidden nodes.
As neural networks require random initial weights to begin learning, we use
set.seed()
for reproducibility.
set.seed(100) nn <- nnet(medv ~ ., data = Boston, size = 2, trace = FALSE, linout = TRUE, maxit = 1000)
We can then create a interpretnn
object
intnn <- interpretnn(nn, X = Boston[, -ncol(Boston)])
A useful summary table can then be produced using the summary()
function
summary(intnn)
This tells provides us with simple point estimates of the effects, and the results from the multiple-parameter Wald test for each input.
We can visualise the covariate effects and their associated uncertainty using
the plot()
function, which creates Partial Covariate Effect (PCE) plots.
There is also a plotnn()
function that visualise the significance of each weight
from the single-parameter Wald test.
plotnn(intnn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.