From 7594ad7b3f5f281d4d6cef1cfd8d0119e9c52f7a Mon Sep 17 00:00:00 2001 From: be-marc Date: Tue, 10 Dec 2019 22:46:16 +0100 Subject: [PATCH 01/11] Add importance to glmnet --- R/LearnerClassifGlmnet.R | 14 +++++++++++++- R/LearnerRegrGlmnet.R | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/R/LearnerClassifGlmnet.R b/R/LearnerClassifGlmnet.R index ad314eba..d70e0169 100644 --- a/R/LearnerClassifGlmnet.R +++ b/R/LearnerClassifGlmnet.R @@ -64,7 +64,7 @@ LearnerClassifGlmnet = R6Class("LearnerClassifGlmnet", inherit = LearnerClassif, param_set = ps, predict_types = c("response", "prob"), feature_types = c("integer", "numeric"), - properties = c("weights", "twoclass", "multiclass"), + properties = c("weights", "twoclass", "multiclass", "importance"), packages = "glmnet", man = "mlr3learners::mlr_learners_classif.glmnet" ) @@ -111,6 +111,18 @@ LearnerClassifGlmnet = R6Class("LearnerClassifGlmnet", inherit = LearnerClassif, } PredictionClassif$new(task = task, prob = prob) } + }, + + importance = function() { + model = self$model$glmnet.fit + + res = sapply(seq_len(nrow(model$beta)), function(i) { + ind = which(model$beta[i,] != 0)[1] + model$lambda[ind] + }) + + names(res) = model$beta@Dimnames[[1]] + sort(res, decreasing = TRUE) } ) ) diff --git a/R/LearnerRegrGlmnet.R b/R/LearnerRegrGlmnet.R index 6b6d528a..9befadd1 100644 --- a/R/LearnerRegrGlmnet.R +++ b/R/LearnerRegrGlmnet.R @@ -71,7 +71,7 @@ LearnerRegrGlmnet = R6Class("LearnerRegrGlmnet", inherit = LearnerRegr, id = "regr.glmnet", param_set = ps, feature_types = c("integer", "numeric"), - properties = "weights", + properties = c("weights", "importance"), packages = "glmnet", man = "mlr3learners::mlr_learners_regr.glmnet" ) @@ -105,6 +105,18 @@ LearnerRegrGlmnet = R6Class("LearnerRegrGlmnet", inherit = LearnerRegr, response = invoke(predict, self$model, newx = newdata, type = "response", .args = pars) PredictionRegr$new(task = task, response = drop(response)) + }, + + importance = function() { + model = self$model$glmnet.fit + + res = sapply(seq_len(nrow(model$beta)), function(i) { + ind = which(model$beta[i,] != 0)[1] + model$lambda[ind] + }) + + names(res) = model$beta@Dimnames[[1]] + sort(res, decreasing = TRUE) } ) ) From 3ad2811e83da471d4c0a4f939d4ff282c234f811 Mon Sep 17 00:00:00 2001 From: be-marc Date: Sat, 21 Dec 2019 20:09:40 +0100 Subject: [PATCH 02/11] Replace sapply by map_dbl --- R/LearnerClassifGlmnet.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/LearnerClassifGlmnet.R b/R/LearnerClassifGlmnet.R index d70e0169..d9f15e33 100644 --- a/R/LearnerClassifGlmnet.R +++ b/R/LearnerClassifGlmnet.R @@ -116,7 +116,7 @@ LearnerClassifGlmnet = R6Class("LearnerClassifGlmnet", inherit = LearnerClassif, importance = function() { model = self$model$glmnet.fit - res = sapply(seq_len(nrow(model$beta)), function(i) { + res = map_dbl(seq_len(nrow(model$beta)), function(i) { ind = which(model$beta[i,] != 0)[1] model$lambda[ind] }) From 7eaa883efd3607e82d5675d61148e8a1b79b7fee Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:23:41 +0100 Subject: [PATCH 03/11] add importance slot for both glmnet learners and add tests --- R/LearnerClassifGlmnet.R | 45 +++++++++++++++++++--------- R/LearnerRegrGlmnet.R | 34 +++++++++++++-------- tests/testthat/test_classif_glmnet.R | 9 ++++++ tests/testthat/test_regr_glmnet.R | 8 +++++ 4 files changed, 69 insertions(+), 27 deletions(-) diff --git a/R/LearnerClassifGlmnet.R b/R/LearnerClassifGlmnet.R index 3285747b..dd0b8eae 100644 --- a/R/LearnerClassifGlmnet.R +++ b/R/LearnerClassifGlmnet.R @@ -64,10 +64,39 @@ LearnerClassifGlmnet = R6Class("LearnerClassifGlmnet", inherit = LearnerClassif, packages = "glmnet", man = "mlr3learners::mlr_learners_classif.glmnet" ) + }, + + #' @description + #' The importance scores are extracted from the beta coefficients of the + #' fitted model. + #' @param task ([Task])\cr + #' Task to calculate the importance on. If a model was already fitted, + #' no refitting is done. + #' @return Named `numeric()`. + importance = function(task) { + + if (is.null(self$model)) { + self$train(task) + } + + if ("multiclass" %in% task$properties) { + mlr3misc::stopf("Learner 'glmnet' only support feature importance for + 'twoclass' tasks.", wrap = TRUE) + } + model = self$model$glmnet.fit + + res = mlr3misc::map_dbl(seq_len(nrow(model$beta)), function(.i) { + ind = which(model$beta[.i, ] != 0)[1] + model$lambda[ind] + }) + + names(res) = model$beta@Dimnames[[1]] + sort(res, decreasing = TRUE) } ), private = list( + .train = function(task) { pars = self$param_set$get_values(tags = "train") @@ -97,11 +126,11 @@ LearnerClassifGlmnet = R6Class("LearnerClassifGlmnet", inherit = LearnerClassif, if (self$predict_type == "response") { response = invoke(predict, self$model, newx = newdata, type = "class", - .args = pars) + .args = pars) PredictionClassif$new(task = task, response = drop(response)) } else { prob = invoke(predict, self$model, newx = newdata, type = "response", - .args = pars) + .args = pars) if (length(task$class_names) == 2L) { prob = cbind(prob, 1 - prob) @@ -111,18 +140,6 @@ LearnerClassifGlmnet = R6Class("LearnerClassifGlmnet", inherit = LearnerClassif, } PredictionClassif$new(task = task, prob = prob) } - }, - - importance = function() { - model = self$model$glmnet.fit - - res = map_dbl(seq_len(nrow(model$beta)), function(i) { - ind = which(model$beta[i,] != 0)[1] - model$lambda[ind] - }) - - names(res) = model$beta@Dimnames[[1]] - sort(res, decreasing = TRUE) } ) ) diff --git a/R/LearnerRegrGlmnet.R b/R/LearnerRegrGlmnet.R index 3f38f917..8caffdc5 100644 --- a/R/LearnerRegrGlmnet.R +++ b/R/LearnerRegrGlmnet.R @@ -68,10 +68,30 @@ LearnerRegrGlmnet = R6Class("LearnerRegrGlmnet", inherit = LearnerRegr, param_set = ps, feature_types = c("logical", "integer", "numeric"), properties = c("weights", "importance"), - properties = "weights", packages = "glmnet", man = "mlr3learners::mlr_learners_regr.glmnet" ) + }, + + #' @description + #' The importance scores are extracted from the beta coefficients of the + #' fitted model. + #' @return Named `numeric()`. + importance = function() { + + if (is.null(self$model)) { + stopf("No model stored. Please train the model first.") + } + + model = self$model$glmnet.fit + + res = mlr3misc::map_dbl(seq_len(nrow(model$beta)), function(.i) { + ind = which(model$beta[.i, ] != 0)[1] + model$lambda[ind] + }) + + names(res) = model$beta@Dimnames[[1]] + sort(res, decreasing = TRUE) } ), @@ -104,18 +124,6 @@ LearnerRegrGlmnet = R6Class("LearnerRegrGlmnet", inherit = LearnerRegr, response = invoke(predict, self$model, newx = newdata, type = "response", .args = pars) PredictionRegr$new(task = task, response = drop(response)) - }, - - importance = function() { - model = self$model$glmnet.fit - - res = sapply(seq_len(nrow(model$beta)), function(i) { - ind = which(model$beta[i,] != 0)[1] - model$lambda[ind] - }) - - names(res) = model$beta@Dimnames[[1]] - sort(res, decreasing = TRUE) } ) ) diff --git a/tests/testthat/test_classif_glmnet.R b/tests/testthat/test_classif_glmnet.R index 30a01fda..f2864345 100644 --- a/tests/testthat/test_classif_glmnet.R +++ b/tests/testthat/test_classif_glmnet.R @@ -9,4 +9,13 @@ test_that("autotest", { skip_on_os("solaris") result = run_autotest(learner, exclude = "(feat_single|sanity)") expect_true(result, info = result$error) + + # FIXME: Should this go into the autotest? + expect_error(learner$importance()) + tasks = generate_tasks(learner, N = 30L)[!grepl("feat_single", names(tasks))] + tasks1 = tasks[!grepl("multiclass", names(tasks))] + tasks2 = tasks1[!grepl("feat_single", names(tasks1))] + for (task in tasks2) { + expect_numeric(learner$train(task)$importance(task)) + } }) diff --git a/tests/testthat/test_regr_glmnet.R b/tests/testthat/test_regr_glmnet.R index aaf42d89..1c0a985a 100644 --- a/tests/testthat/test_regr_glmnet.R +++ b/tests/testthat/test_regr_glmnet.R @@ -9,4 +9,12 @@ test_that("autotest", { skip_on_os("solaris") result = run_autotest(learner, exclude = "feat_single") expect_true(result, info = result$error) + + + # FIXME: Should this go into the autotest? + expect_error(learner$importance()) + tasks = generate_tasks(learner, N = 30L)[!grepl("feat_single", names(tasks))] + for (task in tasks) { + expect_numeric(learner$train(task)$importance()) + } }) From 0c340b7d0275eee16919ed075b0d07e624b1ea8b Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:23:53 +0100 Subject: [PATCH 04/11] format helper.R --- tests/testthat/helper.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index 6b27a8b3..d898606e 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -1,3 +1,4 @@ library(checkmate) library(mlr3) -lapply(list.files(system.file("testthat", package = "mlr3"), pattern = "^helper.*\\.[rR]$", full.names = TRUE), source) +lapply(list.files(system.file("testthat", package = "mlr3"), + pattern = "^helper.*\\.[rR]$", full.names = TRUE), source) From b28c11b51b9bfe99e9a2c37524cd344316fc246d Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:24:09 +0100 Subject: [PATCH 05/11] upd roxygen --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 623cf476..43cc95ab 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -57,4 +57,4 @@ RdMacros: mlr3misc Encoding: UTF-8 NeedsCompilation: no Roxygen: list(markdown = TRUE) -RoxygenNote: 7.0.2 +RoxygenNote: 7.1.0 From 0bee77ba048faa4cb09cd61440a8851b6bc72cad Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:24:41 +0100 Subject: [PATCH 06/11] upd man --- man/mlr_learners_classif.glmnet.Rd | 26 +++++++++++++++++++++++++ man/mlr_learners_classif.kknn.Rd | 2 ++ man/mlr_learners_classif.lda.Rd | 2 ++ man/mlr_learners_classif.log_reg.Rd | 2 ++ man/mlr_learners_classif.multinom.Rd | 2 ++ man/mlr_learners_classif.naive_bayes.Rd | 2 ++ man/mlr_learners_classif.qda.Rd | 2 ++ man/mlr_learners_classif.ranger.Rd | 4 ++++ man/mlr_learners_classif.svm.Rd | 2 ++ man/mlr_learners_classif.xgboost.Rd | 3 +++ man/mlr_learners_regr.glmnet.Rd | 17 ++++++++++++++++ man/mlr_learners_regr.kknn.Rd | 2 ++ man/mlr_learners_regr.km.Rd | 2 ++ man/mlr_learners_regr.lm.Rd | 2 ++ man/mlr_learners_regr.ranger.Rd | 4 ++++ man/mlr_learners_regr.svm.Rd | 2 ++ man/mlr_learners_regr.xgboost.Rd | 3 +++ 17 files changed, 79 insertions(+) diff --git a/man/mlr_learners_classif.glmnet.Rd b/man/mlr_learners_classif.glmnet.Rd index 694a1bc0..86d834ee 100644 --- a/man/mlr_learners_classif.glmnet.Rd +++ b/man/mlr_learners_classif.glmnet.Rd @@ -37,6 +37,7 @@ learner$param_set$ids() \subsection{Public methods}{ \itemize{ \item \href{#method-new}{\code{LearnerClassifGlmnet$new()}} +\item \href{#method-importance}{\code{LearnerClassifGlmnet$importance()}} \item \href{#method-clone}{\code{LearnerClassifGlmnet$clone()}} } } @@ -55,15 +56,40 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{LearnerClassifGlmnet$new()}\if{html}{\out{
}} } +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-importance}{}}} +\subsection{Method \code{importance()}}{ +The importance scores are extracted from the beta coefficients of the +fitted model. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{LearnerClassifGlmnet$importance(task)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{task}}{(\link{Task})\cr +Task to calculate the importance on. If a model was already fitted, +no refitting is done.} +} +\if{html}{\out{
}} +} +\subsection{Returns}{ +Named \code{numeric()}. +} } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.kknn.Rd b/man/mlr_learners_classif.kknn.Rd index 0d3eec74..1fa87895 100644 --- a/man/mlr_learners_classif.kknn.Rd +++ b/man/mlr_learners_classif.kknn.Rd @@ -59,6 +59,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -68,6 +69,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.lda.Rd b/man/mlr_learners_classif.lda.Rd index 49db0615..f2b3af36 100644 --- a/man/mlr_learners_classif.lda.Rd +++ b/man/mlr_learners_classif.lda.Rd @@ -55,6 +55,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -64,6 +65,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.log_reg.Rd b/man/mlr_learners_classif.log_reg.Rd index b83ac831..33e06ab5 100644 --- a/man/mlr_learners_classif.log_reg.Rd +++ b/man/mlr_learners_classif.log_reg.Rd @@ -65,6 +65,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -74,6 +75,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.multinom.Rd b/man/mlr_learners_classif.multinom.Rd index e8656430..6c585bf6 100644 --- a/man/mlr_learners_classif.multinom.Rd +++ b/man/mlr_learners_classif.multinom.Rd @@ -52,6 +52,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -61,6 +62,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.naive_bayes.Rd b/man/mlr_learners_classif.naive_bayes.Rd index 8837e00c..ebe9cec8 100644 --- a/man/mlr_learners_classif.naive_bayes.Rd +++ b/man/mlr_learners_classif.naive_bayes.Rd @@ -52,6 +52,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -61,6 +62,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.qda.Rd b/man/mlr_learners_classif.qda.Rd index d43f2dfc..b472a5bb 100644 --- a/man/mlr_learners_classif.qda.Rd +++ b/man/mlr_learners_classif.qda.Rd @@ -55,6 +55,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -64,6 +65,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.ranger.Rd b/man/mlr_learners_classif.ranger.Rd index e7ca601e..509505ec 100644 --- a/man/mlr_learners_classif.ranger.Rd +++ b/man/mlr_learners_classif.ranger.Rd @@ -59,6 +59,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -68,6 +69,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-importance}{}}} \subsection{Method \code{importance()}}{ The importance scores are extracted from the model slot \code{variable.importance}. Parameter \code{importance.mode} must be set to \code{"impurity"}, \code{"impurity_corrected"}, or @@ -82,6 +84,7 @@ Named \code{numeric()}. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-oob_error}{}}} \subsection{Method \code{oob_error()}}{ The out-of-bag error, extracted from model slot \code{prediction.error}. \subsection{Usage}{ @@ -94,6 +97,7 @@ The out-of-bag error, extracted from model slot \code{prediction.error}. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.svm.Rd b/man/mlr_learners_classif.svm.Rd index f726312b..b59d8992 100644 --- a/man/mlr_learners_classif.svm.Rd +++ b/man/mlr_learners_classif.svm.Rd @@ -54,6 +54,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -63,6 +64,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_classif.xgboost.Rd b/man/mlr_learners_classif.xgboost.Rd index 6e2808bf..3a82922b 100644 --- a/man/mlr_learners_classif.xgboost.Rd +++ b/man/mlr_learners_classif.xgboost.Rd @@ -62,6 +62,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -71,6 +72,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-importance}{}}} \subsection{Method \code{importance()}}{ The importance scores are calculated with \code{\link[xgboost:xgb.importance]{xgboost::xgb.importance()}}. \subsection{Usage}{ @@ -83,6 +85,7 @@ Named \code{numeric()}. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_regr.glmnet.Rd b/man/mlr_learners_regr.glmnet.Rd index fba00e40..b2cd0f80 100644 --- a/man/mlr_learners_regr.glmnet.Rd +++ b/man/mlr_learners_regr.glmnet.Rd @@ -39,6 +39,7 @@ learner$param_set$ids() \subsection{Public methods}{ \itemize{ \item \href{#method-new}{\code{LearnerRegrGlmnet$new()}} +\item \href{#method-importance}{\code{LearnerRegrGlmnet$importance()}} \item \href{#method-clone}{\code{LearnerRegrGlmnet$clone()}} } } @@ -57,15 +58,31 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{LearnerRegrGlmnet$new()}\if{html}{\out{
}} } +} +\if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-importance}{}}} +\subsection{Method \code{importance()}}{ +The importance scores are extracted from the beta coefficients of the +fitted model. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{LearnerRegrGlmnet$importance()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +Named \code{numeric()}. +} } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_regr.kknn.Rd b/man/mlr_learners_regr.kknn.Rd index 8e159990..12f87e06 100644 --- a/man/mlr_learners_regr.kknn.Rd +++ b/man/mlr_learners_regr.kknn.Rd @@ -59,6 +59,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -68,6 +69,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_regr.km.Rd b/man/mlr_learners_regr.km.Rd index b84a1136..e019e0cc 100644 --- a/man/mlr_learners_regr.km.Rd +++ b/man/mlr_learners_regr.km.Rd @@ -61,6 +61,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -70,6 +71,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_regr.lm.Rd b/man/mlr_learners_regr.lm.Rd index 950b7868..6efe9339 100644 --- a/man/mlr_learners_regr.lm.Rd +++ b/man/mlr_learners_regr.lm.Rd @@ -64,6 +64,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -73,6 +74,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_regr.ranger.Rd b/man/mlr_learners_regr.ranger.Rd index 816b2141..f5f1f1e0 100644 --- a/man/mlr_learners_regr.ranger.Rd +++ b/man/mlr_learners_regr.ranger.Rd @@ -59,6 +59,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -68,6 +69,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-importance}{}}} \subsection{Method \code{importance()}}{ The importance scores are extracted from the model slot \code{variable.importance}. Parameter \code{importance.mode} must be set to \code{"impurity"}, \code{"impurity_corrected"}, or @@ -82,6 +84,7 @@ Named \code{numeric()}. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-oob_error}{}}} \subsection{Method \code{oob_error()}}{ The out-of-bag error, extracted from model slot \code{prediction.error}. \subsection{Usage}{ @@ -94,6 +97,7 @@ The out-of-bag error, extracted from model slot \code{prediction.error}. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_regr.svm.Rd b/man/mlr_learners_regr.svm.Rd index d0a7ce00..6901933d 100644 --- a/man/mlr_learners_regr.svm.Rd +++ b/man/mlr_learners_regr.svm.Rd @@ -54,6 +54,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -63,6 +64,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/mlr_learners_regr.xgboost.Rd b/man/mlr_learners_regr.xgboost.Rd index b2741433..87e980d4 100644 --- a/man/mlr_learners_regr.xgboost.Rd +++ b/man/mlr_learners_regr.xgboost.Rd @@ -62,6 +62,7 @@ learner$param_set$ids() } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-new}{}}} \subsection{Method \code{new()}}{ Creates a new instance of this \link[R6:R6Class]{R6} class. \subsection{Usage}{ @@ -71,6 +72,7 @@ Creates a new instance of this \link[R6:R6Class]{R6} class. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-importance}{}}} \subsection{Method \code{importance()}}{ The importance scores are calculated with \code{\link[xgboost:xgb.importance]{xgboost::xgb.importance()}}. \subsection{Usage}{ @@ -83,6 +85,7 @@ Named \code{numeric()}. } \if{html}{\out{
}} \if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ From b34e24c369e509a458e558ae7ad7d1d0adf3aabf Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:25:08 +0100 Subject: [PATCH 07/11] ignore .vscode --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1b9a55be..7946c7bb 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ .DS_Store .Rproj.user -docs/ \ No newline at end of file +docs/ +.vscode From 018f576137bef0b3bbb8de3c177530eb216cf376 Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:27:16 +0100 Subject: [PATCH 08/11] trigger GHA --- .github/workflows/R-CMD-check.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 33748f61..f9aa46bb 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,10 +1,4 @@ -on: - push: - branches: - - master - pull_request: - branches: - - master +on: [push, pull_requests] name: R-CMD-check From 07778c8169b9c7930016ae82df9a74b884f06ac9 Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:28:16 +0100 Subject: [PATCH 09/11] trigger GHA --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index f9aa46bb..b5623b63 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,4 +1,4 @@ -on: [push, pull_requests] +on: [push, pull_request] name: R-CMD-check From c0bb4f85bb997755add07e97af2979b2c0be007f Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:32:38 +0100 Subject: [PATCH 10/11] run checks --- .github/workflows/R-CMD-check-extra.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/R-CMD-check-extra.yaml b/.github/workflows/R-CMD-check-extra.yaml index 4986dbff..c3e4f3a9 100644 --- a/.github/workflows/R-CMD-check-extra.yaml +++ b/.github/workflows/R-CMD-check-extra.yaml @@ -1,7 +1,4 @@ -on: - push: - branches: - - master +on: [push, pull_request] schedule: - cron: '15 8 * * *' From 22aa3a41290cdd5fa3d6d367df423018c5dfe709 Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 22 Mar 2020 00:33:30 +0100 Subject: [PATCH 11/11] run checks --- .github/workflows/R-CMD-check-extra.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/R-CMD-check-extra.yaml b/.github/workflows/R-CMD-check-extra.yaml index c3e4f3a9..2dbabfeb 100644 --- a/.github/workflows/R-CMD-check-extra.yaml +++ b/.github/workflows/R-CMD-check-extra.yaml @@ -1,6 +1,4 @@ on: [push, pull_request] - schedule: - - cron: '15 8 * * *' name: R-CMD-check-extra