{"id":14067118,"url":"https://github.com/mlr-org/mlr3filters","last_synced_at":"2025-04-09T18:18:21.355Z","repository":{"id":38334368,"uuid":"153455918","full_name":"mlr-org/mlr3filters","owner":"mlr-org","description":"Filter-based feature selection for mlr3","archived":false,"fork":false,"pushed_at":"2025-01-29T12:54:18.000Z","size":11603,"stargazers_count":20,"open_issues_count":16,"forks_count":8,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-09T18:18:16.386Z","etag":null,"topics":["feature-selection","filter","filters","mlr","mlr3","r","r-package","variable-importance"],"latest_commit_sha":null,"homepage":"https://mlr3filters.mlr-org.com","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlr-org.png","metadata":{"funding":{"github":"mlr-org"},"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-17T12:48:36.000Z","updated_at":"2025-01-29T12:27:18.000Z","dependencies_parsed_at":"2023-02-10T02:16:02.274Z","dependency_job_id":"0ade5f43-c001-4d2a-b955-3ebc3deddfb0","html_url":"https://github.com/mlr-org/mlr3filters","commit_stats":{"total_commits":430,"total_committers":15,"mean_commits":"28.666666666666668","dds":0.3930232558139535,"last_synced_commit":"17f93b37416a914abd85ec6ec321789a35318912"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlr-org%2Fmlr3filters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlr-org%2Fmlr3filters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlr-org%2Fmlr3filters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlr-org%2Fmlr3filters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlr-org","download_url":"https://codeload.github.com/mlr-org/mlr3filters/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085326,"owners_count":21045139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["feature-selection","filter","filters","mlr","mlr3","r","r-package","variable-importance"],"created_at":"2024-08-13T07:05:26.553Z","updated_at":"2025-04-09T18:18:21.331Z","avatar_url":"https://github.com/mlr-org.png","language":"R","funding_links":["https://github.com/sponsors/mlr-org"],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n# mlr3filters\n\nPackage website: [release](https://mlr3filters.mlr-org.com/) | [dev](https://mlr3filters.mlr-org.com/dev/)\n\n{mlr3filters} adds feature selection filters to [mlr3](https://mlr3.mlr-org.com).\nThe implemented filters can be used stand-alone, or as part of a machine learning pipeline in combination with\n[mlr3pipelines](https://mlr3pipelines.mlr-org.com) and the [filter operator](https://mlr3pipelines.mlr-org.com/reference/mlr_pipeops_filter.html).\n\nWrapper methods for feature selection are implemented in [mlr3fselect](https://mlr3fselect.mlr-org.com).\nLearners which support the extraction feature importance scores can be combined with a filter from this package for embedded feature selection.\n\n\u003c!-- badges: start --\u003e\n[![r-cmd-check](https://github.com/mlr-org/mlr3filters/actions/workflows/r-cmd-check.yml/badge.svg)](https://github.com/mlr-org/mlr3filters/actions/workflows/r-cmd-check.yml)\n[![CRAN Status](https://www.r-pkg.org/badges/version-ago/mlr3filters)](https://cran.r-project.org/package=mlr3filters)\n[![StackOverflow](https://img.shields.io/badge/stackoverflow-mlr3-orange.svg)](https://stackoverflow.com/questions/tagged/mlr3)\n[![Mattermost](https://img.shields.io/badge/chat-mattermost-orange.svg)](https://lmmisld-lmu-stats-slds.srv.mwn.de/mlr_invite/)\n\u003c!-- badges: end --\u003e\n\n## Installation\n\nCRAN version\n\n```{r eval = FALSE}\ninstall.packages(\"mlr3filters\")\n```\n\nDevelopment version\n\n```{r, eval = FALSE}\nremotes::install_github(\"mlr-org/mlr3filters\")\n```\n\n## Filters\n\n### Filter Example\n\n```{r}\nset.seed(1)\nlibrary(\"mlr3\")\nlibrary(\"mlr3filters\")\n\ntask = tsk(\"sonar\")\nfilter = flt(\"auc\")\nhead(as.data.table(filter$calculate(task)))\n```\n\n### Implemented Filters\n\n```{r echo = FALSE, message=FALSE}\nlibrary(\"mlr3misc\")\nlibrary(\"mlr3filters\")\nlibrary(\"data.table\")\n\nlink_cran = function(pkg) {\n  mlr3misc::map(pkg, function(.x) {\n    mlr3misc::map_chr(.x, function(.y) {\n      if (unlist(.y) %in% getOption(\"defaultPackages\")) {\n        .y\n      } else {\n        sprintf(\"[%1$s](https://cran.r-project.org/package=%1$s)\", .y)\n      }\n    })\n  })\n}\n\ntab = as.data.table(mlr_filters)[, !c(\"params\", \"task_properties\")]\ntab[, task_types := sapply(task_types, function(x) if (is_scalar_na(x)) \"Universal\" else paste(capitalize(x), collapse = \" \u0026 \"))]\ntab[, feature_types := sapply(feature_types, function(x) paste(capitalize(x), collapse = \", \"))]\ntab[, packages := sapply(packages, function(x) paste(link_cran(x), collapse = \", \"))]\n\n# manually change the task type for specific filters\nlearner_based = c(\"performance\", \"permutation\", \"importance\", \"selected_features\")\ntab[key %in% learner_based, task_types := \"Universal\"]\ntab[key %in% learner_based, packages := \"\"]\n\n\nsetnames(tab,\n  old = c(\"key\", \"task_types\", \"feature_types\", \"packages\"),\n  new = c(\"Name\", \"Task Types\", \"Feature Types\", \"Package\")\n)\n\nknitr::kable(tab, format = \"markdown\")\n```\n\n### Variable Importance Filters\n\nThe following learners allow the extraction of variable importance and therefore are supported by `FilterImportance`:\n\n```{r echo=FALSE, warning=FALSE}\nlibrary(\"mlr3learners\")\ntab = as.data.table(mlr_learners)\ntab[sapply(properties, is.element, el = \"importance\"), key]\n```\n\nIf your learner is not listed here but capable of extracting variable importance from the fitted model, the reason is most likely that it is not yet integrated in the package [mlr3learners](https://github.com/mlr-org/mlr3learners) or the [extra learner extension](https://github.com/mlr-org/mlr3extralearners).\nPlease open an issue so we can add your package.\n\nSome learners need to have their variable importance measure \"activated\" during learner creation.\nFor example, to use the \"impurity\" measure of Random Forest via the {ranger} package:\n\n```{r}\ntask = tsk(\"iris\")\nlrn = lrn(\"classif.ranger\", seed = 42)\nlrn$param_set$values = list(importance = \"impurity\")\n\nfilter = flt(\"importance\", learner = lrn)\nfilter$calculate(task)\nhead(as.data.table(filter), 3)\n```\n\n### Performance Filter\n\n`FilterPerformance` is a univariate filter method which calls `resample()` with every predictor variable in the dataset and ranks the final outcome using the supplied measure.\nAny learner can be passed to this filter with `classif.rpart` being the default.\nOf course, also regression learners can be passed if the task is of type \"regr\".\n\n\n### Filter-based Feature Selection\n\nIn many cases filtering is only one step in the modeling pipeline.\nTo select features based on filter values, one can use [`PipeOpFilter`](https://mlr3pipelines.mlr-org.com/reference/mlr_pipeops_filter.html) from [mlr3pipelines](https://github.com/mlr-org/mlr3pipelines).\n\n```{r, results='hide'}\nlibrary(mlr3pipelines)\ntask = tsk(\"spam\")\n\n# the `filter.frac` should be tuned\ngraph = po(\"filter\", filter = flt(\"auc\"), filter.frac = 0.5) %\u003e\u003e%\n  po(\"learner\", lrn(\"classif.rpart\"))\n\nlearner = as_learner(graph)\nrr = resample(task, learner, rsmp(\"holdout\"))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlr-org%2Fmlr3filters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlr-org%2Fmlr3filters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlr-org%2Fmlr3filters/lists"}