plot.HessMLP: Plot method for the HessMLP Class

View source: R/HessMLP.R

plot.HessMLPR Documentation

Plot method for the HessMLP Class

Description

Plot the sensitivities and sensitivity metrics of a HessMLP object.

Usage

## S3 method for class 'HessMLP'
plot(
  x,
  plotType = c("sensitivities", "time", "features", "matrix", "interactions"),
  ...
)

Arguments

x

HessMLP object created by HessianMLP

plotType

character specifying which type of plot should be created. It can be:

  • "sensitivities" (default): use HessianMLP function

  • "time": use SensTimePlot function

  • "features": use HessFeaturePlot function

  • "matrix": use SensMatPlot function to show the values of second partial derivatives

  • "interactions": use SensMatPlot function to show the values of second partial derivatives and the first partial derivatives in the diagonal

...

additional parameters passed to plot function of the NeuralSens package

Value

list of graphic objects created by ggplot

Examples

#' ## Load data -------------------------------------------------------------------
data("DAILY_DEMAND_TR")
fdata <- DAILY_DEMAND_TR

## Parameters of the NNET ------------------------------------------------------
hidden_neurons <- 5
iters <- 250
decay <- 0.1

################################################################################
#########################  REGRESSION NNET #####################################
################################################################################
## Regression dataframe --------------------------------------------------------
# Scale the data
fdata.Reg.tr <- fdata[,2:ncol(fdata)]
fdata.Reg.tr[,3] <- fdata.Reg.tr[,3]/10
fdata.Reg.tr[,1] <- fdata.Reg.tr[,1]/1000

# Normalize the data for some models
preProc <- caret::preProcess(fdata.Reg.tr, method = c("center","scale"))
nntrData <- predict(preProc, fdata.Reg.tr)

#' ## TRAIN nnet NNET --------------------------------------------------------
# Create a formula to train NNET
form <- paste(names(fdata.Reg.tr)[2:ncol(fdata.Reg.tr)], collapse = " + ")
form <- formula(paste(names(fdata.Reg.tr)[1], form, sep = " ~ "))

set.seed(150)
nnetmod <- nnet::nnet(form,
                           data = nntrData,
                           linear.output = TRUE,
                           size = hidden_neurons,
                           decay = decay,
                           maxit = iters)
# Try HessianMLP
sens <- NeuralSens::HessianMLP(nnetmod, trData = nntrData, plot = FALSE)

plot(sens)
plot(sens,"time")


NeuralSens documentation built on July 9, 2023, 6:18 p.m.