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

refactor: prepare for bbotk 0.9.0 #102

Merged
merged 2 commits into from
May 13, 2024
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
40 changes: 23 additions & 17 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Depends:
mlr3 (>= 0.12.0),
R (>= 3.1.0)
Imports:
bbotk (>= 0.7.2),
bbotk (>= 0.8.0.9000),
checkmate (>= 2.0.0),
data.table,
lgr,
mlr3misc (>= 0.9.4),
paradox (>= 0.7.0),
mlr3misc (>= 0.15.0.9000),
paradox (>= 1.0.0),
R6
Suggests:
e1071,
Expand All @@ -39,6 +39,10 @@ Suggests:
mlr3pipelines,
rpart,
testthat (>= 3.0.0)
Remotes:
mlr-org/bbotk,
mlr-org/paradox,
mlr-org/mlr3misc
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
Expand All @@ -47,24 +51,26 @@ NeedsCompilation: no
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Collate:
'ArchiveFSelect.R'
'ArchiveBatchFSelect.R'
'AutoFSelector.R'
'CallbackFSelect.R'
'ContextEval.R'
'FSelectInstanceSingleCrit.R'
'FSelectInstanceMultiCrit.R'
'CallbackBatchFSelect.R'
'ContextBatchFSelect.R'
'FSelectInstanceBatchSingleCrit.R'
'FSelectInstanceBatchMultiCrit.R'
'mlr_fselectors.R'
'FSelector.R'
'FSelectorDesignPoints.R'
'FSelectorExhaustiveSearch.R'
'FSelectorFromOptimizer.R'
'FSelectorGeneticSearch.R'
'FSelectorRFE.R'
'FSelectorRFECV.R'
'FSelectorRandomSearch.R'
'FSelectorSequential.R'
'FSelectorShadowVariableSearch.R'
'FSelectorBatch.R'
'FSelectorBatchDesignPoints.R'
'FSelectorBatchExhaustiveSearch.R'
'FSelectorBatchFromOptimizerBatch.R'
'FSelectorBatchGeneticSearch.R'
'FSelectorBatchRFE.R'
'FSelectorBatchRFECV.R'
'FSelectorBatchRandomSearch.R'
'FSelectorBatchSequential.R'
'FSelectorBatchShadowVariableSearch.R'
'ObjectiveFSelect.R'
'ObjectiveFSelectBatch.R'
'assertions.R'
'auto_fselector.R'
'bibentries.R'
Expand Down
38 changes: 23 additions & 15 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
# Generated by roxygen2: do not edit by hand

S3method(as.data.table,ArchiveFSelect)
S3method(as.data.table,ArchiveBatchFSelect)
S3method(as.data.table,DictionaryFSelector)
S3method(extract_inner_fselect_archives,BenchmarkResult)
S3method(extract_inner_fselect_archives,ResampleResult)
S3method(extract_inner_fselect_results,BenchmarkResult)
S3method(extract_inner_fselect_results,ResampleResult)
export(ArchiveFSelect)
export(ArchiveBatchFSelect)
export(AutoFSelector)
export(ContextEval)
export(FSelectInstanceMultiCrit)
export(FSelectInstanceSingleCrit)
export(ContextBatchFSelect)
export(FSelectInstanceBatchMultiCrit)
export(FSelectInstanceBatchSingleCrit)
export(FSelector)
export(FSelectorDesignPoints)
export(FSelectorExhaustiveSearch)
export(FSelectorFromOptimizer)
export(FSelectorGeneticSearch)
export(FSelectorRFE)
export(FSelectorRFECV)
export(FSelectorRandomSearch)
export(FSelectorSequential)
export(FSelectorShadowVariableSearch)
export(FSelectorBatch)
export(FSelectorBatchDesignPoints)
export(FSelectorBatchExhaustiveSearch)
export(FSelectorBatchFromOptimizerBatch)
export(FSelectorBatchGeneticSearch)
export(FSelectorBatchRFE)
export(FSelectorBatchRFECV)
export(FSelectorBatchRandomSearch)
export(FSelectorBatchSequential)
export(FSelectorBatchShadowVariableSearch)
export(ObjectiveFSelect)
export(ObjectiveFSelectBatch)
export(assert_fselect_instance)
export(assert_fselect_instance_async)
export(assert_fselect_instance_batch)
export(assert_fselector_async)
export(assert_fselector_batch)
export(assert_fselectors)
export(auto_fselector)
export(callback_fselect)
export(callback_batch_fselect)
export(clbk)
export(clbks)
export(extract_inner_fselect_archives)
Expand Down
32 changes: 16 additions & 16 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# mlr3fselect 0.12.0

* feat: Add number of features to `instance$result`.
* feat: Add `ties_method` options `"least_features"` and `"random"` to `ArchiveFSelect$best()`.
* refactor: Optimize runtime of `ArchiveFSelect$best()` method.
* feat: Add `ties_method` options `"least_features"` and `"random"` to `ArchiveBatchFSelect$best()`.
* refactor: Optimize runtime of `ArchiveBatchFSelect$best()` method.
* feat: Add importance scores to result of `FSelectorRFE`.
* feat: Add number of features to `as.data.table.ArchiveFSelect()`.
* feat: Add number of features to `as.data.table.ArchiveBatchFSelect()`.
* feat: Features can be always included with the `always_include` column role.
* fix: Add `$phash()` method to `AutoFSelector`.
* fix: Include `FSelector` in hash of `AutoFSelector`.
* refactor: Change default batch size of `FSelectorRandomSearch` to 10.
* feat: Add `batch_size` parameter to `FSelectorExhaustiveSearch` to reduce memory consumption.
* refactor: Change default batch size of `FSelectorBatchRandomSearch` to 10.
* feat: Add `batch_size` parameter to `FSelectorBatchExhaustiveSearch` to reduce memory consumption.
* compatibility: Work with new paradox version 1.0.0

# mlr3fselect 0.11.0
Expand All @@ -29,7 +29,7 @@
* refactor: The importance scores in `FSelectorRFE` are now aggregated by rank instead of averaging them.
* feat: Add `FSelectorRFECV` optimizer to run recursive feature elimination with cross-validation.
* refactor: `FSelectorRFE` works without `store_models = TRUE` now.
* feat: The `as.data.table.ArchiveFSelect()` function additionally returns a character vector of selected features for each row.
* feat: The `as.data.table.ArchiveBatchFSelect()` function additionally returns a character vector of selected features for each row.
* refactor: Add `callbacks` argument to `fsi()` function.

# mlr3fselect 0.9.1
Expand All @@ -39,18 +39,18 @@

# mlr3fselect 0.9.0

* fix: Add `genalg` to required packages of `FSelectorGeneticSearch`.
* fix: Add `genalg` to required packages of `FSelectorBatchGeneticSearch`.
* feat: Add new callback that backups the benchmark result to disk after each batch.
* feat: Create custom callbacks with the `callback_fselect()` function.
* feat: Create custom callbacks with the `callback_batch_fselect()` function.

# mlr3fselect 0.8.0

* refactor: `FSelectorRFE` throws an error if the learner does not support the `$importance()` method.
* refactor: The `AutoFSelector` stores the instance and benchmark result if `store_models = TRUE`.
* refactor: The `AutoFSelector` stores the instance if `store_benchmark_result = TRUE`.
* feat: Add missing parameters from `AutoFSelector` to `auto_fselect()`.
* feat: Add `fsi()` function to create a `FSelectInstanceSingleCrit` or `FSelectInstanceMultiCrit`.
* refactor: Remove `unnest` option from `as.data.table.ArchiveFSelect()` function.
* feat: Add `fsi()` function to create a `FSelectInstanceBatchSingleCrit` or `FSelectInstanceBatchMultiCrit`.
* refactor: Remove `unnest` option from `as.data.table.ArchiveBatchFSelect()` function.

# mlr3fselect 0.7.2

Expand All @@ -67,7 +67,7 @@
* docs: New examples with `fselect()` function.
* feat: `$help()` method which opens manual page of a `FSelector`.
* feat: Added a `as.data.table.DictionaryFSelector` function.
* feat: Added `min_features` parameter to `FSelectorSequential`.
* feat: Added `min_features` parameter to `FSelectorBatchSequential`.

# mlr3fselect 0.6.1

Expand All @@ -90,7 +90,7 @@

* `FSelectorRFE` stores importance values of each evaluated feature set in
archive.
* `ArchiveFSelect$data` is a public field now.
* `ArchiveBatchFSelect$data` is a public field now.

# mlr3fselect 0.4.1

Expand All @@ -110,15 +110,15 @@
* Option to control `store_benchmark_result`, `store_models` and `check_values`
in `AutoFSelector`. `store_fselect_instance` must be set as a parameter during
initialization.
* Adds `FSelectorGeneticSearch`.
* Fixes `check_values` flag in `FSelectInstanceSingleCrit` and
`FSelectInstanceMultiCrit`.
* Adds `FSelectorBatchGeneticSearch`.
* Fixes `check_values` flag in `FSelectInstanceBatchSingleCrit` and
`FSelectInstanceBatchMultiCrit`.
* Removed dependency on orphaned package `bibtex`.
* `PipeOpSelect` is internally used for task subsetting.

# mlr3fselect 0.3.0

* `Archive` is `ArchiveFSelect` now which stores the benchmark result in
* `Archive` is `ArchiveBatchFSelect` now which stores the benchmark result in
`$benchmark_result`. This change removed the resample results from the archive
but they can be still accessed via the benchmark result.

Expand Down
16 changes: 8 additions & 8 deletions R/ArchiveFSelect.R → R/ArchiveBatchFSelect.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' @title Class for Logging Evaluated Feature Sets
#'
#' @description
#' The [ArchiveFSelect] stores all evaluated feature sets and performance scores.
#' The [ArchiveBatchFSelect] stores all evaluated feature sets and performance scores.
#'
#' @details
#' The [ArchiveFSelect] is a container around a [data.table::data.table()].
#' The [ArchiveBatchFSelect] is a container around a [data.table::data.table()].
#' Each row corresponds to a single evaluation of a feature set.
#' See the section on Data Structure for more information.
#' The archive stores additionally a [mlr3::BenchmarkResult] (`$benchmark_result`) that records the resampling experiments.
Expand Down Expand Up @@ -40,10 +40,10 @@
#' Alternatively, measures can be supplied to `as.data.table()`.
#'
#' @section S3 Methods:
#' * `as.data.table.ArchiveFSelect(x, exclude_columns = "uhash", measures = NULL)`\cr
#' * `as.data.table.ArchiveBatchFSelect(x, exclude_columns = "uhash", measures = NULL)`\cr
#' Returns a tabular view of all evaluated feature sets.\cr
#' [ArchiveFSelect] -> [data.table::data.table()]\cr
#' * `x` ([ArchiveFSelect])
#' [ArchiveBatchFSelect] -> [data.table::data.table()]\cr
#' * `x` ([ArchiveBatchFSelect])
#' * `exclude_columns` (`character()`)\cr
#' Exclude columns from table. Set to `NULL` if no column should be excluded.
#' * `measures` (list of [mlr3::Measure])\cr
Expand All @@ -52,8 +52,8 @@
#' @template param_ties_method
#'
#' @export
ArchiveFSelect = R6Class("ArchiveFSelect",
inherit = Archive,
ArchiveBatchFSelect = R6Class("ArchiveBatchFSelect",
inherit = ArchiveBatch,

public = list(

Expand Down Expand Up @@ -212,7 +212,7 @@ ArchiveFSelect = R6Class("ArchiveFSelect",
)

#' @export
as.data.table.ArchiveFSelect = function(x, ..., exclude_columns = "uhash", measures = NULL) {
as.data.table.ArchiveBatchFSelect = function(x, ..., exclude_columns = "uhash", measures = NULL) {
if (nrow(x$data) == 0) return(data.table())
# always ignore x_domain column
exclude_columns = c("x_domain", exclude_columns)
Expand Down
14 changes: 7 additions & 7 deletions R/AutoFSelector.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ AutoFSelector = R6Class("AutoFSelector",
public = list(

#' @field instance_args (`list()`)\cr
#' All arguments from construction to create the [FSelectInstanceSingleCrit].
#' All arguments from construction to create the [FSelectInstanceBatchSingleCrit].
instance_args = NULL,

#' @field fselector ([FSelector])\cr
Expand All @@ -122,7 +122,7 @@ AutoFSelector = R6Class("AutoFSelector",
store_benchmark_result = TRUE,
store_models = FALSE,
check_values = FALSE,
callbacks = list(),
callbacks = NULL,
ties_method = "least_features"
) {
ia = list()
Expand Down Expand Up @@ -249,8 +249,8 @@ AutoFSelector = R6Class("AutoFSelector",

active = list(

#' @field archive ([ArchiveFSelect)\cr
#' Returns [FSelectInstanceSingleCrit] archive.
#' @field archive ([ArchiveBatchFSelect)\cr
#' Returns [FSelectInstanceBatchSingleCrit] archive.
archive = function() self$fselect_instance$archive,

#' @field learner ([mlr3::Learner])\cr
Expand All @@ -264,12 +264,12 @@ AutoFSelector = R6Class("AutoFSelector",
}
},

#' @field fselect_instance ([FSelectInstanceSingleCrit])\cr
#' @field fselect_instance ([FSelectInstanceBatchSingleCrit])\cr
#' Internally created feature selection instance with all intermediate results.
fselect_instance = function() self$model$fselect_instance,

#' @field fselect_result ([data.table::data.table])\cr
#' Short-cut to `$result` from [FSelectInstanceSingleCrit].
#' Short-cut to `$result` from [FSelectInstanceBatchSingleCrit].
fselect_result = function() self$fselect_instance$result,

#' @field predict_type (`character(1)`)\cr
Expand Down Expand Up @@ -311,7 +311,7 @@ AutoFSelector = R6Class("AutoFSelector",
# construct instance from args; then tune
ia = self$instance_args
ia$task = task$clone()
instance = invoke(FSelectInstanceSingleCrit$new, .args = ia)
instance = invoke(FSelectInstanceBatchSingleCrit$new, .args = ia)
self$fselector$optimize(instance)
learner = ia$learner$clone(deep = TRUE)
task = task$clone()
Expand Down
Loading
Loading