You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## Overview
6
+
7
+
dials is an R package that provides infrastructure for creating and managing tuning parameter values in the tidymodels ecosystem. It defines parameter objects, sets of parameters, and methods for generating parameter grids for model tuning.
8
+
9
+
## Key development commands
10
+
11
+
General advice:
12
+
* When running R from the console, always run it with `--quiet --vanilla`
13
+
* Always run `air format .` after generating code
14
+
15
+
### Testing
16
+
17
+
- Use `devtools::test()` to run all tests
18
+
- Use `devtools::test_file("tests/testthat/test-filename.R")` to run tests in a specific file
19
+
- DO NOT USE `devtools::test_active_file()`
20
+
- All testing functions automatically load code; you don't need to.
21
+
22
+
- All new code should have an accompanying test.
23
+
- Tests for `R/{name}.R` go in `tests/testthat/test-{name}.R`.
24
+
- If there are existing tests, place new tests next to similar existing tests.
25
+
26
+
### Documentation
27
+
28
+
- Run `devtools::document()` after changing any roxygen2 docs.
29
+
- Every user facing function should be exported and have roxygen2 documentation.
30
+
- Whenever you add a new documentation file, make sure to also add the topic name to `_pkgdown.yml`.
31
+
- Run `pkgdown::check_pkgdown()` to check that all topics are included in the reference index.
32
+
- Use sentence case for all headings
33
+
34
+
35
+
## Architecture
36
+
37
+
### Core Parameter System
38
+
39
+
The package is built around two main parameter types:
40
+
41
+
1.**`quant_param`**: Quantitative parameters (continuous or integer)
42
+
- Created via `new_quant_param()` in `R/constructors.R`
43
+
- Has `range` (lower/upper bounds), `inclusive`, optional `trans` (transformation), and `finalize` function
- Created via `new_qual_param()` in `R/constructors.R`
48
+
- Has discrete `values` (character or logical)
49
+
- Examples: `activation()`, `weight_func()`
50
+
51
+
### Parameter Organization
52
+
53
+
-**Individual parameters**: parameter definition files (`R/param_*.R`), each defining specific tuning parameters used across tidymodels
54
+
-**Parameter sets**: The `parameters` class (defined in `R/parameters.R`) groups multiple parameters into a data frame-like structure
55
+
56
+
### Grid Generation
57
+
58
+
Three main grid types (in `R/grids.R` and `R/space_filling.R`):
59
+
60
+
1.**Regular grids** (`grid_regular()`): Factorial designs with evenly-spaced values
61
+
2.**Random grids** (`grid_random()`): Random sampling from parameter ranges
62
+
3.**Space-filling grids** (`grid_space_filling()`): Experimental designs (Latin hypercube, max entropy, etc.) that efficiently cover the parameter space
63
+
64
+
All grid functions:
65
+
- Accept parameter objects or parameter sets
66
+
- Return tibbles with one column per parameter
67
+
68
+
### Finalization System
69
+
70
+
Many parameters have `unknown()` ranges that depend on the dataset (e.g., `mtry()` depends on the number of predictors). The finalization system (`R/finalize.R`) resolves these:
71
+
72
+
-`finalize()`: Generic function that calls the parameter's embedded `finalize` function
73
+
-`get_*()`: Various functions that get and set parameter ranges based on data characteristics
74
+
75
+
### Infrastructure Files
76
+
77
+
Files prefixed with `aaa_` load first and define foundational classes:
78
+
-`R/aaa_ranges.R`: Handling and validation of parameter ranges
79
+
-`R/aaa_unknown.R`: The `unknown()` placeholder for unspecified parameter bounds
80
+
-`R/aaa_values.R`: Validation, generation, and transformation of parameter values
81
+
82
+
Files prefixed with `compat-` provide compatibility with dplyr and vctrs for parameter objects.
83
+
84
+
## Integration with tidymodels
85
+
86
+
dials is infrastructure-level; it defines parameters but doesn't perform tuning. The tune package uses dials for actual hyperparameter tuning. Parameter objects integrate with:
87
+
-**parsnip**: Model specifications reference dials parameters
88
+
-**recipes**: Preprocessing steps use dials parameters
89
+
-**workflows**: Workflows combine models and preprocessing that utilize dials parameters
90
+
-**tune**: Grid search and optimization consume parameter grids
0 commit comments