From 9debe41e7771dd238fabf229d671a7d26c882a34 Mon Sep 17 00:00:00 2001 From: henrifnk <50552831+henrifnk@users.noreply.github.com> Date: Thu, 30 Apr 2020 17:47:23 +0200 Subject: [PATCH] Add AdaBoost, IBk, LMT, OneR, PART (#6) --- DESCRIPTION | 6 +- NAMESPACE | 6 + R/LearnerClassifAdaBoostM1.R | 104 +++++++++++++++++ R/LearnerClassifIBk.R | 104 +++++++++++++++++ R/LearnerClassifJ48.R | 36 ++++-- R/LearnerClassifJRip.R | 27 +++-- R/LearnerClassifLMT.R | 106 +++++++++++++++++ R/LearnerClassifOneR.R | 96 +++++++++++++++ R/LearnerClassifPART.R | 110 ++++++++++++++++++ R/LearnerRegrIBk.R | 95 +++++++++++++++ R/LearnerRegrM5Rules.R | 31 +++-- R/zzz.R | 8 ++ .../test_paramtest_classif.AdaBoostM1.R | 41 +++++++ inst/paramtest/test_paramtest_classif.IBk.R | 41 +++++++ inst/paramtest/test_paramtest_classif.J48.R | 29 +++-- inst/paramtest/test_paramtest_classif.JRip.R | 27 +++-- inst/paramtest/test_paramtest_classif.LMT.R | 42 +++++++ inst/paramtest/test_paramtest_classif.OneR.R | 41 +++++++ inst/paramtest/test_paramtest_classif.PART.R | 41 +++++++ inst/paramtest/test_paramtest_regr.IBk.R | 41 +++++++ inst/paramtest/test_paramtest_regr.M5Rules.R | 30 +++-- man/mlr3learners.rweka-package.Rd | 6 +- man/mlr_learners_classif.AdaBoostM1.Rd | 97 +++++++++++++++ man/mlr_learners_classif.IBk.Rd | 98 ++++++++++++++++ man/mlr_learners_classif.J48.Rd | 27 ++++- man/mlr_learners_classif.JRip.Rd | 27 ++++- man/mlr_learners_classif.LMT.Rd | 97 +++++++++++++++ man/mlr_learners_classif.OneR.Rd | 98 ++++++++++++++++ man/mlr_learners_classif.PART.Rd | 97 +++++++++++++++ man/mlr_learners_regr.IBk.Rd | 98 ++++++++++++++++ man/mlr_learners_regr.M5Rules.Rd | 32 +++-- tests/testthat/test_classif_AdaBoostM1.R | 10 ++ tests/testthat/test_classif_IBk.R | 10 ++ tests/testthat/test_classif_LMT.R | 10 ++ tests/testthat/test_classif_OneR.R | 10 ++ tests/testthat/test_classif_PART.R | 10 ++ tests/testthat/test_regr_IBk.R | 10 ++ 37 files changed, 1711 insertions(+), 88 deletions(-) create mode 100644 R/LearnerClassifAdaBoostM1.R create mode 100644 R/LearnerClassifIBk.R create mode 100644 R/LearnerClassifLMT.R create mode 100644 R/LearnerClassifOneR.R create mode 100644 R/LearnerClassifPART.R create mode 100644 R/LearnerRegrIBk.R create mode 100644 inst/paramtest/test_paramtest_classif.AdaBoostM1.R create mode 100644 inst/paramtest/test_paramtest_classif.IBk.R create mode 100644 inst/paramtest/test_paramtest_classif.LMT.R create mode 100644 inst/paramtest/test_paramtest_classif.OneR.R create mode 100644 inst/paramtest/test_paramtest_classif.PART.R create mode 100644 inst/paramtest/test_paramtest_regr.IBk.R create mode 100644 man/mlr_learners_classif.AdaBoostM1.Rd create mode 100644 man/mlr_learners_classif.IBk.Rd create mode 100644 man/mlr_learners_classif.LMT.Rd create mode 100644 man/mlr_learners_classif.OneR.Rd create mode 100644 man/mlr_learners_classif.PART.Rd create mode 100644 man/mlr_learners_regr.IBk.Rd create mode 100644 tests/testthat/test_classif_AdaBoostM1.R create mode 100644 tests/testthat/test_classif_IBk.R create mode 100644 tests/testthat/test_classif_LMT.R create mode 100644 tests/testthat/test_classif_OneR.R create mode 100644 tests/testthat/test_classif_PART.R create mode 100644 tests/testthat/test_regr_IBk.R diff --git a/DESCRIPTION b/DESCRIPTION index 7216b00..6f58923 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,14 @@ Package: mlr3learners.rweka -Title: M5Rules, JRip and J48 Learner for mlr3 +Title: AdaBoostM1, IBk ,JRip, J48, LMT, M5Rules, OneR and PART + Learner for mlr3 Version: 0.1.0.9000 Authors@R: person(given = "Henri", family = "Funk", role = "cre", email = "henrifnk@gmail.com") -Description: JRip and J48 Learner for mlr3. +Description: AdaBoostM1, IBk ,JRip, J48, LMT, M5Rules, OneR and + PART Learner for mlr3. License: LGPL-3 Depends: R (>= 3.1.0) diff --git a/NAMESPACE b/NAMESPACE index 5b86b2c..5f0b2e3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,13 @@ # Generated by roxygen2: do not edit by hand +export(LearnerClassifAdaBoostM1) +export(LearnerClassifIBk) export(LearnerClassifJ48) export(LearnerClassifJRip) +export(LearnerClassifLMT) +export(LearnerClassifOneR) +export(LearnerClassifPART) +export(LearnerRegrIBk) export(LearnerRegrM5Rules) import(data.table) import(mlr3misc) diff --git a/R/LearnerClassifAdaBoostM1.R b/R/LearnerClassifAdaBoostM1.R new file mode 100644 index 0000000..ce62312 --- /dev/null +++ b/R/LearnerClassifAdaBoostM1.R @@ -0,0 +1,104 @@ +#' @title Classification AdaBoostM1 Learner +#' +#' @name mlr_learners_classif.AdaBoostM1 +#' +#' @description +#' A [mlr3::LearnerClassif] implementing classification AdaBoostM1 from package \CRANpkg{RWeka}. +# Calls [RWeka::AdaBoostM1()]. +#' +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern +#' +#' @templateVar id classif.AdaBoostM1 +#' @template section_dictionary_learner +#' +#' @references +#' Freund Y, Schapire, R (1993). +#' Experiments with a New Boosting Algorithm +#' \url{http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.51.6252&rep=rep1&type=pdf} +#' +#' @export +LearnerClassifAdaBoostM1 = R6Class("LearnerClassifAdaBoostM1", + inherit = LearnerClassif, + public = list( + #' @description + #' Creates a new instance of this [R6][R6::R6Class] class. + initialize = function() { + ps = ParamSet$new( + params = list( + ParamUty$new(id = "subset", tags = c("train", "pars")), + ParamUty$new(id = "na.action", tags = c("train", "pars")), + ParamInt$new( + id = "P", default = 100L, lower = 90L, upper = 100L, + tags = c("train", "control")), + ParamLgl$new(id = "Q", default = FALSE, tags = c("train", "control")), + ParamInt$new(id = "S", default = 1L, lower = 1L, tags = c("train", "control")), + ParamInt$new(id = "I", default = 10L, lower = 1L, tags = c("train", "control")), + ParamUty$new( + id = "W", default = "weka.classifiers.trees.DecisionStump", + tags = c("train", "control")), + ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, + tags = c("train", "control")), + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, + tags = c("train", "control")), + ParamInt$new(id = "batch_size", default = 100L, lower = 1L, tags = c("train", "control")), + ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) + ) + ) + + super$initialize( + id = "classif.AdaBoostM1", + packages = "RWeka", + feature_types = c("numeric", "factor", "ordered"), + predict_types = c("response", "prob"), + param_set = ps, + properties = c("twoclass", "multiclass"), + man = "mlr3learners.rweka::mlr_learners_classif.AdaBoostM1" + ) + } + ), + + private = list( + .train = function(task) { + ctrl = self$param_set$get_values(tags = "control") + if (length(ctrl) > 0L) { + names(ctrl) = gsub("_", replacement = "-", x = names(ctrl)) + ctrl = mlr3misc::invoke(RWeka::Weka_control, ctrl) + } + + pars = self$param_set$get_values(tags = "pars") + f = task$formula() + data = task$data() + mlr3misc::invoke(RWeka::AdaBoostM1, formula = f, data = data, control = ctrl, .args = pars) + }, + + .predict = function(task) { + response = NULL + prob = NULL + newdata = task$data(cols = task$feature_names) + + if (self$predict_type == "response") { + response = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "class") + } else { + prob = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "prob") + } + PredictionClassif$new(task = task, response = response, prob = prob) + } + ) +) diff --git a/R/LearnerClassifIBk.R b/R/LearnerClassifIBk.R new file mode 100644 index 0000000..e80b0a2 --- /dev/null +++ b/R/LearnerClassifIBk.R @@ -0,0 +1,104 @@ +#' @title Classification IBk Learner +#' +#' @name mlr_learners_classif.IBk +#' +#' @description +#' A [mlr3::LearnerClassif] implementing classification IBk from package \CRANpkg{RWeka}. +#' Calls [RWeka::IBk()]. +#' +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern +#' +#' @templateVar id classif.IBk +#' @template section_dictionary_learner +#' +#' @references +#' Aha D, Kibbler D, Alber M (1991). +#' Instance-based learning algorithms +#' \url{https://link.springer.com/content/pdf/10.1007/BF00153759.pdf} +#' +#' @export +LearnerClassifIBk = R6Class("LearnerClassifIBk", + inherit = LearnerClassif, + public = list( + #' @description + #' Creates a new instance of this [R6][R6::R6Class] class. + initialize = function() { + ps = ParamSet$new( + params = list( + ParamUty$new(id = "subset", tags = c("train", "pars")), + ParamUty$new(id = "na.action", tags = c("train", "pars")), + ParamLgl$new(id = "I", default = FALSE, tags = c("train", "control")), + ParamLgl$new(id = "F", default = FALSE, tags = c("train", "control")), + ParamInt$new(id = "K", default = 1L, lower = 1L, tags = c("train", "control")), + ParamLgl$new(id = "E", default = FALSE, tags = c("train", "control")), + ParamInt$new(id = "W", default = 0L, lower = 0L, tags = c("train", "control")), + ParamLgl$new(id = "X", default = FALSE, tags = c("train", "control")), + ParamUty$new( + id = "A", default = "weka.core.neighboursearch.LinearNNSearch", + tags = c("train", "control")), + ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, + tags = c("train", "control")), + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, + tags = c("train", "control")), + ParamInt$new(id = "batch_size", default = 100L, lower = 1L, tags = c("train", "control")), + ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) + ) + ) + + super$initialize( + id = "classif.IBk", + packages = "RWeka", + feature_types = c("numeric", "factor", "ordered"), + predict_types = c("response", "prob"), + param_set = ps, + properties = c("twoclass", "multiclass"), + man = "mlr3learners.rweka::mlr_learners_classif.IBk" + ) + } + ), + + private = list( + .train = function(task) { + ctrl = self$param_set$get_values(tags = "control") + if (length(ctrl) > 0L) { + names(ctrl) = gsub("_", replacement = "-", x = names(ctrl)) + ctrl = mlr3misc::invoke(RWeka::Weka_control, ctrl) + } + + pars = self$param_set$get_values(tags = "pars") + f = task$formula() + data = task$data() + mlr3misc::invoke(RWeka::IBk, formula = f, data = data, control = ctrl, .args = pars) + }, + + .predict = function(task) { + response = NULL + prob = NULL + newdata = task$data(cols = task$feature_names) + + if (self$predict_type == "response") { + response = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "class") + } else { + prob = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "prob") + } + PredictionClassif$new(task = task, response = response, prob = prob) + } + ) +) diff --git a/R/LearnerClassifJ48.R b/R/LearnerClassifJ48.R index 1dfb836..cf5d6a5 100644 --- a/R/LearnerClassifJ48.R +++ b/R/LearnerClassifJ48.R @@ -6,12 +6,21 @@ #' A [mlr3::LearnerClassif] implementing classification J48 from package \CRANpkg{RWeka}. #' Calls [RWeka::J48()]. #' -#' This learner contains changed ids of the following control agruments -#' since their ids contain irregular pattern: -#' * mlr3learner: output_debug_info RWeka: output-debug-info -#' * mlr3learner: do_not_check_capabilities RWeka: do-not-check-capabilities -#' * mlr3learner: num_decimal_places RWeka: num-decimal-places -#' * mlr3learner: batch_size RWeka: batch-size +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern #' #' @templateVar id classif.J48 #' @template section_dictionary_learner @@ -34,7 +43,8 @@ LearnerClassifJ48 = R6Class("LearnerClassifJ48", ParamUty$new(id = "na.action", tags = c("train", "pars")), ParamLgl$new(id = "U", default = FALSE, tags = c("train", "control")), ParamLgl$new(id = "O", default = FALSE, tags = c("train", "control")), - ParamDbl$new(id = "C", default = 0.25, lower = .Machine$double.eps, + ParamDbl$new( + id = "C", default = 0.25, lower = .Machine$double.eps, upper = 1 - .Machine$double.eps, tags = c("train", "control")), ParamInt$new(id = "M", default = 2L, lower = 1L, tags = c("train", "control")), ParamLgl$new(id = "R", default = FALSE, tags = c("train", "control")), @@ -45,13 +55,15 @@ LearnerClassifJ48 = R6Class("LearnerClassifJ48", ParamLgl$new(id = "A", default = FALSE, tags = c("train", "control")), ParamLgl$new(id = "J", default = FALSE, tags = c("train", "control")), ParamInt$new(id = "Q", default = 1L, lower = 1L, tags = c("train", "control")), - ParamLgl$new(id = "doNotMakeSplitPointActualValue", default = FALSE, - tags = c("train", "control")), - ParamLgl$new(id = "output_debug_info", default = FALSE, + ParamLgl$new( + id = "doNotMakeSplitPointActualValue", default = FALSE, tags = c("train", "control")), - ParamLgl$new(id = "do_not_check_capabilities", default = FALSE, + ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, tags = c("train", "control")), - ParamInt$new(id = "num_decimal_places", default = 2L, lower = 1L, + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, tags = c("train", "control")), ParamInt$new(id = "batch_size", default = 100L, lower = 1L, tags = c("train", "control")), ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) diff --git a/R/LearnerClassifJRip.R b/R/LearnerClassifJRip.R index ff687ae..5b28687 100644 --- a/R/LearnerClassifJRip.R +++ b/R/LearnerClassifJRip.R @@ -6,12 +6,21 @@ #' A [mlr3::LearnerClassif] implementing classification JRip from package \CRANpkg{RWeka}. #' Calls [RWeka::JRip()]. #' -#' This learner contains changed ids of the following control agruments -#' since their ids contain irregular pattern: -#' * mlr3learner: output_debug_info RWeka: output-debug-info -#' * mlr3learner: do_not_check_capabilities RWeka: do-not-check-capabilities -#' * mlr3learner: num_decimal_places RWeka: num-decimal-places -#' * mlr3learner: batch_size RWeka: batch-size +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern #' #' @templateVar id classif.Jrip #' @template section_dictionary_learner @@ -41,9 +50,11 @@ LearnerClassifJRip = R6Class("LearnerClassifJRip", ParamLgl$new(id = "E", default = FALSE, tags = c("train", "control")), ParamLgl$new(id = "P", default = FALSE, tags = c("train", "control")), ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), - ParamLgl$new(id = "do_not_check_capabilities", default = FALSE, + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, tags = c("train", "control")), - ParamInt$new(id = "num_decimal_places", default = 2L, lower = 1L, + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, tags = c("train", "control")), ParamInt$new(id = "batch_size", default = 100L, lower = 1L, tags = c("train", "control")), ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) diff --git a/R/LearnerClassifLMT.R b/R/LearnerClassifLMT.R new file mode 100644 index 0000000..f5d7ee9 --- /dev/null +++ b/R/LearnerClassifLMT.R @@ -0,0 +1,106 @@ +#' @title Classification Logistic Model Trees Learner +#' +#' @name mlr_learners_classif.LMT +#' +#' @description +#' A [mlr3::LearnerClassif] implementing classification LMT from package \CRANpkg{RWeka}. +# Calls [RWeka::LMT()]. +#' +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern +#' +#' @templateVar id classif.LMT +#' @template section_dictionary_learner +#' +#' @references +#' Landwehr N, Hall M, Frank E (2005). +#' Logistic Model Trees +#' \url{https://link.springer.com/content/pdf/10.1007/s10994-005-0466-3.pdf} +#' +#' @export +LearnerClassifLMT = R6Class("LearnerClassifLMT", + inherit = LearnerClassif, + public = list( + #' @description + #' Creates a new instance of this [R6][R6::R6Class] class. + initialize = function() { + ps = ParamSet$new( + params = list( + ParamUty$new(id = "subset", tags = c("train", "pars")), + ParamUty$new(id = "na.action", tags = c("train", "pars")), + ParamLgl$new(id = "B", default = FALSE, tags = c("train", "control")), + ParamLgl$new(id = "R", default = FALSE, tags = c("train", "control")), + ParamLgl$new(id = "C", default = FALSE, tags = c("train", "control")), + ParamLgl$new(id = "P", default = FALSE, tags = c("train", "control")), + ParamInt$new(id = "I", lower = 1L, tags = c("train", "control")), + ParamInt$new(id = "M", default = 15L, lower = 1L, tags = c("train", "control")), + ParamDbl$new(id = "W", default = 0, lower = 0, upper = 1, tags = c("train", "control")), + ParamLgl$new(id = "A", default = FALSE, tags = c("train", "control")), + ParamLgl$new( + id = "doNotMakeSplitPointActualValue", default = FALSE, + tags = c("train", "control")), + ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, + tags = c("train", "control")), + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, + tags = c("train", "control")), + ParamInt$new(id = "batch_size", default = 100L, lower = 1L, tags = c("train", "control")), + ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) + ) + ) + ps$add_dep("I", "C", CondEqual$new(FALSE)) + super$initialize( + id = "classif.LMT", + packages = "RWeka", + feature_types = c("numeric", "factor", "ordered"), + predict_types = c("response", "prob"), + param_set = ps, + properties = c("twoclass", "multiclass"), + man = "mlr3learners.rweka::mlr_learners_classif.LMT" + ) + } + ), + + private = list( + .train = function(task) { + ctrl = self$param_set$get_values(tags = "control") + if (length(ctrl) > 0L) { + names(ctrl) = gsub("_", replacement = "-", x = names(ctrl)) + ctrl = mlr3misc::invoke(RWeka::Weka_control, ctrl) + } + + pars = self$param_set$get_values(tags = "pars") + f = task$formula() + data = task$data() + mlr3misc::invoke(RWeka::LMT, formula = f, data = data, control = ctrl, .args = pars) + }, + + .predict = function(task) { + response = NULL + prob = NULL + newdata = task$data(cols = task$feature_names) + + if (self$predict_type == "response") { + response = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "class") + } else { + prob = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "prob") + } + PredictionClassif$new(task = task, response = response, prob = prob) + } + ) +) diff --git a/R/LearnerClassifOneR.R b/R/LearnerClassifOneR.R new file mode 100644 index 0000000..1b32c8d --- /dev/null +++ b/R/LearnerClassifOneR.R @@ -0,0 +1,96 @@ +#' @title Classification OneR Learner +#' +#' @name mlr_learners_classif.OneR +#' +#' @description +#' A [mlr3::LearnerClassif] implementing classification PART from package \CRANpkg{RWeka}. +#' Calls [RWeka::OneR()]. +#' +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern +#' +#' @templateVar id classif.OneR +#' @template section_dictionary_learner +#' +#' @references +#' Holte R (1993). +#' Very Simple Classification Rules Perform Well on Most Commonly Used Datasets +#' \url{https://link.springer.com/content/pdf/10.1023/A:1022631118932.pdf} +#' +#' @export +LearnerClassifOneR = R6Class("LearnerClassifOneR", + inherit = LearnerClassif, + public = list( + #' @description + #' Creates a new instance of this [R6][R6::R6Class] class. + initialize = function() { + ps = ParamSet$new( + params = list( + ParamUty$new(id = "subset", tags = c("train", "pars")), + ParamUty$new(id = "na.action", tags = c("train", "pars")), + ParamInt$new(id = "B", default = 6L, lower = 1L, tags = c("train", "control")), + ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, + tags = c("train", "control")), + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, + tags = c("train", "control")), + ParamInt$new(id = "batch_size", default = 100L, lower = 1L, tags = c("train", "control")), + ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) + ) + ) + + super$initialize( + id = "classif.OneR", + packages = "RWeka", + feature_types = c("numeric", "factor", "ordered"), + predict_types = c("response", "prob"), + param_set = ps, + properties = c("twoclass", "multiclass"), + man = "mlr3learners.rweka::mlr_learners_classif.OneR" + ) + } + ), + + private = list( + .train = function(task) { + ctrl = self$param_set$get_values(tags = "control") + if (length(ctrl) > 0L) { + names(ctrl) = gsub("_", replacement = "-", x = names(ctrl)) + ctrl = mlr3misc::invoke(RWeka::Weka_control, ctrl) + } + + pars = self$param_set$get_values(tags = "pars") + f = task$formula() + data = task$data() + mlr3misc::invoke(RWeka::OneR, formula = f, data = data, control = ctrl, .args = pars) + }, + + .predict = function(task) { + response = NULL + prob = NULL + newdata = task$data(cols = task$feature_names) + + if (self$predict_type == "response") { + response = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "class") + } else { + prob = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "prob") + } + PredictionClassif$new(task = task, response = response, prob = prob) + } + ) +) diff --git a/R/LearnerClassifPART.R b/R/LearnerClassifPART.R new file mode 100644 index 0000000..ccda305 --- /dev/null +++ b/R/LearnerClassifPART.R @@ -0,0 +1,110 @@ +#' @title Classification PART Learner +#' +#' @name mlr_learners_classif.PART +#' +#' @description +#' A [mlr3::LearnerClassif] implementing classification PART from package \CRANpkg{RWeka}. +#' Calls [RWeka::PART()]. +#' +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern +#' +#' @templateVar id classif.PART +#' @template section_dictionary_learner +#' +#' @references +#' Frank E, Witten I (1998). +#' Generating Accurate Rule Sets Without Global Optimization +#' +#' @export +LearnerClassifPART = R6Class("LearnerClassifPART", + inherit = LearnerClassif, + public = list( + #' @description + #' Creates a new instance of this [R6][R6::R6Class] class. + initialize = function() { + ps = ParamSet$new( + params = list( + ParamUty$new(id = "subset", tags = c("train", "pars")), + ParamUty$new(id = "na.action", tags = c("train", "pars")), + ParamDbl$new( + id = "C", default = 0.25, lower = .Machine$double.eps, + upper = 1 - .Machine$double.eps, tags = c("train", "control")), + ParamInt$new(id = "M", default = 2L, lower = 1L, tags = c("train", "control")), + ParamLgl$new(id = "R", default = FALSE, tags = c("train", "control")), + ParamInt$new(id = "N", default = 3L, lower = 1L, tags = c("train", "control")), + ParamLgl$new(id = "B", default = FALSE, tags = c("train", "control")), + ParamLgl$new(id = "U", default = FALSE, tags = c("train", "control")), + ParamLgl$new(id = "J", default = FALSE, tags = c("train", "control")), + ParamInt$new(id = "Q", default = 1L, lower = 1L, tags = c("train", "control")), + ParamLgl$new( + id = "doNotMakeSplitPointActualValue", default = FALSE, + tags = c("train", "control")), + ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, + tags = c("train", "control")), + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, + tags = c("train", "control")), + ParamInt$new( + id = "batch_size", default = 100L, lower = 1L, + tags = c("train", "control")), + ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) + ) + ) + ps$add_dep("N", "R", CondEqual$new(TRUE)) + + super$initialize( + id = "classif.PART", + packages = "RWeka", + feature_types = c("numeric", "factor", "ordered"), + predict_types = c("response", "prob"), + param_set = ps, + properties = c("twoclass", "multiclass", "missings"), + man = "mlr3learners.rweka::mlr_learners_classif.PART" + ) + } + ), + + private = list( + .train = function(task) { + ctrl = self$param_set$get_values(tags = "control") + if (length(ctrl) > 0L) { + names(ctrl) = gsub("_", replacement = "-", x = names(ctrl)) + ctrl = mlr3misc::invoke(RWeka::Weka_control, ctrl) + } + + pars = self$param_set$get_values(tags = "pars") + f = task$formula() + data = task$data() + mlr3misc::invoke(RWeka::PART, formula = f, data = data, control = ctrl, .args = pars) + }, + + .predict = function(task) { + response = NULL + prob = NULL + newdata = task$data(cols = task$feature_names) + + if (self$predict_type == "response") { + response = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "class") + } else { + prob = mlr3misc::invoke(predict, self$model, newdata = newdata, type = "prob") + } + PredictionClassif$new(task = task, response = response, prob = prob) + } + ) +) diff --git a/R/LearnerRegrIBk.R b/R/LearnerRegrIBk.R new file mode 100644 index 0000000..c648b74 --- /dev/null +++ b/R/LearnerRegrIBk.R @@ -0,0 +1,95 @@ +#' @title Regression IBk Learner +#' +#' @name mlr_learners_regr.IBk +#' +#' @description +#' A [mlr3::LearnerRegr] implementing classification JRip from package \CRANpkg{RWeka}. +#' Calls [RWeka::IBk()]. +#' +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern +#' +#' @templateVar id regr.IBk +#' @template section_dictionary_learner +#' +#' @references +#' Aha D, Kibbler D, Alber M (1991). +#' Instance-based learning algorithms +#' \url{https://link.springer.com/content/pdf/10.1007/BF00153759.pdf} +#' +#' @export +LearnerRegrIBk = R6Class("LearnerRegrIBk", + inherit = LearnerRegr, + public = list( + #' @description + #' Creates a new instance of this [R6][R6::R6Class] class. + initialize = function() { + ps = ParamSet$new( + params = list( + ParamUty$new(id = "subset", tags = c("train", "pars")), + ParamUty$new(id = "na.action", tags = c("train", "pars")), + ParamLgl$new(id = "I", default = FALSE, tags = c("train", "control")), + ParamLgl$new(id = "F", default = FALSE, tags = c("train", "control")), + ParamInt$new(id = "K", default = 1L, lower = 1L, tags = c("train", "control")), + ParamLgl$new(id = "E", default = FALSE, tags = c("train", "control")), + ParamInt$new(id = "W", default = 0L, lower = 0L, tags = c("train", "control")), + ParamLgl$new(id = "X", default = FALSE, tags = c("train", "control")), + ParamUty$new( + id = "A", default = "weka.core.neighboursearch.LinearNNSearch", + tags = c("train", "control")), + ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, tags = c("train", "control")), + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, tags = c("train", "control")), + ParamInt$new(id = "batch_size", default = 100L, lower = 1L, tags = c("train", "control")), + ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) + ) + ) + + super$initialize( + id = "regr.IBk", + packages = "RWeka", + feature_types = c("numeric", "factor", "ordered"), + predict_types = "response", + param_set = ps, + properties = character(0L), + man = "mlr3learners.rweka::mlr_learners_regr.IBk" + ) + } + ), + + private = list( + .train = function(task) { + ctrl = self$param_set$get_values(tags = "control") + if (length(ctrl) > 0L) { + names(ctrl) = gsub("_", replacement = "-", x = names(ctrl)) + ctrl = mlr3misc::invoke(RWeka::Weka_control, ctrl) + } + + pars = self$param_set$get_values(tags = "pars") + f = task$formula() + data = task$data() + mlr3misc::invoke(RWeka::IBk, formula = f, data = data, control = ctrl, .args = pars) + }, + + .predict = function(task) { + newdata = task$data(cols = task$feature_names) + response = mlr3misc::invoke(predict, self$model, newdata = newdata) + PredictionRegr$new(task = task, response = response) + } + ) +) diff --git a/R/LearnerRegrM5Rules.R b/R/LearnerRegrM5Rules.R index 63a6bdb..e91258f 100644 --- a/R/LearnerRegrM5Rules.R +++ b/R/LearnerRegrM5Rules.R @@ -1,4 +1,4 @@ -#' @title Regrssion M5Rules Learner +#' @title Regression M5Rules Learner #' #' @name mlr_learners_regr.M5Rules #' @@ -6,12 +6,21 @@ #' A [mlr3::LearnerRegr] implementing classification JRip from package \CRANpkg{RWeka}. #' Calls [RWeka::M5Rules()]. #' -#' This learner contains changed ids of the following control agruments -#' since their ids contain irregular pattern: -#' * mlr3learner: output_debug_info RWeka: output-debug-info -#' * mlr3learner: do_not_check_capabilities RWeka: do-not-check-capabilities -#' * mlr3learner: num_decimal_places RWeka: num-decimal-places -#' * mlr3learner: batch_size RWeka: batch-size +#' @section Custom mlr3 defaults: +#' - `output_debug_info`: +#' - original id: output-debug-info +#' +#' - `do_not_check_capabilities`: +#' - original id: do-not-check-capabilities +#' +#' - `num_decimal_places`: +#' - original id: num-decimal-places +#' +#' - `batch_size`: +#' - original id: batch-size +#' +#' - Reason for change: This learner contains changed ids of the following control arguments +#' since their ids contain irregular pattern #' #' @templateVar id regr.M5Rules #' @template section_dictionary_learner @@ -39,10 +48,10 @@ LearnerRegrM5Rules = R6Class("LearnerRegrM5Rules", ParamLgl$new(id = "R", default = FALSE, tags = c("train", "control")), ParamInt$new(id = "M", default = 4L, tags = c("train", "control")), ParamLgl$new(id = "output_debug_info", default = FALSE, tags = c("train", "control")), - ParamLgl$new(id = "do_not_check_capabilities", default = FALSE, - tags = c("train", "control")), - ParamInt$new(id = "num_decimal_places", default = 2L, lower = 1L, - tags = c("train", "control")), + ParamLgl$new( + id = "do_not_check_capabilities", default = FALSE, tags = c("train", "control")), + ParamInt$new( + id = "num_decimal_places", default = 2L, lower = 1L, tags = c("train", "control")), ParamInt$new(id = "batch_size", default = 100L, lower = 1L, tags = c("train", "control")), ParamUty$new(id = "options", default = NULL, tags = c("train", "pars")) ) diff --git a/R/zzz.R b/R/zzz.R index acc1bde..d1ffc5c 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -7,13 +7,21 @@ # nocov start register_mlr3 = function(libname, pkgname) { + # get mlr_learners dictionary from the mlr3 namespace + x = utils::getFromNamespace("mlr_learners", ns = "mlr3") # add the learner to the dictionary + x$add("classif.AdaBoostM1", LearnerClassifAdaBoostM1) + x$add("classif.IBk", LearnerClassifIBk) + x$add("regr.IBk", LearnerRegrIBk) x$add("classif.JRip", LearnerClassifJRip) x$add("classif.J48", LearnerClassifJ48) + x$add("classif.LMT", LearnerClassifLMT) x$add("regr.M5Rules", LearnerRegrM5Rules) + x$add("classif.OneR", LearnerClassifOneR) + x$add("classif.PART", LearnerClassifPART) } .onLoad = function(libname, pkgname) { # nolint diff --git a/inst/paramtest/test_paramtest_classif.AdaBoostM1.R b/inst/paramtest/test_paramtest_classif.AdaBoostM1.R new file mode 100644 index 0000000..cf3ebf4 --- /dev/null +++ b/inst/paramtest/test_paramtest_classif.AdaBoostM1.R @@ -0,0 +1,41 @@ +library(mlr3learners.rweka) + +test_that("classif.AdaBoostM1", { + learner = lrn("classif.AdaBoostM1") + fun = RWeka::AdaBoostM1 + exclude = c( + "formula", # handled via mlr3 + "data", # handled via mlr3 + "control" # handled to RWeka::Weka_Control + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("Weka_control AdaBoostM1", { + learner = lrn("classif.AdaBoostM1") + fun = RWeka::Weka_control + exclude = c( + character(0L) + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("predict classif.AdaBoostM1", { + learner = lrn("classif.AdaBoostM1") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) +}) diff --git a/inst/paramtest/test_paramtest_classif.IBk.R b/inst/paramtest/test_paramtest_classif.IBk.R new file mode 100644 index 0000000..98bcc69 --- /dev/null +++ b/inst/paramtest/test_paramtest_classif.IBk.R @@ -0,0 +1,41 @@ +library(mlr3learners.rweka) + +test_that("classif.IBk", { + learner = lrn("classif.IBk") + fun = RWeka::IBk + exclude = c( + "formula", # handled via mlr3 + "data", # handled via mlr3 + "control" # handled to RWeka::Weka_Control + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("Weka_control IBk", { + learner = lrn("classif.IBk") + fun = RWeka::Weka_control + exclude = c( + character(0L) + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("predict classif.IBk", { + learner = lrn("classif.IBk") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) +}) diff --git a/inst/paramtest/test_paramtest_classif.J48.R b/inst/paramtest/test_paramtest_classif.J48.R index 874d4fc..5ca4276 100644 --- a/inst/paramtest/test_paramtest_classif.J48.R +++ b/inst/paramtest/test_paramtest_classif.J48.R @@ -8,14 +8,10 @@ test_that("classif.J48", { "data", # handled via mlr3 "control" # handled to RWeka::Weka_Control ) - ParamTest = run_paramtest(learner, fun, exclude) expect_true(ParamTest, info = paste0( - " -Missing parameters: -", - paste0("- '", ParamTest$missing, "'", collapse = " -"))) + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) }) test_that("Weka_control J48", { @@ -24,12 +20,23 @@ test_that("Weka_control J48", { exclude = c( character(0L) ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("predict classif.J48", { + learner = lrn("classif.J48") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) ParamTest = run_paramtest(learner, fun, exclude) expect_true(ParamTest, info = paste0( - " -Missing parameters: -", - paste0("- '", ParamTest$missing, "'", collapse = " -"))) + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) }) diff --git a/inst/paramtest/test_paramtest_classif.JRip.R b/inst/paramtest/test_paramtest_classif.JRip.R index b13dc6e..caadec8 100644 --- a/inst/paramtest/test_paramtest_classif.JRip.R +++ b/inst/paramtest/test_paramtest_classif.JRip.R @@ -10,11 +10,8 @@ test_that("classif.JRip", { ) ParamTest = run_paramtest(learner, fun, exclude) expect_true(ParamTest, info = paste0( - " -Missing parameters: -", - paste0("- '", ParamTest$missing, "'", collapse = " -"))) + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) }) test_that("Weka_control JRip", { @@ -23,12 +20,22 @@ test_that("Weka_control JRip", { exclude = c( character(0L) ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) +test_that("predict classif.JRip", { + learner = lrn("classif.JRip") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) ParamTest = run_paramtest(learner, fun, exclude) expect_true(ParamTest, info = paste0( - " -Missing parameters: -", - paste0("- '", ParamTest$missing, "'", collapse = " -"))) + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) }) diff --git a/inst/paramtest/test_paramtest_classif.LMT.R b/inst/paramtest/test_paramtest_classif.LMT.R new file mode 100644 index 0000000..e46ab58 --- /dev/null +++ b/inst/paramtest/test_paramtest_classif.LMT.R @@ -0,0 +1,42 @@ +library(mlr3learners.rweka) + +test_that("classif.LMT", { + learner = lrn("classif.LMT") + fun = RWeka::LMT + exclude = c( + "formula", # handled via mlr3 + "data", # handled via mlr3 + "control" # handled to RWeka::Weka_Control + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("Weka_control LMT", { + learner = lrn("classif.LMT") + fun = RWeka::Weka_control + exclude = c( + character(0L) + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + + +test_that("predict classif.LMT", { + learner = lrn("classif.LMT") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) +}) diff --git a/inst/paramtest/test_paramtest_classif.OneR.R b/inst/paramtest/test_paramtest_classif.OneR.R new file mode 100644 index 0000000..32acdf3 --- /dev/null +++ b/inst/paramtest/test_paramtest_classif.OneR.R @@ -0,0 +1,41 @@ +library(mlr3learners.rweka) + +test_that("classif.OneR", { + learner = lrn("classif.OneR") + fun = RWeka::OneR + exclude = c( + "formula", # handled via mlr3 + "data", # handled via mlr3 + "control" # handled to RWeka::Weka_Control + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("Weka_control OneR", { + learner = lrn("classif.OneR") + fun = RWeka::Weka_control + exclude = c( + character(0L) + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("predict classif.OneR", { + learner = lrn("classif.OneR") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) +}) diff --git a/inst/paramtest/test_paramtest_classif.PART.R b/inst/paramtest/test_paramtest_classif.PART.R new file mode 100644 index 0000000..00364c2 --- /dev/null +++ b/inst/paramtest/test_paramtest_classif.PART.R @@ -0,0 +1,41 @@ +library(mlr3learners.rweka) + +test_that("classif.PART", { + learner = lrn("classif.PART") + fun = RWeka::PART + exclude = c( + "formula", # handled via mlr3 + "data", # handled via mlr3 + "control" # handled to RWeka::Weka_Control + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("Weka_control PART", { + learner = lrn("classif.PART") + fun = RWeka::Weka_control + exclude = c( + character(0L) + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("predict classif.PART", { + learner = lrn("classif.PART") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) +}) diff --git a/inst/paramtest/test_paramtest_regr.IBk.R b/inst/paramtest/test_paramtest_regr.IBk.R new file mode 100644 index 0000000..2626508 --- /dev/null +++ b/inst/paramtest/test_paramtest_regr.IBk.R @@ -0,0 +1,41 @@ +library(mlr3learners.rweka) + +test_that("regr.IBk", { + learner = lrn("regr.IBk") + fun = RWeka::IBk + exclude = c( + "formula", # handled via mlr3 + "data", # handled via mlr3 + "control" # handled to RWeka::Weka_Control + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("Weka_control IBk", { + learner = lrn("regr.IBk") + fun = RWeka::Weka_control + exclude = c( + character(0L) + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) + +test_that("predict regr.IBk", { + learner = lrn("regr.IBk") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) +}) diff --git a/inst/paramtest/test_paramtest_regr.M5Rules.R b/inst/paramtest/test_paramtest_regr.M5Rules.R index daa979e..5b480b7 100644 --- a/inst/paramtest/test_paramtest_regr.M5Rules.R +++ b/inst/paramtest/test_paramtest_regr.M5Rules.R @@ -2,20 +2,16 @@ library(mlr3learners.rweka) test_that("regr.M5Rules", { learner = lrn("regr.M5Rules") - fun = RWeka::JRip + fun = RWeka::M5Rules exclude = c( "formula", # handled via mlr3 "data", # handled via mlr3 "control" # handled to RWeka::Weka_Control ) - ParamTest = run_paramtest(learner, fun, exclude) expect_true(ParamTest, info = paste0( - " -Missing parameters: -", - paste0("- '", ParamTest$missing, "'", collapse = " -"))) + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) }) test_that("Weka_control M5 Rules", { @@ -24,12 +20,22 @@ test_that("Weka_control M5 Rules", { exclude = c( character(0L) ) + ParamTest = run_paramtest(learner, fun, exclude) + expect_true(ParamTest, info = paste0( + "\nMissing parameters:\n", + paste0("- '", ParamTest$missing, "'", collapse = "\n"))) +}) +test_that("predict regr.M5Rules", { + learner = lrn("regr.M5Rules") + fun = RWeka:::predict.Weka_classifier + exclude = c( + "object", # handled via mlr3 + "newdata", # handled via mlr3 + "type" # handled via mlr3 + ) ParamTest = run_paramtest(learner, fun, exclude) expect_true(ParamTest, info = paste0( - " -Missing parameters: -", - paste0("- '", ParamTest$missing, "'", collapse = " -"))) + "Missing parameters:", + paste0("- '", ParamTest$missing, "'", collapse = "‚"))) }) diff --git a/man/mlr3learners.rweka-package.Rd b/man/mlr3learners.rweka-package.Rd index bd8757b..0b6adaa 100644 --- a/man/mlr3learners.rweka-package.Rd +++ b/man/mlr3learners.rweka-package.Rd @@ -4,9 +4,11 @@ \name{mlr3learners.rweka-package} \alias{mlr3learners.rweka} \alias{mlr3learners.rweka-package} -\title{mlr3learners.rweka: M5Rules, JRip and J48 Learner for mlr3} +\title{mlr3learners.rweka: AdaBoostM1, IBk ,JRip, J48, LMT, M5Rules, OneR and PART + Learner for mlr3} \description{ -JRip and J48 Learner for mlr3. +AdaBoostM1, IBk ,JRip, J48, LMT, M5Rules, OneR and + PART Learner for mlr3. } \author{ \strong{Maintainer}: Henri Funk \email{henrifnk@gmail.com} diff --git a/man/mlr_learners_classif.AdaBoostM1.Rd b/man/mlr_learners_classif.AdaBoostM1.Rd new file mode 100644 index 0000000..1d766fd --- /dev/null +++ b/man/mlr_learners_classif.AdaBoostM1.Rd @@ -0,0 +1,97 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/LearnerClassifAdaBoostM1.R +\name{mlr_learners_classif.AdaBoostM1} +\alias{mlr_learners_classif.AdaBoostM1} +\alias{LearnerClassifAdaBoostM1} +\title{Classification AdaBoostM1 Learner} +\description{ +A \link[mlr3:LearnerClassif]{mlr3::LearnerClassif} implementing classification AdaBoostM1 from package \CRANpkg{RWeka}. +} +\section{Custom mlr3 defaults}{ + +\itemize{ +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size +} +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern +} +} + +\section{Dictionary}{ + +This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} +\link{mlr_learners} or with the associated sugar function \code{\link[=lrn]{lrn()}}:\preformatted{mlr_learners$get("classif.AdaBoostM1") +lrn("classif.AdaBoostM1") +} +} + +\references{ +Freund Y, Schapire, R (1993). +Experiments with a New Boosting Algorithm +\url{http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.51.6252&rep=rep1&type=pdf} +} +\section{Super classes}{ +\code{\link[mlr3:Learner]{mlr3::Learner}} -> \code{\link[mlr3:LearnerClassif]{mlr3::LearnerClassif}} -> \code{LearnerClassifAdaBoostM1} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-new}{\code{LearnerClassifAdaBoostM1$new()}} +\item \href{#method-clone}{\code{LearnerClassifAdaBoostM1$clone()}} +} +} +\if{html}{ +\out{
Inherited methods} +\itemize{ +\item \out{}\href{../../mlr3/html/Learner.html#method-format}{\code{mlr3::Learner$format()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-help}{\code{mlr3::Learner$help()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict}{\code{mlr3::Learner$predict()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict_newdata}{\code{mlr3::Learner$predict_newdata()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-print}{\code{mlr3::Learner$print()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-reset}{\code{mlr3::Learner$reset()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-train}{\code{mlr3::Learner$train()}}\out{} +} +\out{
} +} +\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{LearnerClassifAdaBoostM1$new()}\if{html}{\out{
}} +} + +} +\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}{ +\if{html}{\out{
}}\preformatted{LearnerClassifAdaBoostM1$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/mlr_learners_classif.IBk.Rd b/man/mlr_learners_classif.IBk.Rd new file mode 100644 index 0000000..1edda29 --- /dev/null +++ b/man/mlr_learners_classif.IBk.Rd @@ -0,0 +1,98 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/LearnerClassifIBk.R +\name{mlr_learners_classif.IBk} +\alias{mlr_learners_classif.IBk} +\alias{LearnerClassifIBk} +\title{Classification IBk Learner} +\description{ +A \link[mlr3:LearnerClassif]{mlr3::LearnerClassif} implementing classification IBk from package \CRANpkg{RWeka}. +Calls \code{\link[RWeka:IBk]{RWeka::IBk()}}. +} +\section{Custom mlr3 defaults}{ + +\itemize{ +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size +} +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern +} +} + +\section{Dictionary}{ + +This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} +\link{mlr_learners} or with the associated sugar function \code{\link[=lrn]{lrn()}}:\preformatted{mlr_learners$get("classif.IBk") +lrn("classif.IBk") +} +} + +\references{ +Aha D, Kibbler D, Alber M (1991). +Instance-based learning algorithms +\url{https://link.springer.com/content/pdf/10.1007/BF00153759.pdf} +} +\section{Super classes}{ +\code{\link[mlr3:Learner]{mlr3::Learner}} -> \code{\link[mlr3:LearnerClassif]{mlr3::LearnerClassif}} -> \code{LearnerClassifIBk} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-new}{\code{LearnerClassifIBk$new()}} +\item \href{#method-clone}{\code{LearnerClassifIBk$clone()}} +} +} +\if{html}{ +\out{
Inherited methods} +\itemize{ +\item \out{}\href{../../mlr3/html/Learner.html#method-format}{\code{mlr3::Learner$format()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-help}{\code{mlr3::Learner$help()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict}{\code{mlr3::Learner$predict()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict_newdata}{\code{mlr3::Learner$predict_newdata()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-print}{\code{mlr3::Learner$print()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-reset}{\code{mlr3::Learner$reset()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-train}{\code{mlr3::Learner$train()}}\out{} +} +\out{
} +} +\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{LearnerClassifIBk$new()}\if{html}{\out{
}} +} + +} +\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}{ +\if{html}{\out{
}}\preformatted{LearnerClassifIBk$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/mlr_learners_classif.J48.Rd b/man/mlr_learners_classif.J48.Rd index ff7ac27..e262bc5 100644 --- a/man/mlr_learners_classif.J48.Rd +++ b/man/mlr_learners_classif.J48.Rd @@ -7,16 +7,31 @@ \description{ A \link[mlr3:LearnerClassif]{mlr3::LearnerClassif} implementing classification J48 from package \CRANpkg{RWeka}. Calls \code{\link[RWeka:J48]{RWeka::J48()}}. +} +\section{Custom mlr3 defaults}{ -This Learner contains changed ids of the following control-agruments for, -since their ids contain irregular pattern: \itemize{ -\item mlr3learner: output_debug_info RWeka: output-debug-info -\item mlr3learner: do_not_check_capabilities RWeka: do-not-check-capabilities -\item mlr3learner: num_decimal_places RWeka: num-decimal-places -\item mlr3learner: batch_size RWeka: batch-size +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size } +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern } +} + \section{Dictionary}{ This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} diff --git a/man/mlr_learners_classif.JRip.Rd b/man/mlr_learners_classif.JRip.Rd index 914fc92..d99a3d9 100644 --- a/man/mlr_learners_classif.JRip.Rd +++ b/man/mlr_learners_classif.JRip.Rd @@ -7,16 +7,31 @@ \description{ A \link[mlr3:LearnerClassif]{mlr3::LearnerClassif} implementing classification JRip from package \CRANpkg{RWeka}. Calls \code{\link[RWeka:JRip]{RWeka::JRip()}}. +} +\section{Custom mlr3 defaults}{ -This Learner contains changed ids of the following control-agruments for, -since their ids contain irregular pattern: \itemize{ -\item mlr3learner: output_debug_info RWeka: output-debug-info -\item mlr3learner: do_not_check_capabilities RWeka: do-not-check-capabilities -\item mlr3learner: num_decimal_places RWeka: num-decimal-places -\item mlr3learner: batch_size RWeka: batch-size +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size } +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern } +} + \section{Dictionary}{ This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} diff --git a/man/mlr_learners_classif.LMT.Rd b/man/mlr_learners_classif.LMT.Rd new file mode 100644 index 0000000..a025e93 --- /dev/null +++ b/man/mlr_learners_classif.LMT.Rd @@ -0,0 +1,97 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/LearnerClassifLMT.R +\name{mlr_learners_classif.LMT} +\alias{mlr_learners_classif.LMT} +\alias{LearnerClassifLMT} +\title{Classification Logistic Model Trees Learner} +\description{ +A \link[mlr3:LearnerClassif]{mlr3::LearnerClassif} implementing classification LMT from package \CRANpkg{RWeka}. +} +\section{Custom mlr3 defaults}{ + +\itemize{ +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size +} +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern +} +} + +\section{Dictionary}{ + +This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} +\link{mlr_learners} or with the associated sugar function \code{\link[=lrn]{lrn()}}:\preformatted{mlr_learners$get("classif.LMT") +lrn("classif.LMT") +} +} + +\references{ +Landwehr N, Hall M, Frank E (2005). +Logistic Model Trees +\url{https://link.springer.com/content/pdf/10.1007/s10994-005-0466-3.pdf} +} +\section{Super classes}{ +\code{\link[mlr3:Learner]{mlr3::Learner}} -> \code{\link[mlr3:LearnerClassif]{mlr3::LearnerClassif}} -> \code{LearnerClassifLMT} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-new}{\code{LearnerClassifLMT$new()}} +\item \href{#method-clone}{\code{LearnerClassifLMT$clone()}} +} +} +\if{html}{ +\out{
Inherited methods} +\itemize{ +\item \out{}\href{../../mlr3/html/Learner.html#method-format}{\code{mlr3::Learner$format()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-help}{\code{mlr3::Learner$help()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict}{\code{mlr3::Learner$predict()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict_newdata}{\code{mlr3::Learner$predict_newdata()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-print}{\code{mlr3::Learner$print()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-reset}{\code{mlr3::Learner$reset()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-train}{\code{mlr3::Learner$train()}}\out{} +} +\out{
} +} +\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{LearnerClassifLMT$new()}\if{html}{\out{
}} +} + +} +\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}{ +\if{html}{\out{
}}\preformatted{LearnerClassifLMT$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/mlr_learners_classif.OneR.Rd b/man/mlr_learners_classif.OneR.Rd new file mode 100644 index 0000000..c05b449 --- /dev/null +++ b/man/mlr_learners_classif.OneR.Rd @@ -0,0 +1,98 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/LearnerClassifOneR.R +\name{mlr_learners_classif.OneR} +\alias{mlr_learners_classif.OneR} +\alias{LearnerClassifOneR} +\title{Classification OneR Learner} +\description{ +A \link[mlr3:LearnerClassif]{mlr3::LearnerClassif} implementing classification PART from package \CRANpkg{RWeka}. +Calls \code{\link[RWeka:OneR]{RWeka::OneR()}}. +} +\section{Custom mlr3 defaults}{ + +\itemize{ +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size +} +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern +} +} + +\section{Dictionary}{ + +This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} +\link{mlr_learners} or with the associated sugar function \code{\link[=lrn]{lrn()}}:\preformatted{mlr_learners$get("classif.OneR") +lrn("classif.OneR") +} +} + +\references{ +Holte R (1993). +Very Simple Classification Rules Perform Well on Most Commonly Used Datasets +\url{https://link.springer.com/content/pdf/10.1023/A:1022631118932.pdf} +} +\section{Super classes}{ +\code{\link[mlr3:Learner]{mlr3::Learner}} -> \code{\link[mlr3:LearnerClassif]{mlr3::LearnerClassif}} -> \code{LearnerClassifOneR} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-new}{\code{LearnerClassifOneR$new()}} +\item \href{#method-clone}{\code{LearnerClassifOneR$clone()}} +} +} +\if{html}{ +\out{
Inherited methods} +\itemize{ +\item \out{}\href{../../mlr3/html/Learner.html#method-format}{\code{mlr3::Learner$format()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-help}{\code{mlr3::Learner$help()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict}{\code{mlr3::Learner$predict()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict_newdata}{\code{mlr3::Learner$predict_newdata()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-print}{\code{mlr3::Learner$print()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-reset}{\code{mlr3::Learner$reset()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-train}{\code{mlr3::Learner$train()}}\out{} +} +\out{
} +} +\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{LearnerClassifOneR$new()}\if{html}{\out{
}} +} + +} +\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}{ +\if{html}{\out{
}}\preformatted{LearnerClassifOneR$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/mlr_learners_classif.PART.Rd b/man/mlr_learners_classif.PART.Rd new file mode 100644 index 0000000..176124a --- /dev/null +++ b/man/mlr_learners_classif.PART.Rd @@ -0,0 +1,97 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/LearnerClassifPART.R +\name{mlr_learners_classif.PART} +\alias{mlr_learners_classif.PART} +\alias{LearnerClassifPART} +\title{Classification PART Learner} +\description{ +A \link[mlr3:LearnerClassif]{mlr3::LearnerClassif} implementing classification PART from package \CRANpkg{RWeka}. +Calls \code{\link[RWeka:PART]{RWeka::PART()}}. +} +\section{Custom mlr3 defaults}{ + +\itemize{ +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size +} +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern +} +} + +\section{Dictionary}{ + +This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} +\link{mlr_learners} or with the associated sugar function \code{\link[=lrn]{lrn()}}:\preformatted{mlr_learners$get("classif.PART") +lrn("classif.PART") +} +} + +\references{ +Frank E, Witten I (1998). +Generating Accurate Rule Sets Without Global Optimization +} +\section{Super classes}{ +\code{\link[mlr3:Learner]{mlr3::Learner}} -> \code{\link[mlr3:LearnerClassif]{mlr3::LearnerClassif}} -> \code{LearnerClassifPART} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-new}{\code{LearnerClassifPART$new()}} +\item \href{#method-clone}{\code{LearnerClassifPART$clone()}} +} +} +\if{html}{ +\out{
Inherited methods} +\itemize{ +\item \out{}\href{../../mlr3/html/Learner.html#method-format}{\code{mlr3::Learner$format()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-help}{\code{mlr3::Learner$help()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict}{\code{mlr3::Learner$predict()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict_newdata}{\code{mlr3::Learner$predict_newdata()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-print}{\code{mlr3::Learner$print()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-reset}{\code{mlr3::Learner$reset()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-train}{\code{mlr3::Learner$train()}}\out{} +} +\out{
} +} +\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{LearnerClassifPART$new()}\if{html}{\out{
}} +} + +} +\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}{ +\if{html}{\out{
}}\preformatted{LearnerClassifPART$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/mlr_learners_regr.IBk.Rd b/man/mlr_learners_regr.IBk.Rd new file mode 100644 index 0000000..b6546b3 --- /dev/null +++ b/man/mlr_learners_regr.IBk.Rd @@ -0,0 +1,98 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/LearnerRegrIBk.R +\name{mlr_learners_regr.IBk} +\alias{mlr_learners_regr.IBk} +\alias{LearnerRegrIBk} +\title{Regression IBk Learner} +\description{ +A \link[mlr3:LearnerRegr]{mlr3::LearnerRegr} implementing classification JRip from package \CRANpkg{RWeka}. +Calls \code{\link[RWeka:IBk]{RWeka::IBk()}}. +} +\section{Custom mlr3 defaults}{ + +\itemize{ +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size +} +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern +} +} + +\section{Dictionary}{ + +This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} +\link{mlr_learners} or with the associated sugar function \code{\link[=lrn]{lrn()}}:\preformatted{mlr_learners$get("regr.IBk") +lrn("regr.IBk") +} +} + +\references{ +Aha D, Kibbler D, Alber M (1991). +Instance-based learning algorithms +\url{https://link.springer.com/content/pdf/10.1007/BF00153759.pdf} +} +\section{Super classes}{ +\code{\link[mlr3:Learner]{mlr3::Learner}} -> \code{\link[mlr3:LearnerRegr]{mlr3::LearnerRegr}} -> \code{LearnerRegrIBk} +} +\section{Methods}{ +\subsection{Public methods}{ +\itemize{ +\item \href{#method-new}{\code{LearnerRegrIBk$new()}} +\item \href{#method-clone}{\code{LearnerRegrIBk$clone()}} +} +} +\if{html}{ +\out{
Inherited methods} +\itemize{ +\item \out{}\href{../../mlr3/html/Learner.html#method-format}{\code{mlr3::Learner$format()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-help}{\code{mlr3::Learner$help()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict}{\code{mlr3::Learner$predict()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-predict_newdata}{\code{mlr3::Learner$predict_newdata()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-print}{\code{mlr3::Learner$print()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-reset}{\code{mlr3::Learner$reset()}}\out{} +\item \out{}\href{../../mlr3/html/Learner.html#method-train}{\code{mlr3::Learner$train()}}\out{} +} +\out{
} +} +\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{LearnerRegrIBk$new()}\if{html}{\out{
}} +} + +} +\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}{ +\if{html}{\out{
}}\preformatted{LearnerRegrIBk$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/mlr_learners_regr.M5Rules.Rd b/man/mlr_learners_regr.M5Rules.Rd index 3fe330c..5dad14a 100644 --- a/man/mlr_learners_regr.M5Rules.Rd +++ b/man/mlr_learners_regr.M5Rules.Rd @@ -3,20 +3,35 @@ \name{mlr_learners_regr.M5Rules} \alias{mlr_learners_regr.M5Rules} \alias{LearnerRegrM5Rules} -\title{Regrssion M5Rules Learner} +\title{Regression M5Rules Learner} \description{ A \link[mlr3:LearnerRegr]{mlr3::LearnerRegr} implementing classification JRip from package \CRANpkg{RWeka}. Calls \code{\link[RWeka:M5Rules]{RWeka::M5Rules()}}. +} +\section{Custom mlr3 defaults}{ -This Learner contains changed ids of the following control-agruments for, -since their ids contain irregular pattern: \itemize{ -\item mlr3learner: output_debug_info RWeka: output-debug-info -\item mlr3learner: do_not_check_capabilities RWeka: do-not-check-capabilities -\item mlr3learner: num_decimal_places RWeka: num-decimal-places -\item mlr3learner: batch_size RWeka: batch-size +\item \code{output_debug_info}: +\itemize{ +\item original id: output-debug-info +} +\item \code{do_not_check_capabilities}: +\itemize{ +\item original id: do-not-check-capabilities +} +\item \code{num_decimal_places}: +\itemize{ +\item original id: num-decimal-places +} +\item \code{batch_size}: +\itemize{ +\item original id: batch-size } +\item Reason for change: This learner contains changed ids of the following control arguments +since their ids contain irregular pattern } +} + \section{Dictionary}{ This \link{Learner} can be instantiated via the \link[mlr3misc:Dictionary]{dictionary} @@ -28,7 +43,8 @@ lrn("regr.M5Rules") \references{ Hall M, Et al. (1999) Generating rule sets from model trees -In: Proceedings of the Twelfth Australian Joint Conference on Artificial Intelligence, pages 1- 12. +In: Proceedings of the Twelfth Australian Joint Conference on +Artificial Intelligence, pages 1- 12. \url{http://citeseer.ist.psu.edu/holmes99generating.html} } \section{Super classes}{ diff --git a/tests/testthat/test_classif_AdaBoostM1.R b/tests/testthat/test_classif_AdaBoostM1.R new file mode 100644 index 0000000..bfb87af --- /dev/null +++ b/tests/testthat/test_classif_AdaBoostM1.R @@ -0,0 +1,10 @@ +context("classif.AdaBoostM1") + +skip_on_os("windows") + +test_that("autotest", { + learner = LearnerClassifAdaBoostM1$new() + expect_learner(learner) + result = run_autotest(learner) + expect_true(result, info = result$error) +}) diff --git a/tests/testthat/test_classif_IBk.R b/tests/testthat/test_classif_IBk.R new file mode 100644 index 0000000..c5ef42a --- /dev/null +++ b/tests/testthat/test_classif_IBk.R @@ -0,0 +1,10 @@ +context("classif.IBk") + +skip_on_os("windows") + +test_that("autotest", { + learner = LearnerClassifIBk$new() + expect_learner(learner) + result = run_autotest(learner) + expect_true(result, info = result$error) +}) diff --git a/tests/testthat/test_classif_LMT.R b/tests/testthat/test_classif_LMT.R new file mode 100644 index 0000000..c34e6b1 --- /dev/null +++ b/tests/testthat/test_classif_LMT.R @@ -0,0 +1,10 @@ +context("classif.LMT") + +skip_on_os("windows") + +test_that("autotest", { + learner = LearnerClassifLMT$new() + expect_learner(learner) + result = run_autotest(learner) + expect_true(result, info = result$error) +}) diff --git a/tests/testthat/test_classif_OneR.R b/tests/testthat/test_classif_OneR.R new file mode 100644 index 0000000..c09920e --- /dev/null +++ b/tests/testthat/test_classif_OneR.R @@ -0,0 +1,10 @@ +context("classif.OneR") + +skip_on_os("windows") + +test_that("autotest", { + learner = LearnerClassifOneR$new() + expect_learner(learner) + result = run_autotest(learner) + expect_true(result, info = result$error) +}) diff --git a/tests/testthat/test_classif_PART.R b/tests/testthat/test_classif_PART.R new file mode 100644 index 0000000..54b6a89 --- /dev/null +++ b/tests/testthat/test_classif_PART.R @@ -0,0 +1,10 @@ +context("classif.PART") + +skip_on_os("windows") + +test_that("autotest", { + learner = LearnerClassifPART$new() + expect_learner(learner) + result = run_autotest(learner) + expect_true(result, info = result$error) +}) diff --git a/tests/testthat/test_regr_IBk.R b/tests/testthat/test_regr_IBk.R new file mode 100644 index 0000000..951f418 --- /dev/null +++ b/tests/testthat/test_regr_IBk.R @@ -0,0 +1,10 @@ +context("regr.IBk") + +skip_on_os("windows") + +test_that("autotest", { + learner = LearnerRegrIBk$new() + expect_learner(learner) + result = run_autotest(learner) + expect_true(result, info = result$error) +})