1 Setup

1.1 Packages and options

library(NNbenchmark)
library(kableExtra)
options(scipen = 999)

1.2 Datasets to test

NNdataSummary(NNdatasets)
##      Dataset n_rows n_inputs n_neurons n_parameters
## 1     mDette    500        3         5           26
## 2  mFriedman    500        5         5           36
## 3  mIshigami    500        3        10           51
## 4    mRef153    153        5         3           22
## 5     uDmod1     51        1         6           19
## 6     uDmod2     51        1         5           16
## 7  uDreyfus1     51        1         3           10
## 8  uDreyfus2     51        1         3           10
## 9    uGauss1    250        1         5           16
## 10   uGauss2    250        1         4           13
## 11   uGauss3    250        1         4           13
## 12 uNeuroOne     51        1         2            7

1.3 validann trainPredict arguments - inputs x, y

if(dir.exists("D:/GSoC2020/Results/2020run03/"))
{  
  odir <- "D:/GSoC2020/Results/2020run03/"
}else if(dir.exists("~/Documents/recherche-enseignement/code/R/NNbenchmark-project/NNtempresult/"))
{  
  odir <- "~/Documents/recherche-enseignement/code/R/NNbenchmark-project/NNtempresult/"
}else
  odir <- "~"

nrep <- 10
maxit2ndorder  <-    200
maxit1storderA <-   1000
maxit1storderB <-  10000
maxit1storderC <- 100000

#library(validann)
validann.method <- c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN")
hyperParams.validann <- function(optim_method, ...) {
    
    if (optim_method == "Nelder-Mead")  {iter <- maxit1storderB} 
    if (optim_method == "BFGS")         {iter <- maxit2ndorder}
    if (optim_method == "CG")           {iter <- maxit1storderA}
    if (optim_method == "L-BFGS-B")     {iter <- maxit2ndorder}
    if (optim_method == "SANN")         {iter <- maxit1storderA}
  
    out <- list(iter = iter)
    return (out)
}
NNtrain.validann <- function(x, y, dataxy, formula, neur, optim_method, hyperParams, NNfullformula, NNparam,...) {
    
    hyper_params <- do.call(hyperParams, list(optim_method, ...))
    
    iter <- hyper_params$iter
    method <- hyper_params$method
    
    NNreg <- validann::ann(x, y, size = neur, 
                           method = optim_method, maxit = iter)
    
    return (NNreg)
}
NNpredict.validann <- function(object, x, ...)
  predict(object, x)
NNclose.validann <- function()
  if("package:validann" %in% search())
    detach("package:validann", unload=TRUE)
validann.prepareZZ <- list(xdmv = "m", ydmv = "m", zdm = "d", scale = TRUE)
if(FALSE)
res <- trainPredict_1data(1, validann.method, "NNtrain.validann", "hyperParams.validann", "NNpredict.validann", 
                               NNsummary, "NNclose.validann", NA, validann.prepareZZ, nrep=5, echo=TRUE, doplot=FALSE,
                               pkgname="validann", pkgfun="ann", csvfile=TRUE, rdafile=TRUE, odir=odir)

2 Launch package’s trainPredict

res <- trainPredict_1pkg(1:12, pkgname = "validann", pkgfun = "ann", validann.method,
  prepareZZ.arg = validann.prepareZZ, nrep = nrep, doplot = FALSE,
  csvfile = TRUE, rdafile = TRUE, odir = odir, echo = FALSE)

3 Results

#print(res)
kable(apply(res[,,1,], c(3,1), min), caption = "Nelder-Mead")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
Nelder-Mead
RMSE MSE MAE WAE time
mDette 2.6242 6.8863 1.7653 13.4298 1.61
mFriedman 0.0903 0.0082 0.0734 0.2922 12.56
mIshigami 2.4313 5.9112 1.9925 6.6966 28.64
mRef153 3.9160 15.3350 2.8203 12.5384 35.09
uDmod1 0.1364 0.0186 0.0970 0.3993 61.19
uDmod2 0.0813 0.0066 0.0643 0.1852 56.74
uDreyfus1 0.0837 0.0070 0.0507 0.2074 15.02
uDreyfus2 0.1153 0.0133 0.0926 0.2777 16.51
uGauss1 10.2802 105.6825 8.5612 22.6390 46.91
uGauss2 5.0229 25.2296 3.7622 16.6120 42.46
uGauss3 3.7876 14.3458 2.9598 10.3789 33.56
uNeuroOne 0.2983 0.0890 0.2485 0.5724 12.94
kable(apply(res[,,2,], c(3,1), min), caption = "BFGS")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
BFGS
RMSE MSE MAE WAE time
mDette 0.2964 0.0878 0.2347 1.2450 1.64
mFriedman 0.0092 0.0001 0.0073 0.0293 2.47
mIshigami 0.6049 0.3659 0.4351 2.8035 5.56
mRef153 3.1802 10.1135 2.1864 12.3262 0.54
uDmod1 0.0412 0.0017 0.0312 0.1132 0.79
uDmod2 0.0427 0.0018 0.0330 0.0869 0.73
uDreyfus1 0.0018 0.0000 0.0013 0.0049 0.23
uDreyfus2 0.0906 0.0082 0.0724 0.2197 0.22
uGauss1 2.2396 5.0156 1.7361 7.0394 1.08
uGauss2 2.3528 5.5357 1.8491 7.4254 0.90
uGauss3 2.3033 5.3050 1.8439 7.0882 0.57
uNeuroOne 0.2830 0.0801 0.2313 0.5675 0.12
kable(apply(res[,,3,], c(3,1), min), caption = "CG")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
CG
RMSE MSE MAE WAE time
mDette 0.3785 0.1433 0.2921 1.4510 11.52
mFriedman 0.0176 0.0003 0.0139 0.0555 35.92
mIshigami 0.6883 0.4737 0.5126 2.6717 87.78
mRef153 3.1181 9.7223 2.1554 12.9054 54.27
uDmod1 0.0494 0.0024 0.0393 0.1280 62.23
uDmod2 0.0507 0.0026 0.0418 0.1105 59.14
uDreyfus1 0.0051 0.0000 0.0041 0.0136 49.23
uDreyfus2 0.0909 0.0083 0.0728 0.2231 53.42
uGauss1 2.3153 5.3607 1.8289 7.7608 75.68
uGauss2 2.8878 8.3393 2.3108 8.3963 63.09
uGauss3 2.5744 6.6276 2.0602 7.7276 70.57
uNeuroOne 0.2830 0.0801 0.2313 0.5674 56.35
kable(apply(res[,,4,], c(3,1), min), caption = "L-BFGS-B")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
L-BFGS-B
RMSE MSE MAE WAE time
mDette 0.3817 0.1457 0.2978 1.3503 1.76
mFriedman 0.0163 0.0003 0.0131 0.0466 2.75
mIshigami 0.7714 0.5950 0.5692 2.7837 5.70
mRef153 3.1296 9.7943 2.1737 11.1759 1.28
uDmod1 0.0525 0.0028 0.0436 0.1089 1.09
uDmod2 0.0525 0.0028 0.0444 0.1010 0.92
uDreyfus1 0.0015 0.0000 0.0013 0.0037 0.65
uDreyfus2 0.0906 0.0082 0.0722 0.2159 0.24
uGauss1 2.3895 5.7096 1.8696 7.8333 1.16
uGauss2 2.6774 7.1686 2.1646 7.9370 1.01
uGauss3 2.3952 5.7371 1.9224 6.2121 1.14
uNeuroOne 0.2830 0.0801 0.2313 0.5674 0.17
kable(apply(res[,,5,], c(3,1), min), caption = "SANN")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
SANN
RMSE MSE MAE WAE time
mDette 3.6109 13.0384 2.6870 17.3460 0.17
mFriedman 0.1395 0.0195 0.1097 0.4286 0.22
mIshigami 3.0705 9.4282 2.5252 9.7793 0.32
mRef153 6.6279 43.9290 4.9132 21.2194 0.22
uDmod1 0.2278 0.0519 0.1804 0.5406 0.20
uDmod2 0.2179 0.0475 0.1730 0.4578 0.17
uDreyfus1 0.1969 0.0388 0.1485 0.5082 0.22
uDreyfus2 0.2425 0.0588 0.1976 0.5504 0.21
uGauss1 12.4076 153.9489 9.3709 32.3143 0.26
uGauss2 10.3689 107.5132 7.8878 25.8157 0.26
uGauss3 5.1887 26.9226 4.1216 15.4642 0.33
uNeuroOne 0.3325 0.1105 0.2726 0.6766 0.32