Skip to contents

Print the sensitivities of a HessMLP object.

Usage

# S3 method for HessMLP
print(x, n = 5, round_digits = NULL, ...)

Arguments

x

HessMLP object created by HessianMLP

n

integer specifying number of sensitivities to print per each output

round_digits

integer number of decimal places, default NULL

...

additional parameters

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)
#> # weights:  21
#> initial  value 2487.870002 
#> iter  10 value 1587.516208
#> iter  20 value 1349.706741
#> iter  30 value 1333.940734
#> iter  40 value 1329.097060
#> iter  50 value 1326.518168
#> iter  60 value 1323.148574
#> iter  70 value 1322.378769
#> iter  80 value 1322.018091
#> final  value 1321.996301 
#> converged
# Try HessianMLP
sens <- NeuralSens::HessianMLP(nnetmod, trData = nntrData, plot = FALSE)
sens
#> Sensitivity analysis of 2-5-1 MLP network.
#> 
#>   1980 samples
#> 
#> Sensitivities of each output (only 5 first samples):
#> $.outcome
#> , , 1
#> 
#>            WD     TEMP
#> WD   1.028311 1.174910
#> TEMP 1.174910 3.386778
#> 
#> , , 2
#> 
#>             WD     TEMP
#> WD   -2.693044 0.856781
#> TEMP  0.856781 1.608223
#> 
#> , , 3
#> 
#>             WD      TEMP
#> WD   -3.523861 -2.061425
#> TEMP -2.061425 -5.352261
#> 
#> , , 4
#> 
#>             WD      TEMP
#> WD   -3.823715 -2.719650
#> TEMP -2.719650 -7.312955
#> 
#> , , 5
#> 
#>              WD      TEMP
#> WD   -2.1583991 0.4679963
#> TEMP  0.4679963 1.9635852
#>