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 neuralnet trainPredict arguments - inputs fmla, data

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(neuralnet)
neuralnet.method <- c("slr", "sag", "rprop-", "rprop+", "backprop")
hyperParams.neuralnet <- function(method, ...) {
    return(list(iter=maxit1storderC, threshold=0.2, linear.output=TRUE))
}
NNtrain.neuralnet <- function(x, y, dataxy, formula, hidden_neur, method, hyperParams, ...) {
    
    hyper_params <- do.call(hyperParams, list(method, ...))
    
    if(method == "backprop") {learningrate <- 0.001} else {learningrate <- NULL}
    
    neuralnet::neuralnet(formula = formula, data = dataxy, hidden = hidden_neur, algorithm=method,
                        threshold=hyper_params$threshold, linear.output=hyper_params$linear.output,
                                    stepmax = hyper_params$iter, startweights = NULL, act.fct = "tanh",
                                    learningrate = learningrate)
}
NNpredict.neuralnet <- function(object, x, ...)
  as.numeric(predict(object, newdata = x))

NNclose.neuralnet <- function()
  if("package:neuralnet" %in% search())
    detach("package:neuralnet", unload=TRUE)
neuralnet.prepareZZ <- list(xdmv = "d", ydmv = "d", zdm = "d", scale = TRUE)

if(FALSE)
res <- train_and_predict_1data(1, neuralnet.method, "NNtrain.neuralnet", "hyperParams.neuralnet", "NNpredict.neuralnet", 
                               NNsummary, "NNclose.neuralnet", NA, neuralnet.prepareZZ, nrep=2,
                               echo=TRUE, doplot=FALSE, echoreport=0,
                               pkgname="neuralnet", pkgfun="neuralnet", rdafile=TRUE, odir=odir)

2 Launch package’s trainPredict

res <- trainPredict_1pkg(1:12, pkgname = "neuralnet", pkgfun = "neuralnet", neuralnet.method,
  prepareZZ.arg = neuralnet.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 = "slr")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
slr
RMSE MSE MAE WAE time
mDette 0.5081 0.2581 0.3846 2.0598 2.00
mFriedman 0.0782 0.0061 0.0684 0.1748 6.19
mIshigami 0.6889 0.4745 0.5116 2.9555 6.65
mRef153 3.5139 12.3475 2.5008 13.5814 0.00
uDmod1 0.1212 0.0147 0.0911 0.2957 0.03
uDmod2 0.1031 0.0106 0.0830 0.2699 0.01
uDreyfus1 0.2062 0.0425 0.1723 0.4822 0.00
uDreyfus2 0.1478 0.0218 0.1131 0.4772 0.00
uGauss1 2.6835 7.2009 2.1664 7.2250 0.12
uGauss2 3.6199 13.1039 2.6638 14.2330 0.06
uGauss3 3.4612 11.9802 2.7154 9.4444 0.03
uNeuroOne 0.2839 0.0806 0.2315 0.5901 0.00
kable(apply(res[,,2,], c(3,1), min), caption = "sag")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
sag
RMSE MSE MAE WAE time
mDette 2.1873 4.7843 1.4869 14.3579 10.05
mFriedman 0.0810 0.0066 0.0731 0.1637 14.37
mIshigami 3.6898 13.6148 2.9776 13.1137 23.18
mRef153 3.5321 12.4754 2.4879 13.5064 0.09
uDmod1 0.0986 0.0097 0.0751 0.2445 0.09
uDmod2 0.0533 0.0028 0.0404 0.1336 0.17
uDreyfus1 0.0845 0.0071 0.0681 0.2469 0.00
uDreyfus2 0.1380 0.0191 0.1095 0.4437 0.00
uGauss1 2.3728 5.6303 1.8438 6.4944 0.95
uGauss2 3.5764 12.7904 2.6518 12.8941 0.31
uGauss3 2.6882 7.2265 2.1073 7.6228 0.03
uNeuroOne 0.2875 0.0826 0.2373 0.5672 0.01
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 0.4446 0.1977 0.3353 1.8921 0.33
mFriedman 0.0079 0.0001 0.0062 0.0282 1.43
mIshigami 0.5951 0.3541 0.4313 2.5546 1.05
mRef153 3.4256 11.7344 2.4574 11.8535 0.00
uDmod1 0.1120 0.0125 0.0807 0.2938 0.01
uDmod2 0.0909 0.0083 0.0733 0.2001 0.02
uDreyfus1 0.2014 0.0405 0.1518 0.5512 0.00
uDreyfus2 0.1201 0.0144 0.0930 0.3439 0.00
uGauss1 2.5005 6.2525 1.9565 7.0535 0.09
uGauss2 3.3776 11.4084 2.6799 9.4165 0.05
uGauss3 2.7630 7.6341 2.1991 7.5066 0.01
uNeuroOne 0.2875 0.0826 0.2378 0.5537 0.00
kable(apply(res[,,4,], c(3,1), min), caption = "rprop+")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
rprop+
RMSE MSE MAE WAE time
mDette 0.5886 0.3464 0.4360 2.5436 0.42
mFriedman 0.0088 0.0001 0.0071 0.0265 1.64
mIshigami 0.3844 0.1478 0.2943 1.6935 1.21
mRef153 3.2534 10.5849 2.3087 13.0795 0.00
uDmod1 0.0875 0.0076 0.0647 0.2547 0.02
uDmod2 0.0639 0.0041 0.0526 0.1434 0.02
uDreyfus1 0.1678 0.0282 0.1222 0.3999 0.00
uDreyfus2 0.1514 0.0229 0.1172 0.4654 0.00
uGauss1 2.5278 6.3895 1.9628 7.4449 0.07
uGauss2 3.6927 13.6357 2.7311 11.8958 0.05
uGauss3 2.5436 6.4699 2.0353 7.5269 0.03
uNeuroOne 0.2842 0.0808 0.2328 0.5227 0.00
kable(apply(res[,,5,], c(3,1), min), caption = "backprop")%>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
backprop
RMSE MSE MAE WAE time
mDette 8.1656 66.6770 6.5262 36.2385 13.12
mFriedman 0.2348 0.0551 0.1880 0.6346 13.55
mIshigami 3.6898 13.6148 2.9776 13.1137 22.03
mRef153 3.9001 15.2109 2.8803 14.3666 0.04
uDmod1 0.1520 0.0231 0.1240 0.4189 0.20
uDmod2 0.1110 0.0123 0.0888 0.2368 0.25
uDreyfus1 0.2960 0.0876 0.2458 0.6437 0.01
uDreyfus2 0.2227 0.0496 0.1600 0.6753 0.02
uGauss1 2.6408 6.9736 2.0431 7.9787 0.39
uGauss2 3.2221 10.3822 2.5058 11.6109 0.61
uGauss3 3.3962 11.5339 2.6348 10.0509 0.23
uNeuroOne 0.2870 0.0824 0.2372 0.5080 0.13