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 CaDENCE 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(CaDENCE)
CaDENCE.method <- c("optim", "psoptim", "Rprop")
hyperParams.CaDENCE <- function(optim_method, ...) {
  
    if (optim_method == "optim")    {iter <- maxit2ndorder;  epsilon <- 0.01} 
    if (optim_method == "psoptim")  {iter <- maxit1storderA; epsilon <- 0.01}
    if (optim_method == "Rprop")    {iter <- maxit1storderA; epsilon <- 0.01}
    
    out <- list(iter = iter, epsilon = epsilon)
    return (out)
}

NNtrain.CaDENCE <- function(x, y, dataxy, formula, neur, optim_method, hyperParams,...) {
    
    hyper_params <- do.call(hyperParams, list(optim_method, ...))
    iter <- hyper_params$iter ; epsilon <- hyper_params$epsilon

    NNreg <- CaDENCE::cadence.fit(x = x, y = y, 
                                iter.max = iter, 
                                n.hidden = neur, 
                                hidden.fcn = tanh, 
                                method = optim_method, 
                                n.trials = 1, 
                                trace = 0, 
                                maxit.Nelder = 1, 
                                f.cost = cadence.cost,
                                distribution = list(density.fcn = dnorm,
                                                    parameters = c("mean", "sd"),
                                                    parameters.fixed = NULL,
                                                    output.fcns = c(identity, exp)),
                                epsilon = epsilon)
    return(NNreg)
}
NNpredict.CaDENCE <- function(object, x, ...)
    CaDENCE::cadence.predict(x = x, fit = object)[,1]
NNclose.CaDENCE <- function()
  if("package:CaDENCE" %in% search())
    detach("package:CaDENCE", unload=TRUE)
CaDENCE.prepareZZ <- list(xdmv = "m", ydmv = "m", zdm = "d", scale = TRUE)

if(FALSE)
res <- trainPredict_1data(1, CaDENCE.method, "NNtrain.CaDENCE", "hyperParams.CaDENCE", "NNpredict.CaDENCE", 
                               NNsummary, "NNclose.CaDENCE", NA, CaDENCE.prepareZZ, nrep=2, echo=TRUE, doplot=FALSE,
                               pkgname="CaDENCE", pkgfun="cadence.fit", csvfile=TRUE, rdafile=TRUE, odir=odir)

2 Launch package’s trainPredict

res <- trainPredict_1pkg(1:12, pkgname = "CaDENCE", pkgfun = "cadence.fit", CaDENCE.method,
  prepareZZ.arg = CaDENCE.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 = "optim")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
optim
RMSE MSE MAE WAE time
mDette 0.3264 0.1066 0.2329 1.7464 7.17
mFriedman 0.0229 0.0005 0.0148 0.0637 9.13
mIshigami 0.8058 0.6493 0.5809 3.3313 14.92
mRef153 3.2664 10.6692 2.3721 11.8947 2.64
uDmod1 0.0500 0.0025 0.0381 0.1420 1.75
uDmod2 0.0518 0.0027 0.0390 0.1397 2.14
uDreyfus1 0.0421 0.0018 0.0213 0.1725 0.67
uDreyfus2 0.0909 0.0083 0.0730 0.2263 0.80
uGauss1 2.2672 5.1400 1.7603 7.4331 2.86
uGauss2 7.1642 51.3262 4.5787 23.7357 2.28
uGauss3 2.8398 8.0643 2.2072 7.6855 1.98
uNeuroOne 0.2831 0.0801 0.2310 0.5815 0.23
kable(apply(res[,,2,], c(3,1), min), caption = "psoptim")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
psoptim
RMSE MSE MAE WAE time
mDette 3.0739 9.4488 1.6632 17.5140 11.51
mFriedman 0.0890 0.0079 0.0599 0.2678 12.05
mIshigami 2.2433 5.0322 1.7211 7.6639 15.00
mRef153 3.5690 12.7379 2.5162 13.8542 7.49
uDmod1 0.2784 0.0775 0.2262 0.5959 5.08
uDmod2 0.2195 0.0482 0.1867 0.4694 5.00
uDreyfus1 0.3963 0.1570 0.2525 0.9527 4.41
uDreyfus2 0.3258 0.1061 0.2177 1.0083 4.39
uGauss1 21.6434 468.4362 16.9332 42.7843 6.01
uGauss2 11.3874 129.6730 7.7513 30.6006 5.58
uGauss3 7.3171 53.5403 5.8748 21.7574 5.64
uNeuroOne 0.5813 0.3379 0.4354 1.5849 4.12
kable(apply(res[,,3,], c(3,1), min), caption = "Rprop")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
Rprop
RMSE MSE MAE WAE time
mDette 2.9812 8.8876 1.6313 13.8176 17.28
mFriedman 0.0500 0.0025 0.0377 0.2094 22.30
mIshigami 1.7308 2.9955 1.1751 8.3313 36.78
mRef153 3.7678 14.1963 2.6184 15.2636 9.66
uDmod1 0.2584 0.0668 0.1900 0.6078 6.35
uDmod2 0.1679 0.0282 0.1190 0.4630 5.56
uDreyfus1 0.2513 0.0631 0.1859 0.6844 3.54
uDreyfus2 0.1475 0.0217 0.1092 0.4730 3.74
uGauss1 14.7524 217.6337 7.9690 49.3105 6.95
uGauss2 7.1611 51.2816 5.2363 21.8244 5.72
uGauss3 8.4677 71.7015 5.9923 28.2131 5.72
uNeuroOne 0.2854 0.0815 0.2347 0.5373 2.73