Skip to content

Commit f27ac80

Browse files
committed
Update README and remove x_domain from result
1 parent 14154e9 commit f27ac80

File tree

8 files changed

+133
-42
lines changed

8 files changed

+133
-42
lines changed

R/FSelectInstanceMultiCrit.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ FSelectInstanceMultiCrit = R6Class("FSelectInstanceMultiCrit",
9595
self$objective$task$feature_names[as.logical(x)]
9696
})
9797
xdt[, features := list(features)]
98-
super$assign_result(xdt, ydt)
98+
assert_data_table(xdt)
99+
assert_names(names(xdt), must.include = self$search_space$ids())
100+
assert_data_table(ydt)
101+
assert_names(names(ydt), permutation.of = self$objective$codomain$ids())
102+
private$.result = cbind(xdt, ydt)
99103
}
100104
),
101105

R/FSelectInstanceSingleCrit.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ FSelectInstanceSingleCrit = R6Class("FSelectInstanceSingleCrit",
9393
# Add feature names to result for easy task subsetting
9494
features = list(self$objective$task$feature_names[as.logical(xdt)])
9595
xdt[, features := list(features)]
96-
super$assign_result(xdt, y)
96+
assert_data_table(xdt, nrows = 1L)
97+
assert_names(names(xdt), must.include = self$search_space$ids())
98+
assert_number(y)
99+
assert_names(names(y), permutation.of = self$objective$codomain$ids())
100+
private$.result = cbind(xdt, t(y)) # t(y) so the name of y stays
97101
}
98102
),
99103

README.Rmd

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
output: github_document
3+
---
4+
5+
```{r, include = FALSE}
6+
lgr::get_logger("mlr3")$set_threshold("warn")
7+
lgr::get_logger("bbotk")$set_threshold("warn")
8+
set.seed(1)
9+
options(datatable.print.class = FALSE, datatable.print.keys = FALSE)
10+
```
11+
12+
# mlr3fselect
13+
14+
Package website: [release](https://mlr3fselect.mlr-org.com/) | [dev](https://mlr3fselect.mlr-org.com/dev/)
15+
16+
<!-- badges: start -->
17+
[![tic](https://github.com/mlr-org/mlr3fselect/workflows/tic/badge.svg?branch=main)](https://github.com/mlr-org/mlr3fselect/actions)
18+
[![CRAN Status](https://www.r-pkg.org/badges/version/mlr3fselect)](https://cran.r-project.org/package=mlr3fselect)
19+
[![StackOverflow](https://img.shields.io/badge/stackoverflow-mlr3-orange.svg)](https://stackoverflow.com/questions/tagged/mlr3)
20+
[![Mattermost](https://img.shields.io/badge/chat-mattermost-orange.svg)](https://lmmisld-lmu-stats-slds.srv.mwn.de/mlr_invite/)
21+
[![CodeFactor](https://www.codefactor.io/repository/github/mlr-org/mlr3fselect/badge)](https://www.codefactor.io/repository/github/mlr-org/mlr3fselect)
22+
<!-- badges: end -->
23+
24+
This package provides feature selection for [mlr3](https://mlr3.mlr-org.com).
25+
It offers various feature selection wrappers, e.g. random search and sequential feature selection and different termination criteria can be set and combined.'AutoFSelect' provides a convenient way to perform nested resampling in combination with 'mlr3'.
26+
The package is build on [bbotk](https://github.com/mlr-org/bbotk) which provides a common framework for optimization.
27+
For feature filters and embedded methods, see [mlr3filters](https://mlr3filters.mlr-org.com)
28+
29+
## Resources
30+
31+
* mlr3book [chapter](https://mlr3book.mlr-org.com/fs.html)
32+
* mlr3gallery [post](https://mlr3gallery.mlr-org.com/posts/2020-09-14-mlr3fselect-basic/)
33+
* [cheatsheet](https://cheatsheets.mlr-org.com/mlr3fselect.pdf)
34+
35+
## Installation
36+
37+
Install the last release from CRAN:
38+
39+
```{r eval = FALSE}
40+
install.packages("mlr3fselect")
41+
```
42+
43+
Install the development version from GitHub:
44+
45+
```{r eval = FALSE}
46+
remotes::install_github("mlr-org/mlr3fselect")
47+
```
48+
49+
## Example
50+
51+
```{r}
52+
library("mlr3")
53+
library("mlr3fselect")
54+
55+
task = tsk("pima")
56+
learner = lrn("classif.rpart")
57+
resampling = rsmp("holdout")
58+
measure = msr("classif.ce")
59+
60+
# define termination criterion
61+
terminator = trm("evals", n_evals = 20)
62+
63+
# create fselect instance
64+
instance = FSelectInstanceSingleCrit$new(
65+
task = task,
66+
learner = learner,
67+
resampling = resampling,
68+
measure = measure,
69+
terminator = terminator)
70+
71+
# load fselector
72+
fselector = fs("random_search")
73+
74+
# trigger optimization
75+
fselector$optimize(instance)
76+
```
77+
78+

README.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,53 @@
1+
12
# mlr3fselect
23

3-
Package website: [release](https://mlr3fselect.mlr-org.com/) | [dev](https://mlr3fselect.mlr-org.com/dev/)
4+
Package website: [release](https://mlr3fselect.mlr-org.com/) |
5+
[dev](https://mlr3fselect.mlr-org.com/dev/)
46

57
<!-- badges: start -->
8+
69
[![tic](https://github.com/mlr-org/mlr3fselect/workflows/tic/badge.svg?branch=main)](https://github.com/mlr-org/mlr3fselect/actions)
7-
[![CRAN Status](https://www.r-pkg.org/badges/version/mlr3fselect)](https://cran.r-project.org/package=mlr3fselect)
10+
[![CRAN
11+
Status](https://www.r-pkg.org/badges/version/mlr3fselect)](https://cran.r-project.org/package=mlr3fselect)
812
[![StackOverflow](https://img.shields.io/badge/stackoverflow-mlr3-orange.svg)](https://stackoverflow.com/questions/tagged/mlr3)
913
[![Mattermost](https://img.shields.io/badge/chat-mattermost-orange.svg)](https://lmmisld-lmu-stats-slds.srv.mwn.de/mlr_invite/)
1014
[![CodeFactor](https://www.codefactor.io/repository/github/mlr-org/mlr3fselect/badge)](https://www.codefactor.io/repository/github/mlr-org/mlr3fselect)
1115
<!-- badges: end -->
1216

13-
This package provides feature selection for [mlr3](https://mlr3.mlr-org.com).
14-
It offers various feature selection wrappers, e.g. random search and sequential feature selection and
15-
different termination criteria can be set and combined. 'AutoFSelect' provides a
16-
convenient way to perform nested resampling in combination with 'mlr3'. The
17-
package is build on [bbotk](https://github.com/mlr-org/bbotk) which provides a
18-
common framework for optimization.
17+
This package provides feature selection for
18+
[mlr3](https://mlr3.mlr-org.com). It offers various feature selection
19+
wrappers, e.g. random search and sequential feature selection and
20+
different termination criteria can be set and combined.’AutoFSelect’
21+
provides a convenient way to perform nested resampling in combination
22+
with ‘mlr3’. The package is build on
23+
[bbotk](https://github.com/mlr-org/bbotk) which provides a common
24+
framework for optimization. For feature filters and embedded methods,
25+
see [mlr3filters](https://mlr3filters.mlr-org.com)
26+
27+
## Resources
1928

20-
For feature filters and embedded methods, see [mlr3filters](https://mlr3filters.mlr-org.com)
29+
- mlr3book [chapter](https://mlr3book.mlr-org.com/fs.html)
30+
- mlr3gallery
31+
[post](https://mlr3gallery.mlr-org.com/posts/2020-09-14-mlr3fselect-basic/)
32+
- [cheatsheet](https://cheatsheets.mlr-org.com/mlr3fselect.pdf)
2133

2234
## Installation
2335

24-
CRAN version
36+
Install the last release from CRAN:
2537

26-
```r
38+
``` r
2739
install.packages("mlr3fselect")
2840
```
2941

30-
Development version
42+
Install the development version from GitHub:
3143

32-
```r
44+
``` r
3345
remotes::install_github("mlr-org/mlr3fselect")
3446
```
3547

3648
## Example
3749

38-
```r
50+
``` r
3951
library("mlr3")
4052
library("mlr3fselect")
4153

@@ -44,24 +56,25 @@ learner = lrn("classif.rpart")
4456
resampling = rsmp("holdout")
4557
measure = msr("classif.ce")
4658

47-
# Define termination criterion
59+
# define termination criterion
4860
terminator = trm("evals", n_evals = 20)
4961

50-
# Create fselect instance
51-
instance = FSelectInstanceSingleCrit$new(task = task,
62+
# create fselect instance
63+
instance = FSelectInstanceSingleCrit$new(
64+
task = task,
5265
learner = learner,
5366
resampling = resampling,
5467
measure = measure,
5568
terminator = terminator)
5669

57-
# Load fselector
70+
# load fselector
5871
fselector = fs("random_search")
5972

60-
# Trigger optimization
73+
# trigger optimization
6174
fselector$optimize(instance)
62-
63-
# View results
64-
instance$result
6575
```
6676

67-
77+
## age glucose insulin mass pedigree pregnant pressure triceps
78+
## 1: TRUE TRUE TRUE TRUE TRUE FALSE FALSE TRUE
79+
## features classif.ce
80+
## 1: age,glucose,insulin,mass,pedigree,triceps 0.1757812

man/AutoFSelector.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/FSelectInstanceMultiCrit.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/FSelectInstanceSingleCrit.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/helper.R

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ test_fselector = function(.key, ..., term_evals = 2L, real_evals = term_evals,
6767

6868
fselector = fs(.key, ...)
6969
expect_fselector(fselector)
70-
expect_data_table(fselector$optimize(inst), nrows = 1, ncols = 7,
70+
expect_data_table(fselector$optimize(inst), nrows = 1, ncols = 6,
7171
any.missing = FALSE)
7272
archive = inst$archive
7373

@@ -76,21 +76,15 @@ test_fselector = function(.key, ..., term_evals = 2L, real_evals = term_evals,
7676
expect_equal(inst$archive$n_evals, real_evals)
7777

7878
# Result checks
79-
expect_data_table(inst$result, nrows = 1, ncols = 7)
79+
expect_data_table(inst$result, nrows = 1, ncols = 6)
8080
expect_named(inst$result, c(
8181
"x1",
8282
"x2",
8383
"x3",
8484
"x4",
8585
"features",
86-
"x_domain",
8786
"dummy"))
8887
expect_character(inst$result$features[[1]])
89-
expect_named(inst$result_x_domain, c(
90-
"x1",
91-
"x2",
92-
"x3",
93-
"x4"))
9488
expect_data_table(inst$result_x_search_space, nrows = 1, ncols = 4,
9589
types = "logical")
9690
expect_named(inst$result_x_search_space, c(
@@ -116,7 +110,7 @@ test_fselector_2D = function(.key, ..., term_evals = 2L, real_evals = term_evals
116110

117111
fselector = fs(.key, ...)
118112
expect_fselector(fselector)
119-
expect_data_table(fselector$optimize(inst), ncols = 8,
113+
expect_data_table(fselector$optimize(inst), ncols = 7,
120114
any.missing = FALSE)
121115
archive = inst$archive
122116

@@ -125,23 +119,16 @@ test_fselector_2D = function(.key, ..., term_evals = 2L, real_evals = term_evals
125119
expect_equal(inst$archive$n_evals, real_evals)
126120

127121
# Result checks
128-
expect_data_table(inst$result, ncols = 8)
122+
expect_data_table(inst$result, ncols = 7)
129123
expect_named(inst$result, c(
130124
"x1",
131125
"x2",
132126
"x3",
133127
"x4",
134128
"features",
135-
"x_domain",
136129
"regr.rmse",
137130
"regr.mse"))
138131
expect_character(inst$result$features[[1]])
139-
140-
expect_named(inst$result_x_domain[[1]], c(
141-
"x1",
142-
"x2",
143-
"x3",
144-
"x4"))
145132
expect_data_table(inst$result_x_search_space, ncols = 4,
146133
types = "logical")
147134
expect_named(inst$result_x_search_space, c(

0 commit comments

Comments
 (0)