mlr3tuning

Hyperparameter optimization package of the mlr3 ecosystem

https://github.com/mlr-org/mlr3tuning

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 14 committers (7.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.9%) to scientific vocabulary

Keywords

bbotk hyperparameter-optimization hyperparameter-tuning machine-learning mlr3 optimization r r-package tune tuning

Keywords from Contributors

learners reproducibility imbalance-correction hyperparameters-optimization feature-selection bayesian-optimization parallel-computing mlr multilabel-classification survival-analysis
Last synced: 6 months ago · JSON representation

Repository

Hyperparameter optimization package of the mlr3 ecosystem

Basic Info
Statistics
  • Stars: 58
  • Watchers: 16
  • Forks: 7
  • Open Issues: 5
  • Releases: 35
Topics
bbotk hyperparameter-optimization hyperparameter-tuning machine-learning mlr3 optimization r r-package tune tuning
Created over 7 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---

```{r, include = FALSE}
lgr::get_logger("mlr3")$set_threshold("warn")
lgr::get_logger("bbotk")$set_threshold("warn")
set.seed(1)
options(
    datatable.print.nrows = 10,
    datatable.print.class = FALSE,
    datatable.print.keys = FALSE,
    width = 100)
# mute load messages
library("mlr3tuning")
```

# mlr3tuning 

Package website: [release](https://mlr3tuning.mlr-org.com/) | [dev](https://mlr3tuning.mlr-org.com/dev/)


[![r-cmd-check](https://github.com/mlr-org/mlr3tuning/actions/workflows/r-cmd-check.yml/badge.svg)](https://github.com/mlr-org/mlr3tuning/actions/workflows/r-cmd-check.yml)
[![CRAN Status](https://www.r-pkg.org/badges/version-ago/mlr3tuning)](https://cran.r-project.org/package=mlr3tuning)
[![Mattermost](https://img.shields.io/badge/chat-mattermost-orange.svg)](https://lmmisld-lmu-stats-slds.srv.mwn.de/mlr_invite/)


*mlr3tuning* is the hyperparameter optimization package of the [mlr3](https://mlr-org.com/) ecosystem.
It features highly configurable search spaces via the [paradox](https://github.com/mlr-org/paradox) package and finds optimal hyperparameter configurations for any mlr3 [learner](https://github.com/mlr-org/mlr3learners).
mlr3tuning works with several optimization algorithms e.g. Random Search, Iterated Racing, Bayesian Optimization (in [mlr3mbo](https://github.com/mlr-org/mlr3mbo)) and Hyperband (in [mlr3hyperband](https://github.com/mlr-org/mlr3hyperband)).
Moreover, it can [automatically](https://mlr3book.mlr-org.com/chapters/chapter4/hyperparameter_optimization.html#sec-autotuner) optimize learners and estimate the performance of optimized models with [nested resampling](https://mlr3book.mlr-org.com/chapters/chapter4/hyperparameter_optimization.html#sec-nested-resampling).
The package is built on the optimization framework [bbotk](https://github.com/mlr-org/bbotk).

## Extension packages

mlr3tuning is extended by the following packages.

* [mlr3tuningspaces](https://github.com/mlr-org/mlr3tuningspaces) is a collection of search spaces from scientific articles for commonly used learners.
* [mlr3hyperband](https://github.com/mlr-org/mlr3hyperband) adds the Hyperband and Successive Halving algorithm.
* [mlr3mbo](https://github.com/mlr-org/mlr3mbo) adds Bayesian Optimization methods.

## Resources

There are several sections about hyperparameter optimization in the [mlr3book](https://mlr3book.mlr-org.com).

* Getting started with [hyperparameter optimization](https://mlr3book.mlr-org.com/chapters/chapter4/hyperparameter_optimization.html).
* An overview of all tuners can be found on our [website](https://mlr-org.com/tuners.html).
* [Tune](https://mlr3book.mlr-org.com/chapters/chapter4/hyperparameter_optimization.html#sec-model-tuning) a support vector machine on the Sonar data set.
* Learn about [tuning spaces](https://mlr3book.mlr-org.com/chapters/chapter4/hyperparameter_optimization.html#sec-defining-search-spaces).
* Estimate the model performance with [nested resampling](https://mlr3book.mlr-org.com/chapters/chapter4/hyperparameter_optimization.html#sec-nested-resampling).
* Learn about [multi-objective optimization](https://mlr3book.mlr-org.com/chapters/chapter5/advanced_tuning_methods_and_black_box_optimization.html#sec-multi-metrics-tuning).
* Simultaneously optimize hyperparameters and use [early stopping](https://mlr3book.mlr-org.com/chapters/chapter15/predsets_valid_inttune.html) with XGBoost.
* [Automate](https://mlr3book.mlr-org.com/chapters/chapter4/hyperparameter_optimization.html#sec-autotuner) the tuning.

The [gallery](https://mlr-org.com/gallery-all-optimization.html) features a collection of case studies and demos about optimization.

* Learn more advanced methods with the [Practical Tuning Series](https://mlr-org.com/gallery/series/2021-03-09-practical-tuning-series-tune-a-support-vector-machine/).
* Learn about [hotstarting](https://mlr-org.com/gallery/optimization/2023-01-16-hotstart/) models.
* Run the [default hyperparameter configuration](https://mlr-org.com/gallery/optimization/2023-01-31-default-configuration/) of learners as a baseline.
* Use the [Hyperband](https://mlr-org.com/gallery/series/2023-01-15-hyperband-xgboost/) optimizer with different budget parameters.

The [cheatsheet](https://cheatsheets.mlr-org.com/mlr3tuning.pdf) summarizes the most important functions of mlr3tuning.

## Installation

Install the last release from CRAN:

```{r eval = FALSE}
install.packages("mlr3tuning")
```

Install the development version from GitHub:

```{r eval = FALSE}
# install.packages("pak")
pak::pak("mlr-org/mlr3tuning")
```

## Examples

We optimize the `cost` and `gamma` hyperparameters of a support vector machine on the [Sonar](https://mlr3.mlr-org.com/reference/mlr_tasks_sonar.html) data set.

```{r}
library("mlr3learners")
library("mlr3tuning")

learner = lrn("classif.svm",
  cost  = to_tune(1e-5, 1e5, logscale = TRUE),
  gamma = to_tune(1e-5, 1e5, logscale = TRUE),
  kernel = "radial",
  type = "C-classification"
)
```

We construct a tuning instance with the `ti()` function.
The tuning instance describes the tuning problem.

```{r}
instance = ti(
  task = tsk("sonar"),
  learner = learner,
  resampling = rsmp("cv", folds = 3),
  measures = msr("classif.ce"),
  terminator = trm("none")
)
instance
```

We select a simple grid search as the optimization algorithm.

```{r}
tuner = tnr("grid_search", resolution = 5)
tuner
```

To start the tuning, we simply pass the tuning instance to the tuner.

```{r}
tuner$optimize(instance)
```

The tuner returns the best hyperparameter configuration and the corresponding measured performance.

The archive contains all evaluated hyperparameter configurations.

```{r}
as.data.table(instance$archive)[, .(cost, gamma, classif.ce, batch_nr, resample_result)]
```

The [mlr3viz](https://mlr3viz.mlr-org.com/) package visualizes tuning results.

```{r, eval=FALSE}
library(mlr3viz)

autoplot(instance, type = "surface")
```

```{r, eval=FALSE, echo=FALSE}
p = autoplot(instance, type = "surface")
ggplot2::ggsave(filename = "plot.png", plot = p, units = "px", width = 600,  height = 500, scale = 5)
```



We fit a final model with optimized hyperparameters to make predictions on new data.

```{r}
learner$param_set$values = instance$result_learner_param_vals
learner$train(tsk("sonar"))
```

Owner

  • Name: mlr-org
  • Login: mlr-org
  • Kind: organization
  • Location: Munich, Germany

GitHub Events

Total
  • Create event: 42
  • Release event: 6
  • Issues event: 18
  • Watch event: 3
  • Delete event: 34
  • Member event: 1
  • Issue comment event: 9
  • Push event: 187
  • Pull request review event: 2
  • Pull request review comment event: 2
  • Pull request event: 65
Last Year
  • Create event: 42
  • Release event: 6
  • Issues event: 18
  • Watch event: 3
  • Delete event: 34
  • Member event: 1
  • Issue comment event: 9
  • Push event: 187
  • Pull request review event: 2
  • Pull request review comment event: 2
  • Pull request event: 65

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 884
  • Total Committers: 14
  • Avg Commits per committer: 63.143
  • Development Distribution Score (DDS): 0.612
Past Year
  • Commits: 86
  • Committers: 5
  • Avg Commits per committer: 17.2
  • Development Distribution Score (DDS): 0.233
Top Committers
Name Email Commits
be-marc m****r@p****e 343
Michel Lang m****g@g****m 225
Bernd Bischl b****l@g****t 113
schalkdaniel d****k@t****e 88
pat-s p****z@g****m 52
Jakob Richter c****e@j****e 29
Sebastian Fischer s****r@g****m 18
mb706 m****6 9
Lennart Schneider l****h@w****e 2
juliambr j****r@g****m 1
github-actions[bot] 4****] 1
Michael Chirico m****4@g****m 1
Lona 1****k 1
Raphael Sonabend r****5@u****k 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 69
  • Total pull requests: 161
  • Average time to close issues: 10 months
  • Average time to close pull requests: 24 days
  • Total issue authors: 32
  • Total pull request authors: 11
  • Average comments per issue: 2.41
  • Average comments per pull request: 0.19
  • Merged pull requests: 138
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 15
  • Pull requests: 53
  • Average time to close issues: 8 days
  • Average time to close pull requests: 8 days
  • Issue authors: 7
  • Pull request authors: 6
  • Average comments per issue: 0.67
  • Average comments per pull request: 0.02
  • Merged pull requests: 45
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • be-marc (16)
  • sebffischer (8)
  • berndbischl (7)
  • mb706 (4)
  • pat-s (3)
  • pfistfl (2)
  • mllg (2)
  • SteveBronder (2)
  • ZekeMarshall (1)
  • giuseppec (1)
  • Fred-Wu (1)
  • RaphaelS1 (1)
  • MarcelMiche (1)
  • MLopez-Ibanez (1)
  • m-muecke (1)
Pull Request Authors
  • be-marc (154)
  • sebffischer (35)
  • mb706 (5)
  • MichaelChirico (3)
  • pat-s (2)
  • lona-k (2)
  • jakob-r (2)
  • m-muecke (2)
  • sumny (2)
  • mllg (2)
  • pfistfl (1)
Top Labels
Issue Labels
Status: Discussion Needed (9) Type: Enhancement (7) Status: In Progress (4) Type: Bug (3) Priority: Low (2) Priority: Medium (2) Workshop (2) Type: Question (1) Status: Accepted (1) Priority: Critical (1)
Pull Request Labels
Workshop (2) Status: Pending (1) Priority: Low (1) Type: Bug (1) Status: In Progress (1) Priority: Medium (1)

Packages

  • Total packages: 1
  • Total downloads:
    • cran 20,161 last-month
  • Total docker downloads: 42,385
  • Total dependent packages: 13
  • Total dependent repositories: 28
  • Total versions: 36
  • Total maintainers: 1
cran.r-project.org: mlr3tuning

Hyperparameter Optimization for 'mlr3'

  • Versions: 36
  • Dependent Packages: 13
  • Dependent Repositories: 28
  • Downloads: 20,161 Last month
  • Docker Downloads: 42,385
Rankings
Dependent packages count: 4.4%
Dependent repos count: 5.2%
Downloads: 6.3%
Stargazers count: 7.1%
Average: 9.7%
Forks count: 10.8%
Docker downloads count: 24.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/dev-cmd-check.yml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/r-cmd-check.yml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 3.1.0 depends
  • mlr3 >= 0.14.1 depends
  • paradox >= 0.10.0 depends
  • R6 * imports
  • bbotk >= 0.7.2 imports
  • checkmate >= 2.0.0 imports
  • data.table * imports
  • lgr * imports
  • mlr3misc >= 0.11.0 imports
  • GenSA * suggests
  • adagio * suggests
  • irace * suggests
  • mlr3learners >= 0.5.5 suggests
  • mlr3pipelines * suggests
  • nloptr * suggests
  • rpart * suggests
  • testthat >= 3.0.0 suggests
  • xgboost * suggests