Use unifiedml for benchmarking models

# Use `unifiedml` for benchmarking models

# Classification

    library(unifiedml)
    library(randomForest)

    ## randomForest 4.7-1.2

    ## Type rfNews() to see new features/changes/bug fixes.

    library(e1071)
    library(caret)

    ## Loading required package: ggplot2

    ##
    ## Attaching package: 'ggplot2'

    ## The following object is masked from 'package:randomForest':
    ##
    ##     margin

    ## Loading required package: lattice

    set.seed(123)

    X <- iris[, 1:4]
    y <- iris$Species

    models <- list(
      glm  = Model$new(caret::train),
      rf   = Model$new(randomForest::randomForest),
      svm  = Model$new(e1071::svm)
    )

    params <- list(
      glm = list(method = "glmnet",
                 tuneGrid = data.frame(alpha = 0, lambda = 0.01),
                 trControl = trainControl(method = "none")),

      rf  = list(ntree = 150),

      svm = list(kernel = "radial",   # <-- added
                 cost = 1,
                 gamma = 0.1)
    )

    results <- benchmark(models, X, y, cv = 5, params = params)

    ##
    ## [1/3] Fitting model: glm
    ## Mean CV score for glm: 0.9533
    ##
    ## [2/3] Fitting model: rf
    ## Mean CV score for rf: 0.9600
    ##
    ## [3/3] Fitting model: svm
    ## Mean CV score for svm: 0.9733

    print(results)

    ## $glm
    ## $glm$avg_score
    ## [1] 0.9533333
    ##
    ## $glm$scores
    ##     fold1     fold2     fold3     fold4     fold5
    ## 0.9333333 0.9666667 0.9333333 0.9333333 1.0000000
    ##
    ##
    ## $rf
    ## $rf$avg_score
    ## [1] 0.96
    ##
    ## $rf$scores
    ##     fold1     fold2     fold3     fold4     fold5
    ## 0.9333333 1.0000000 0.9333333 0.9333333 1.0000000
    ##
    ##
    ## $svm
    ## $svm$avg_score
    ## [1] 0.9733333
    ##
    ## $svm$scores
    ##     fold1     fold2     fold3     fold4     fold5
    ## 0.9666667 1.0000000 0.9666667 0.9333333 1.0000000

# Regression

    library(unifiedml)
    library(randomForest)
    library(e1071)
    library(caret)

    set.seed(123)

    # Regression data
    X <- mtcars[, setdiff(names(mtcars), "mpg")]
    y <- mtcars$mpg

    models <- list(
      glm  = Model$new(caret::train),
      rf   = Model$new(randomForest::randomForest),
      svm  = Model$new(e1071::svm)
    )

    params <- list(
      glm = list(method = "glmnet",
                 tuneGrid = data.frame(alpha = 0, lambda = 0.01),
                 trControl = trainControl(method = "none")),

      rf  = list(ntree = 150),

      svm = list(type = "eps-regression",  # <-- important for regression
                 kernel = "radial",
                 cost = 1,
                 gamma = 0.1)
    )

    results <- benchmark(models, X, y, cv = 5, params = params)

    ##
    ## [1/3] Fitting model: glm
    ## Mean CV score for glm: 2.8020
    ##
    ## [2/3] Fitting model: rf
    ## Mean CV score for rf: 2.1512
    ##
    ## [3/3] Fitting model: svm
    ## Mean CV score for svm: 3.6608

    print(results)

    ## $glm
    ## $glm$avg_score
    ## [1] 2.801956
    ##
    ## $glm$scores
    ##    fold1    fold2    fold3    fold4    fold5
    ## 3.656903 3.503580 1.815958 1.422791 3.610545
    ##
    ##
    ## $rf
    ## $rf$avg_score
    ## [1] 2.15118
    ##
    ## $rf$scores
    ##    fold1    fold2    fold3    fold4    fold5
    ## 3.034925 2.577693 1.710550 1.237986 2.194744
    ##
    ##
    ## $svm
    ## $svm$avg_score
    ## [1] 3.660827
    ##
    ## $svm$scores
    ##    fold1    fold2    fold3    fold4    fold5
    ## 4.654566 3.565078 3.394040 2.102445 4.588007