-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
159 lines (138 loc) · 3.98 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
# dynparam
Provides tools for describing parameters of algorithms in an abstract way.
Description can include an id, a description, a domain (range or list of values), and a default value.
'dynparam' can also convert parameter sets to a `ParamHelpers` format, in order to be able to use `dynparam` in conjunction with `mlrMBO`.
Check `?dynparam` for an overview of all functionality provided by dynparam.
## Examples
The main goal of `dynparam` is to be able to describe a set of parameters,
be able to serialise the parameter sets, and also sample random settings from
the parameter set.
```{r, message = FALSE, error = FALSE, warning = FALSE}
library(tidyverse)
library(dynparam)
set.seed(1)
```
```{r, echo=FALSE}
cat <- function(x) {
base::cat(
"```yaml\n",
x, "\n",
"```",
sep = ""
)
}
```
Define a parameter set as follows:
```{r}
parameters <- parameter_set(
integer_parameter(
id = "num_iter",
default = 100L,
distribution = expuniform_distribution(lower = 1L, upper = 10000L),
description = "Number of iterations"
),
subset_parameter(
id = "dimreds",
default = c("pca", "mds"),
values = c("pca", "mds", "tsne", "umap", "ica"),
description = "Which dimensionality reduction methods to apply (can be multiple)"
),
integer_range_parameter(
id = "ks",
default = c(3L, 15L),
lower_distribution = uniform_distribution(1L, 5L),
upper_distribution = uniform_distribution(10L, 20L),
description = "The numbers of clusters to be evaluated"
)
)
```
You can retrieve the default parameters as follows:
```{r}
get_defaults(parameters)
```
Serialise a parameter set from/to json/yaml with the `as.list()` and `as_parameter_set()` functions.
```{r}
li <- as.list(parameters)
pa <- as_parameter_set(li)
```
Sample a parameter set using with `sip()`:
```{r}
sip(pa, n = 3)
```
### Large parameter set
```{r}
parameters <- parameter_set(
integer_parameter(
id = "num_iter",
default = 100L,
distribution = expuniform_distribution(lower = 1L, upper = 10000L),
description = "Number of iterations"
),
numeric_parameter(
id = "delta",
default = c(4.5, 2.4, 1.9),
distribution = normal_distribution(mean = 5, sd = 1),
description = "Multiplying factors"
),
character_parameter(
id = "method",
default = "kendall",
values = c("kendall", "spearman", "pearson"),
description = "Correlation method"
),
logical_parameter(
id = "inverse",
default = TRUE,
description = "Inversion parameter"
),
subset_parameter(
id = "dimreds",
default = c("pca", "mds"),
values = c("pca", "mds", "tsne", "umap", "ica"),
description = "Which dimensionality reduction methods to apply (can be multiple)"
),
integer_range_parameter(
id = "ks",
default = c(3L, 15L),
lower_distribution = uniform_distribution(1L, 5L),
upper_distribution = uniform_distribution(10L, 20L),
description = "The numbers of clusters to be evaluated."
),
numeric_range_parameter(
id = "quantiles",
default = c(0.15, 0.90),
lower_distribution = uniform_distribution(0, .4),
upper_distribution = uniform_distribution(.6, 1),
description = "Quantile cutoff range"
),
forbidden = "inverse == (method == 'kendall')"
)
```
As yaml:
```{r comment = "", results = "asis"}
cat(yaml::as.yaml(as.list(parameters)))
```
Generate a random parameter set:
```{r}
sip(parameters, n = 2)
```
Convert paramhelper object:
```{r}
as_paramhelper(parameters)
```
## Latest changes
Check out `news(package = "dynparam")` or [NEWS.md](inst/NEWS.md) for a full list of changes.
<!-- This section gets automatically generated from inst/NEWS.md, and also generates inst/NEWS -->
```{r news, echo=FALSE, results="asis"}
dynutils::update_news()
base::cat(dynutils::recent_news())
```
## Dynverse dependencies
<!-- Generated by "update_dependency_graphs.R" in the main dynverse repo -->
![](man/figures/dependencies.png)