Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mlr-org/paradox
ParamHelpers Next Generation
https://github.com/mlr-org/paradox
experimental-design hyperparameters mlr3 r r-package transformations
Last synced: 1 day ago
JSON representation
ParamHelpers Next Generation
- Host: GitHub
- URL: https://github.com/mlr-org/paradox
- Owner: mlr-org
- License: lgpl-3.0
- Created: 2017-10-07T10:29:04.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-10-18T15:50:39.000Z (20 days ago)
- Last Synced: 2024-10-28T17:24:31.727Z (10 days ago)
- Topics: experimental-design, hyperparameters, mlr3, r, r-package, transformations
- Language: R
- Homepage: https://paradox.mlr-org.com
- Size: 10.5 MB
- Stars: 28
- Watchers: 14
- Forks: 7
- Open Issues: 46
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - mlr-org/paradox - ParamHelpers Next Generation (R)
README
---
output: github_document
---# paradox
Package website: [release](https://paradox.mlr-org.com/) | [dev](https://paradox.mlr-org.com/dev/)
Universal Parameter Space Description and Tools.
[![r-cmd-check](https://github.com/mlr-org/paradox/actions/workflows/r-cmd-check.yml/badge.svg)](https://github.com/mlr-org/paradox/actions/workflows/r-cmd-check.yml)
[![CRAN Status](https://www.r-pkg.org/badges/version/paradox)](https://CRAN.R-project.org/package=paradox)
[![StackOverflow](https://img.shields.io/badge/stackoverflow-mlr3-orange.svg)](https://stackoverflow.com/questions/tagged/mlr3)
[![Mattermost](https://img.shields.io/badge/chat-mattermost-orange.svg)](https://lmmisld-lmu-stats-slds.srv.mwn.de/mlr_invite/)```{r setup, include=FALSE}
set.seed(123)
knitr::opts_chunk$set(cache = FALSE, collapse = TRUE, comment = "#>")
options(datatable.print.class = FALSE, datatable.print.keys = FALSE)
library(paradox)
```## Installation
```{r inst, eval=FALSE}
remotes::install_github("mlr-org/paradox")
```## Usage
Create a simple ParamSet using all supported Parameter Types:
* integer numbers (`"int"`)
* real-valued numbers (`"dbl"`)
* truth values `TRUE` or `FALSE` (`"lgl"`)
* categorical values from a set of possible strings (`"fct"`)
* further types are only possible by using transformations.```{r ps}
pset = ps(
z = p_int(lower = 1, upper = 3),
x = p_dbl(lower = -10, upper = 10),
flag = p_lgl(),
methods = p_fct(c("a","b","c"))
)
```Draw random samples / create random design:
```{r pssample}
generate_design_random(pset, 3)
```Generate LHS Design:
```{r pslhs}
requireNamespace("lhs")
generate_design_lhs(pset, 3)
```Generate Grid Design:
```{r psgrid, R.options=list(max.print=30)}
generate_design_grid(pset, resolution = 2)
```Properties of the parameters within the `ParamSet`:
```{r psprobs}
pset$ids()
pset$levels
pset$nlevels
pset$is_number
pset$lower
pset$upper
```### Parameter Checks
Check that a parameter satisfies all conditions of a `ParamSet`, using `$test()` (returns `FALSE` on mismatch), `$check()` (returns error description on mismatch), and `$assert()` (throws error on mismatch):
```{r, error = TRUE}
pset$test(list(z = 1, x = 1))
pset$test(list(z = -1, x = 1))
pset$check(list(z = -1, x = 1))
pset$assert(list(z = -1, x = 1))
```### Transformations
Transformations are functions with a fixed signature.
* `x` A named list of parameter values
* `param_set` the `ParamSet` used to create the designTransformations can be used to change the distributions of sampled parameters.
For example, to sample values between $2^-3$ and $2^3$ in a $log_2$-uniform distribution, one can sample uniformly between -3 and 3 and exponentiate the random value inside the transformation.
Alternatively, `logscale = TRUE` can be set; in this case, `lower` and `upper` represent the values *after* the transformation.```{r pstransscale}
pset = ps(
z = p_int(lower = -3, upper = 3),
x = p_dbl(lower = 2^-3, upper = 2^3, logscale = TRUE)
)
pset$extra_trafo = function(x, param_set) {
x$z = 2^x$z
return(x)
}
pset_smplr = SamplerUnif$new(pset)
x = pset_smplr$sample(2)
xst = x$transpose()
xst
```Further documentation can be found in the [in-depth tutorial](https://paradox.mlr-org.com/dev/articles/indepth.html)