Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help method for filters #68

Merged
merged 4 commits into from Mar 14, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -3,10 +3,15 @@ repos:
rev: v0.0.0.9027
hooks:
- id: style-files
args: [--style_fun=mlr_style]
args: [--style_pkg=styler, --style_fun=mlr_style]
- id: parsable-R
- id: no-browser-statement
- id: readme-rmd-rendered
- id: roxygenize
- id: use-tidy-description
- id: codemeta-description-updated
#- id: codemeta-description-updated
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=200']
4 changes: 2 additions & 2 deletions DESCRIPTION
Expand Up @@ -35,7 +35,7 @@ Imports:
backports,
checkmate,
data.table,
mlr3 (>= 0.1.2),
mlr3 (>= 0.1.8),
mlr3misc,
paradox,
R6
Expand All @@ -52,7 +52,7 @@ Suggests:
Encoding: UTF-8
NeedsCompilation: no
Roxygen: list(markdown = TRUE, r6 = TRUE)
RoxygenNote: 7.0.2
RoxygenNote: 7.1.0
Collate:
'Filter.R'
'mlr_filters.R'
Expand Down
18 changes: 17 additions & 1 deletion R/Filter.R
Expand Up @@ -31,6 +31,11 @@ Filter = R6Class("Filter",
feature_types = NULL,
packages = NULL,

#' @field man (`character(1)`)\cr
#' String in the format `[pkg]::[topic]` pointing to a manual page for this object.
#' Defaults to `NA`, but can be set by child classes.
man = NULL,

#' @field scores
#' Stores the calculated filter score values as named numeric vector.
#' The vector is sorted in decreasing order with possible `NA` values
Expand Down Expand Up @@ -58,9 +63,13 @@ Filter = R6Class("Filter",
#' Set of required packages.
#' Note that these packages will be loaded via [requireNamespace()], and
#' are not attached.
#' @param man (`character(1)`)\cr
#' 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(),
param_set = ParamSet$new(), feature_types = character(),
packages = character()) {
packages = character(), man = NA_character_) {

self$id = assert_string(id)
self$task_type = assert_subset(task_type, mlr_reflections$task_types$type,
Expand All @@ -73,6 +82,7 @@ Filter = R6Class("Filter",
self$packages = assert_character(packages, any.missing = FALSE,
unique = TRUE)
self$scores = set_names(numeric(), character())
self$man = assert_string(man, na.ok = TRUE)
},

#' @description
Expand All @@ -95,6 +105,12 @@ Filter = R6Class("Filter",
}
},

#' @description
#' Opens the corresponding help page referenced by field `$man`.
help = function() {
open_help(self$man) # nocov
},

#' @description
#' Calculates the filter score values for the provided [mlr3::Task] and
#' stores them in field `scores`. `nfeat` determines the minimum number of
Expand Down
3 changes: 2 additions & 1 deletion R/FilterAUC.R
Expand Up @@ -52,7 +52,8 @@ FilterAUC = R6Class("FilterAUC", inherit = Filter,
task_type = task_type,
task_properties = task_properties,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_auc"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterAnova.R
Expand Up @@ -54,7 +54,8 @@ FilterAnova = R6Class("FilterAnova", inherit = Filter,
id = id,
packages = packages,
feature_types = feature_types,
task_type = task_type
task_type = task_type,
man = "mlr3filters::mlr_filters_anova"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterCMIM.R
Expand Up @@ -47,7 +47,8 @@ FilterCMIM = R6Class("FilterCMIM", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_cmim"
)
}
),
Expand Down
4 changes: 3 additions & 1 deletion R/FilterCarScore.R
Expand Up @@ -57,7 +57,9 @@ FilterCarScore = R6Class("FilterCarScore", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_carscore"

)
self$param_set$values = list(verbose = FALSE)
}
Expand Down
3 changes: 2 additions & 1 deletion R/FilterCorrelation.R
Expand Up @@ -57,7 +57,8 @@ FilterCorrelation = R6Class("FilterCorrelation", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_correlation"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterDISR.R
Expand Up @@ -47,7 +47,8 @@ FilterDISR = R6Class("FilterDISR", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_disr"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterFindCorrelation.R
Expand Up @@ -65,7 +65,8 @@ FilterFindCorrelation = R6Class("FilterFindCorrelation", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_find_correlation"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterImportance.R
Expand Up @@ -55,7 +55,8 @@ FilterImportance = R6Class("FilterImportance", inherit = Filter,
task_type = task_type,
feature_types = feature_types,
packages = packages,
param_set = param_set
param_set = param_set,
man = "mlr3filters::mlr_filters_importance"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterInformationGain.R
Expand Up @@ -64,7 +64,8 @@ FilterInformationGain = R6Class("FilterInformationGain", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_information_gain"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterJMI.R
Expand Up @@ -47,7 +47,8 @@ FilterJMI = R6Class("FilterJMI", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_jmi"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterJMIM.R
Expand Up @@ -47,7 +47,8 @@ FilterJMIM = R6Class("FilterJMIM", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_jmim"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterKruskalTest.R
Expand Up @@ -53,7 +53,8 @@ FilterKruskalTest = R6Class("FilterKruskalTest", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_kruskal_test"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterMIM.R
Expand Up @@ -47,7 +47,8 @@ FilterMIM = R6Class("FilterMIM", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_mim"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterMRMR.R
Expand Up @@ -47,7 +47,8 @@ FilterMRMR = R6Class("FilterMRMR", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_mrmr"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterNJMIM.R
Expand Up @@ -47,7 +47,8 @@ FilterNJMIM = R6Class("FilterNJMIM", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_njmim"
)
}
),
Expand Down
12 changes: 5 additions & 7 deletions R/FilterPerformance.R
Expand Up @@ -46,29 +46,27 @@ FilterPerformance = R6Class("FilterPerformance", inherit = Filter,
#' [mlr3::Resampling] to be used within resampling.
#' @param measure ([mlr3::Measure])\cr
#' [mlr3::Measure] to be used for evaluating the performance.
#' @param packages (`character()`)\cr
#' Set of required packages.
#' Note that these packages will be loaded via [requireNamespace()], and
#' are not attached.
initialize = function(id = "performance",
task_type = learner$task_type,
param_set = learner$param_set,
feature_types = learner$feature_types,
learner = mlr3::lrn("classif.rpart"),
resampling = mlr3::rsmp("holdout"),
measure = mlr3::msr("classif.ce"),
packages = learner$packages) {
measure = mlr3::msr("classif.ce")) {

self$learner = learner = assert_learner(as_learner(learner, clone = TRUE),
properties = "importance")
self$resampling = assert_resampling(as_resampling(resampling))
self$measure = assert_measure(as_measure(measure,
task_type = learner$task_type, clone = TRUE), learner = learner)
packages = unique(c(self$learner$packages, self$measure$packages))

super$initialize(
id = id,
task_type = task_type,
feature_types = feature_types
feature_types = feature_types,
packages = packages,
man = "mlr3filters::mlr_filters_performance"
)
}
),
Expand Down
3 changes: 2 additions & 1 deletion R/FilterVariance.R
Expand Up @@ -47,7 +47,8 @@ FilterVariance = R6Class("FilterVariance", inherit = Filter,
task_type = task_type,
param_set = param_set,
feature_types = feature_types,
packages = packages
packages = packages,
man = "mlr3filters::mlr_filters_variance"
)
self$param_set$values = list(na.rm = TRUE)
}
Expand Down
10 changes: 5 additions & 5 deletions codemeta.json
Expand Up @@ -14,14 +14,14 @@
],
"issueTracker": "https://github.com/mlr-org/mlr3filters/issues",
"license": "https://spdx.org/licenses/LGPL-3.0",
"version": "0.1.1.9002",
"version": "0.2.0.9000",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"version": "3.6.2",
"version": "3.6.3",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 3.6.2 (2019-12-12)",
"runtimePlatform": "R version 3.6.3 Patched (2020-02-29 r77919)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -226,7 +226,7 @@
"@type": "SoftwareApplication",
"identifier": "mlr3",
"name": "mlr3",
"version": ">= 0.1.2",
"version": ">= 0.1.8",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -274,7 +274,7 @@
],
"releaseNotes": "https://github.com/mlr-org/mlr3filters/blob/master/NEWS.md",
"readme": "https://github.com/mlr-org/mlr3filters/blob/master/README.md",
"fileSize": "22.613KB",
"fileSize": "23.59KB",
"contIntegration": "https://codecov.io/github/mlr-org/mlr3filters?branch=master",
"keywords": [
"filter",
Expand Down