+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/update-tic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on:
workflow_dispatch:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 4 * * *"
- cron: "0 4 * * 0" # every week

name: Update tic

Expand All @@ -23,27 +23,26 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
persist-credentials: false

- uses: r-lib/actions/setup-r@master
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
Ncpus: 4

- name: "[Stage] Dependencies"
run: |
sudo apt install libcurl4-openssl-dev libsodium-dev libharfbuzz-dev libfribidi-dev libgit2-dev
Rscript -e "if (!requireNamespace('remotes')) install.packages('remotes', type = 'source')"
Rscript -e "remotes::install_github('ropensci/tic', dependencies = TRUE)"
Rscript -e "install.packages('pak', repos = 'https://r-lib.github.io/p/pak/stable')"
Rscript -e "if (grepl('Ubuntu', Sys.info()[['version']])) {options(repos = c(CRAN = sprintf('https://packagemanager.rstudio.com/all/__linux__/%s/latest', system('lsb_release -cs', intern = TRUE))))}; pak::pkg_install('ropensci/tic', dependencies = TRUE)"

- name: "[Stage] Update YAMLs"
run: |
Rscript -e "tic::update_yml()"

- name: "[Stage] Create Pull Request"
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v4
with:
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
token: ${{ secrets.TIC_UPDATE }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2
rev: v0.3.2.9003
hooks:
- id: style-files
args: [--style_pkg=styler.mlr, --style_fun=mlr_style]
Expand Down
15 changes: 0 additions & 15 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@
## Chore

- do not use deprecated function from mlr3misc

## Uncategorized

- Improve PipeOpFilter docu (@66853113+pre-commit-ci[bot], #135)

- [github.com/lorenzwalthert/precommit: v0.3.0 → v0.3.2](https://github.com/lorenzwalthert/precommit/compare/v0.3.0...v0.3.2) (@66853113+pre-commit-ci[bot], #129)

- [github.com/pre-commit/pre-commit-hooks: v4.2.0 → v4.3.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.2.0...v4.3.0) (@66853113+pre-commit-ci[bot], #129)

- [pre-commit.ci] pre-commit autoupdate (@66853113+pre-commit-ci[bot], #128)

- [github.com/lorenzwalthert/precommit: v0.2.2.9015 → v0.3.0](https://github.com/lorenzwalthert/precommit/compare/v0.2.2.9015...v0.3.0) (@66853113+pre-commit-ci[bot], #128)

- [pre-commit.ci] auto fixes from pre-commit.com hooks (@66853113+pre-commit-ci[bot], #128)

- Use featureless learner in defaults (#124)


Expand Down
32 changes: 21 additions & 11 deletions R/Filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ Filter = R6Class("Filter",
#' Can be used in tables, plot and text output instead of the ID.
label = NA_character_,

#' @field task_type (`character(1)`)\cr
#' Task type, e.g. `"classif"` or `"regr"`.
#' Can be set to `NA` to allow all task types.
#' @field task_types (`character()`)\cr
#' Set of supported task types, e.g. `"classif"` or `"regr"`.
#' Can be set to the scalar value `NA` to allow any task type.
#'
#' For a complete list of possible task types (depending on the loaded packages),
#' see [`mlr_reflections$task_types$type`][mlr_reflections].
task_type = NULL,
task_types = NULL,

#' @field task_properties (`character()`)\cr
#' [mlr3::Task]task properties.
Expand Down Expand Up @@ -67,9 +67,9 @@ Filter = R6Class("Filter",
#' @description Create a Filter object.
#' @param id (`character(1)`)\cr
#' Identifier for the filter.
#' @param task_type (`character()`)\cr
#' @param task_types (`character()`)\cr
#' Types of the task the filter can operator on. E.g., `"classif"` or
#' `"regr"`. Can be set to `NA` to allow all task types.
#' `"regr"`. Can be set to scalar `NA` to allow any task type.
#' @param param_set ([paradox::ParamSet])\cr
#' Set of hyperparameters.
#' @param feature_types (`character()`)\cr
Expand All @@ -90,18 +90,18 @@ Filter = R6Class("Filter",
#' String in the format `[pkg]::[topic]` pointing to a manual page for
#' this object. The referenced help package can be opened via method
#' `$help()`.
initialize = function(id, task_type, task_properties = character(),
initialize = function(id, task_types, task_properties = character(),
param_set = ps(), feature_types = character(),
packages = character(), label = NA_character_, man = NA_character_) {

self$id = assert_string(id)
self$label = assert_string(label, na.ok = TRUE)
if (!test_scalar_na(task_type)) {
if (!test_scalar_na(task_types)) {
# we allow any task type here, otherwise we are not able to construct
# the filter without loading additional packages like mlr3proba
assert_character(task_type, any.missing = FALSE)
assert_character(task_types, any.missing = FALSE)
}
self$task_type = task_type
self$task_types = task_types
self$task_properties = assert_subset(
task_properties,
unlist(mlr_reflections$task_properties, use.names = FALSE))
Expand All @@ -124,7 +124,7 @@ Filter = R6Class("Filter",
#' Printer for Filter class
print = function() {
catn(format(self), if (is.na(self$label)) "" else paste0(": ", self$label))
catn(str_indent("Task Types:", self$task_type))
catn(str_indent("Task Types:", self$task_types))
catn(str_indent("Task Properties:", self$task_properties))
catn(str_indent("Packages:", self$packages))
catn(str_indent("Feature types:", self$feature_types))
Expand Down Expand Up @@ -162,6 +162,11 @@ Filter = R6Class("Filter",
task = assert_task(as_task(task),
feature_types = self$feature_types,
task_properties = self$task_properties)

if (!is_scalar_na(self$task_types) && task$task_type %nin% self$task_types) {
stopf("Filter '%s' does not support the type '%s' of task '%s'",
self$id, task$task_type, task$id)
}
fn = task$feature_names

if (task$nrow == 0L) {
Expand All @@ -176,6 +181,11 @@ Filter = R6Class("Filter",
nfeat = min(nfeat, length(fn))
}

if (any(task$missings() > 0L)) {
stopf("Cannot apply filter '%s' on task '%s', missing values detected",
self$id, task$id)
}

# calculate filter values using the dedicated filter
require_namespaces(self$packages)
scores = private$.calculate(task, nfeat)
Expand Down
4 changes: 2 additions & 2 deletions R/FilterAUC.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' @template seealso_filter
#' @export
#' @examples
#' task = mlr3::tsk("pima")
#' task = mlr3::tsk("sonar")
#' filter = flt("auc")
#' filter$calculate(task)
#' head(as.data.table(filter), 3)
Expand All @@ -43,7 +43,7 @@ FilterAUC = R6Class("FilterAUC",
initialize = function() {
super$initialize(
id = "auc",
task_type = "classif",
task_types = "classif",
task_properties = "twoclass",
feature_types = c("integer", "numeric"),
packages = "mlr3measures",
Expand Down
2 changes: 1 addition & 1 deletion R/FilterAnova.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ FilterAnova = R6Class("FilterAnova",
id = "anova",
packages = "stats",
feature_types = c("integer", "numeric"),
task_type = "classif",
task_types = "classif",
label = "ANOVA F-Test",
man = "mlr3filters::mlr_filters_anova"
)
Expand Down
2 changes: 1 addition & 1 deletion R/FilterCMIM.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ FilterCMIM = R6Class("FilterCMIM",

super$initialize(
id = "cmim",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
feature_types = c("integer", "numeric", "factor", "ordered"),
packages = "praznik",
Expand Down
2 changes: 1 addition & 1 deletion R/FilterCarScore.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ FilterCarScore = R6Class("FilterCarScore",

super$initialize(
id = "carscore",
task_type = "regr",
task_types = "regr",
param_set = param_set,
feature_types = "numeric",
packages = "care",
Expand Down
2 changes: 1 addition & 1 deletion R/FilterCarSurvScore.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ FilterCarSurvScore = R6Class("FilterCarSurvScore",
packages = c("carSurv", "mlr3proba"),
param_set = ps,
feature_types = c("integer", "numeric"),
task_type = "surv",
task_types = "surv",
label = "Correlation-Adjusted coRrelation Survival Score",
man = "mlr3filters::mlr_filters_carsurvscore"
)
Expand Down
2 changes: 1 addition & 1 deletion R/FilterCorrelation.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ FilterCorrelation = R6Class("FilterCorrelation",

super$initialize(
id = "correlation",
task_type = "regr",
task_types = "regr",
param_set = param_set,
feature_types = c("integer", "numeric"),
packages = "stats",
Expand Down
2 changes: 1 addition & 1 deletion R/FilterDISR.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ FilterDISR = R6Class("FilterDISR",

super$initialize(
id = "disr",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
feature_types = c("integer", "numeric", "factor", "ordered"),
packages = "praznik",
Expand Down
2 changes: 1 addition & 1 deletion R/FilterFindCorrelation.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ FilterFindCorrelation = R6Class("FilterFindCorrelation",

super$initialize(
id = "find_correlation",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
feature_types = c("integer", "numeric"),
packages = "stats",
Expand Down
2 changes: 1 addition & 1 deletion R/FilterImportance.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ FilterImportance = R6Class("FilterImportance",

super$initialize(
id = "importance",
task_type = learner$task_type,
task_types = learner$task_type,
feature_types = learner$feature_types,
packages = learner$packages,
param_set = learner$param_set,
Expand Down
4 changes: 2 additions & 2 deletions R/FilterInformationGain.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' @examples
#' if (requireNamespace("FSelectorRcpp")) {
#' ## InfoGain (default)
#' task = mlr3::tsk("pima")
#' task = mlr3::tsk("sonar")
#' filter = flt("information_gain")
#' filter$calculate(task)
#' head(filter$scores, 3)
Expand Down Expand Up @@ -61,7 +61,7 @@ FilterInformationGain = R6Class("FilterInformationGain",

super$initialize(
id = "information_gain",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
feature_types = c("integer", "numeric", "factor", "ordered"),
packages = "FSelectorRcpp",
Expand Down
2 changes: 1 addition & 1 deletion R/FilterJMI.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ FilterJMI = R6Class("FilterJMI",

super$initialize(
id = "jmi",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
packages = "praznik",
feature_types = c("integer", "numeric", "factor", "ordered"),
Expand Down
2 changes: 1 addition & 1 deletion R/FilterJMIM.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ FilterJMIM = R6Class("FilterJMIM",
param_set$values = list(threads = 1L)
super$initialize(
id = "jmim",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
packages = "praznik",
feature_types = c("integer", "numeric", "factor", "ordered"),
Expand Down
2 changes: 1 addition & 1 deletion R/FilterKruskalTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ FilterKruskalTest = R6Class("FilterKruskalTest",

super$initialize(
id = "kruskal_test",
task_type = "classif",
task_types = "classif",
param_set = param_set,
packages = "stats",
feature_types = c("integer", "numeric"),
Expand Down
2 changes: 1 addition & 1 deletion R/FilterMIM.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ FilterMIM = R6Class("FilterMIM",

super$initialize(
id = "mim",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
packages = "praznik",
feature_types = c("integer", "numeric", "factor", "ordered"),
Expand Down
2 changes: 1 addition & 1 deletion R/FilterMRMR.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ FilterMRMR = R6Class("FilterMRMR",

super$initialize(
id = "mrmr",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
packages = "praznik",
feature_types = c("integer", "numeric", "factor", "ordered"),
Expand Down
2 changes: 1 addition & 1 deletion R/FilterNJMIM.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ FilterNJMIM = R6Class("FilterNJMIM",
param_set$values = list(threads = 1L)
super$initialize(
id = "njmim",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
packages = "praznik",
feature_types = c("integer", "numeric", "factor", "ordered"),
Expand Down
2 changes: 1 addition & 1 deletion R/FilterPerformance.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FilterPerformance = R6Class("FilterPerformance",

super$initialize(
id = "performance",
task_type = learner$task_type,
task_types = learner$task_type,
param_set = learner$param_set,
feature_types = learner$feature_types,
packages = packages,
Expand Down
2 changes: 1 addition & 1 deletion R/FilterPermutation.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ FilterPermutation = R6Class("FilterPermutation",

super$initialize(
id = "permutation",
task_type = learner$task_type,
task_types = learner$task_type,
feature_types = learner$feature_types,
packages = packages,
param_set = param_set,
Expand Down
4 changes: 2 additions & 2 deletions R/FilterRelief.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @examples
#' if (requireNamespace("FSelectorRcpp")) {
#' ## Relief (default)
#' task = mlr3::tsk("pima")
#' task = mlr3::tsk("sonar")
#' filter = flt("relief")
#' filter$calculate(task)
#' head(filter$scores, 3)
Expand Down Expand Up @@ -43,7 +43,7 @@ FilterRelief = R6Class("FilterRelief",

super$initialize(
id = "relief",
task_type = c("classif", "regr"),
task_types = c("classif", "regr"),
param_set = param_set,
feature_types = c("integer", "numeric", "factor", "ordered"),
packages = "FSelectorRcpp",
Expand Down
2 changes: 1 addition & 1 deletion R/FilterSelectedFeatures.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ FilterSelectedFeatures = R6Class("FilterSelectedFeatures",

super$initialize(
id = "selected_features",
task_type = learner$task_type,
task_types = learner$task_type,
feature_types = learner$feature_types,
packages = learner$packages,
param_set = learner$param_set,
Expand Down
2 changes: 1 addition & 1 deletion R/FilterVariance.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ FilterVariance = R6Class("FilterVariance",

super$initialize(
id = "variance",
task_type = NA_character_,
task_types = NA_character_,
param_set = param_set,
packages = "stats",
feature_types = c("integer", "numeric"),
Expand Down
2 changes: 1 addition & 1 deletion R/mlr_filters.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ as.data.table.DictionaryFilter = function(x, ..., objects = FALSE) {
setkeyv(map_dtr(x$keys(), function(key) {
f = x$get(key)
insert_named(
list(key = key, label = f$label, task_type = list(f$task_type),
list(key = key, label = f$label, task_types = list(f$task_types),
task_properties = list(f$task_properties), params = list(f$param_set$ids()),
feature_types = list(f$feature_types), packages = list(f$packages)),
if (objects) list(object = list(f))
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载