--- title: "Use `unifiedml` for benchmarking models" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Use `unifiedml` for benchmarking models} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- # Classification ```{r fig.width=7, eval=TRUE} library(unifiedml) library(randomForest) library(e1071) library(caret) 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) print(results) ``` # Regression ```{r, eval=TRUE} 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) print(results) ```