Skip to content

Commit 5f24742

Browse files
committed
disable threading, tag hyperpars
1 parent db9d756 commit 5f24742

17 files changed

+62
-39
lines changed

R/FilterCMIM.R

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ FilterCMIM = R6Class("FilterCMIM",
2424
#' @description Create a FilterCMIM object.
2525
initialize = function() {
2626
param_set = ParamSet$new(list(
27-
ParamInt$new("threads", lower = 0L, default = 0L)
27+
ParamInt$new("threads", lower = 0L, default = 0L, tags = "threads")
2828
))
29+
param_set$values = list(threads = 1L)
2930

3031
super$initialize(
3132
id = "cmim",
@@ -40,10 +41,7 @@ FilterCMIM = R6Class("FilterCMIM",
4041

4142
private = list(
4243
.calculate = function(task, nfeat) {
43-
threads = self$param_set$values$threads %??% 0L
44-
X = task$data(cols = task$feature_names)
45-
Y = task$truth()
46-
reencode_praznik_score(praznik::CMIM(X = X, Y = Y, k = nfeat, threads = threads))
44+
call_praznik(self, task, praznik::CMIM)
4745
}
4846
)
4947
)

R/FilterDISR.R

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ FilterDISR = R6Class("FilterDISR",
2424
#' @description Create a FilterDISR object.
2525
initialize = function() {
2626
param_set = ParamSet$new(list(
27-
ParamInt$new("threads", lower = 0L, default = 0L)
27+
ParamInt$new("threads", lower = 0L, default = 0L, tags = "threads")
2828
))
29+
param_set$values = list(threads = 1L)
2930

3031
super$initialize(
3132
id = "disr",
@@ -40,10 +41,7 @@ FilterDISR = R6Class("FilterDISR",
4041

4142
private = list(
4243
.calculate = function(task, nfeat) {
43-
threads = self$param_set$values$threads %??% 0L
44-
X = task$data(cols = task$feature_names)
45-
Y = task$truth()
46-
reencode_praznik_score(praznik::DISR(X = X, Y = Y, k = nfeat, threads = threads))
44+
call_praznik(self, task, praznik::DISR)
4745
}
4846
)
4947
)

R/FilterInformationGain.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ FilterInformationGain = R6Class("FilterInformationGain",
4141
default = "infogain"),
4242
ParamLgl$new("equal", default = FALSE),
4343
ParamLgl$new("discIntegers", default = TRUE),
44-
ParamInt$new("threads", lower = 0L, default = 1L)
44+
ParamInt$new("threads", lower = 1L, default = 1L, tags = "threads")
4545
))
4646

4747
super$initialize(

R/FilterJMI.R

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ FilterJMI = R6Class("FilterJMI",
2424
#' @description Create a FilterJMI object.
2525
initialize = function() {
2626
param_set = ParamSet$new(list(
27-
ParamInt$new("threads", lower = 0L, default = 0L)
27+
ParamInt$new("threads", lower = 0L, default = 0L, tags = "threads")
2828
))
29+
param_set$values = list(threads = 1L)
2930

3031
super$initialize(
3132
id = "jmi",
@@ -40,10 +41,7 @@ FilterJMI = R6Class("FilterJMI",
4041

4142
private = list(
4243
.calculate = function(task, nfeat) {
43-
threads = self$param_set$values$threads %??% 0L
44-
X = task$data(cols = task$feature_names)
45-
Y = task$truth()
46-
reencode_praznik_score(praznik::JMI(X = X, Y = Y, k = nfeat, threads = threads))
44+
call_praznik(self, task, praznik::JMI)
4745
}
4846
)
4947
)

R/FilterJMIM.R

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ FilterJMIM = R6Class("FilterJMIM",
2525
initialize = function() {
2626

2727
param_set = ParamSet$new(list(
28-
ParamInt$new("threads", lower = 0L, default = 0L)
28+
ParamInt$new("threads", lower = 0L, default = 0L, tags = "threads")
2929
))
30+
param_set$values = list(threads = 1L)
3031
super$initialize(
3132
id = "jmim",
3233
task_type = c("classif", "regr"),
@@ -40,10 +41,7 @@ FilterJMIM = R6Class("FilterJMIM",
4041

4142
private = list(
4243
.calculate = function(task, nfeat) {
43-
threads = self$param_set$values$threads %??% 0L
44-
X = task$data(cols = task$feature_names)
45-
Y = task$truth()
46-
reencode_praznik_score(praznik::JMIM(X = X, Y = Y, k = nfeat, threads = threads))
44+
call_praznik(self, task, praznik::JMIM)
4745
}
4846
)
4947
)

R/FilterMIM.R

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ FilterMIM = R6Class("FilterMIM",
2424
#' @description Create a FilterMIM object.
2525
initialize = function() {
2626
param_set = ParamSet$new(list(
27-
ParamInt$new("threads", lower = 0L, default = 0L)
27+
ParamInt$new("threads", lower = 0L, default = 0L, tags = "threads")
2828
))
29+
param_set$values = list(threads = 1L)
2930

3031
super$initialize(
3132
id = "mim",
@@ -40,10 +41,7 @@ FilterMIM = R6Class("FilterMIM",
4041

4142
private = list(
4243
.calculate = function(task, nfeat) {
43-
threads = self$param_set$values$threads %??% 0L
44-
X = task$data(cols = task$feature_names)
45-
Y = task$truth()
46-
reencode_praznik_score(praznik::MIM(X = X, Y = Y, k = nfeat, threads = threads))
44+
call_praznik(self, task, praznik::MIM)
4745
}
4846
)
4947
)

R/FilterMRMR.R

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ FilterMRMR = R6Class("FilterMRMR",
2424
#' @description Create a FilterMRMR object.
2525
initialize = function() {
2626
param_set = ParamSet$new(list(
27-
ParamInt$new("threads", lower = 0L, default = 0L)
27+
ParamInt$new("threads", lower = 0L, default = 0L, tags = "threads")
2828
))
29+
param_set$values = list(threads = 1L)
2930

3031
super$initialize(
3132
id = "mrmr",
@@ -40,10 +41,7 @@ FilterMRMR = R6Class("FilterMRMR",
4041

4142
private = list(
4243
.calculate = function(task, nfeat) {
43-
threads = self$param_set$values$threads %??% 0L
44-
X = task$data(cols = task$feature_names)
45-
Y = task$truth()
46-
reencode_praznik_score(praznik::MRMR(X = X, Y = Y, k = nfeat, threads = threads))
44+
call_praznik(self, task, praznik::MRMR)
4745
}
4846
)
4947
)

R/FilterNJMIM.R

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ FilterNJMIM = R6Class("FilterNJMIM",
2424
#' @description Create a FilterNJMIM object.
2525
initialize = function() {
2626
param_set = ParamSet$new(list(
27-
ParamInt$new("threads", lower = 0L, default = 0L)
27+
ParamInt$new("threads", lower = 0L, default = 0L, tags = "threads")
2828
))
29+
param_set$values = list(threads = 1L)
2930
super$initialize(
3031
id = "njmim",
3132
task_type = c("classif", "regr"),
@@ -39,10 +40,7 @@ FilterNJMIM = R6Class("FilterNJMIM",
3940

4041
private = list(
4142
.calculate = function(task, nfeat) {
42-
threads = self$param_set$values$threads %??% 0L
43-
X = task$data(cols = task$feature_names)
44-
Y = task$truth()
45-
reencode_praznik_score(praznik::NJMIM(X = X, Y = Y, k = nfeat, threads = threads))
43+
call_praznik(self, task, praznik::NJMIM)
4644
}
4745
)
4846
)

R/helper.R

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
reencode_praznik_score = function(x) {
2-
scores = x$score
3-
set_names(seq(from = 1, to = 0, length.out = length(scores)), names(scores))
1+
call_praznik = function(self, task, fun) {
2+
selection = invoke(fun,
3+
X = task$data(cols = task$feature_names),
4+
Y = task$truth(),
5+
.args = self$param_set$get_values()
6+
)$selection
7+
8+
set_names(seq(from = 1, to = 0, length.out = length(selection)), names(selection))
49
}

man-roxygen/details_praznik.R

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
#' As the scores calculated by the \CRANpkg{praznik} package are not monotone due
33
#' to the greedy forward fashion, the returned scores simply reflect the selection order:
44
#' `1`, `(k-1)/k`, ..., `1/k` where `k` is the number of selected features.
5+
#'
6+
#' Threading is disabled by default (hyperparameter `threads` is set to 1).
7+
#' Set to a number `>= 2` to enable threading, or to `0` for auto-detecting the number
8+
#' of available cores.

man/mlr_filters_cmim.Rd

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlr_filters_disr.Rd

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlr_filters_jmi.Rd

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlr_filters_jmim.Rd

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlr_filters_mim.Rd

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlr_filters_mrmr.Rd

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mlr_filters_njmim.Rd

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)