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 monmlp 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(monmlp)
monmlp.method <- c("BFGS", "Nelder-Mead")
hyperParams.monmlp <- function(optim_method, ...) {
    if (optim_method == "BFGS")         {iter <- maxit2ndorder}
    if (optim_method == "Nelder-Mead")  {iter <- maxit1storderB} 
    return (list(iter=iter, silent=TRUE, scale=TRUE))
}
NNtrain.monmlp <- function(x, y, dataxy, formula, neur, optim_method, hyperParams, ...) {
    
    hyper_params <- do.call(hyperParams, list(optim_method, ...))
    iter <- hyper_params$iter
    scale <- hyper_params$scale
    silent <- hyper_params$silent
    
    monmlp::monmlp.fit(x, y, hidden1 = neur, scale.y = scale, silent=silent,
                         method = optim_method, iter.max = iter)
}
NNpredict.monmlp <- function(object, x, ...)
  as.numeric(monmlp::monmlp.predict(x, weights=object))
NNclose.monmlp <- function()
  if("package:monmlp" %in% search())
    detach("package:monmlp", unload=TRUE)
monmlp.prepareZZ <- list(xdmv = "m", ydmv = "m", zdm = "d", scale = TRUE)
if(FALSE)
res <- trainPredict_1data(1, monmlp.method, "NNtrain.monmlp", "hyperParams.monmlp", "NNpredict.monmlp", 
                               NNsummary, "NNclose.monmlp", NA, monmlp.prepareZZ, nrep=2,
                               echo=TRUE, doplot=FALSE, echoreport=0,
                               pkgname="monmlp", pkgfun="monmlp.fit", csvfile=TRUE, rdafile=TRUE, odir=odir)

2 Launch package’s trainPredict

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

3 Results

#print(res)
kable(apply(res[,,1,], c(3,1), min), caption = "BFGS")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
BFGS
RMSE MSE MAE WAE time
mDette 0.3988 0.1591 0.2998 1.7266 0.14
mFriedman 0.0105 0.0001 0.0084 0.0300 0.17
mIshigami 0.6926 0.4797 0.4964 2.9453 0.31
mRef153 3.2115 10.3140 2.1924 12.8649 0.08
uDmod1 0.0579 0.0034 0.0473 0.1243 0.06
uDmod2 0.0564 0.0032 0.0444 0.1227 0.06
uDreyfus1 0.0181 0.0003 0.0141 0.0549 0.06
uDreyfus2 0.0909 0.0083 0.0727 0.2234 0.06
uGauss1 2.3778 5.6541 1.8628 7.7754 0.09
uGauss2 3.9531 15.6273 3.0495 11.6027 0.08
uGauss3 3.3488 11.2142 2.6509 10.1172 0.08
uNeuroOne 0.2830 0.0801 0.2310 0.5367 0.06
kable(apply(res[,,2,], c(3,1), min), caption = "Nelder-Mead")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
Nelder-Mead
RMSE MSE MAE WAE time
mDette 2.6378 6.9578 1.9232 13.7171 0.83
mFriedman 0.1071 0.0115 0.0829 0.3057 0.87
mIshigami 2.4163 5.8384 1.8732 7.7563 1.29
mRef153 3.8818 15.0685 2.8026 13.6188 0.27
uDmod1 0.1714 0.0294 0.1337 0.4292 0.26
uDmod2 0.1354 0.0183 0.1110 0.3237 0.18
uDreyfus1 0.0733 0.0054 0.0621 0.1740 0.10
uDreyfus2 0.1273 0.0162 0.0993 0.2956 0.11
uGauss1 10.7831 116.2752 8.5970 24.7682 0.21
uGauss2 8.4869 72.0278 6.4404 25.4725 0.20
uGauss3 4.6604 21.7193 3.7489 11.9319 0.18
uNeuroOne 0.3265 0.1066 0.2601 0.6446 0.06