add-dials-parameter — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited add-dials-parameter (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Create custom tuning parameters for hyperparameter tuning in Tidymodels
Guide for creating new dials parameters for hyperparameter tuning. Use when a developer needs to define custom tuning parameters for models, recipes, or workflows, including quantitative parameters (continuous/integer), qualitative parameters (categorical), parameters with transformations, and data-dependent parameters requiring finalization.
--------------------------------------------------------------------------------
This skill supports two distinct development contexts with different capabilities and constraints:
Use when: Creating a new R package that defines custom tuning parameters
dials:: prefix:::)Guide](references/extension-guide.md)
Package detection: DESCRIPTION file does NOT have Package: dials
Use when: Contributing parameter definitions directly to tidymodels/dials repository
dials:: prefixcheck_type(), check_range())range_get()/range_set()Package detection: DESCRIPTION file has Package: dials
--------------------------------------------------------------------------------
Before you begin, verify your development context:
# Extension development (most common)
usethis::create_package("myextension")
# DESCRIPTION will have: Package: myextension
# Source development (contributing to dials)
# Clone repository: git clone https://github.com/tidymodels/dials
# DESCRIPTION will have: Package: dialsINSTRUCTIONS FOR CLAUDE:
Detect development context by checking:
Package: dials → Source developmentPackage: [anything else] → Extension developmentExtension indicators:
Source indicators:
itself?"
Apply appropriate patterns:
if needed
--------------------------------------------------------------------------------
dials is the tuning parameter infrastructure package for Tidymodels. It provides:
The name reflects the idea that tuning predictive models can be like turning a set of dials on a complex machine.
--------------------------------------------------------------------------------
INSTRUCTIONS FOR CLAUDE: Check if repos/dials/ exists in the current working directory. Use this to guide development:
If `repos/dials/` exists:
repos/dials/R/param_mtry.R) to study implementationpatterns
repos/dials/tests/testthat/test-param_mtry.R) fortesting patterns
If `repos/dials/` does NOT exist:
Guide](references/package-repository-access.md)
https://github.com/tidymodels/dials/blob/main/R/[file-name].RWhen to use repository references:
See Repository Access Guide for setup instructions.
--------------------------------------------------------------------------------
┌─────────────────────────────────────────────────────────────┐
│ What type of tuning parameter do you need? │
└─────────────────────────────────────────────────────────────┘
│
┌───────────────────┴───────────────────┐
│ │
▼ ▼
Numeric values Categorical choices
(continuous or integer) (discrete options)
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ QUANTITATIVE │ │ QUALITATIVE │
│ PARAMETER │ │ PARAMETER │
└─────────────────┘ └─────────────────┘
│ │
│ │
├───────────┬────────────┐ │
▼ ▼ ▼ ▼
Simple Transformed Data- Examples:
range (log scale) dependent - activation()
- weight_func()
│ │ │ - prune_method()
▼ ▼ ▼
Examples: Examples: Examples:
- threshold - penalty - mtry
- mixture - learn_rate - num_comp
- neighbors - cost - sample_sizeDecision guide:
Quantitative Parameters + Transformations
Quantitative Parameters + Data-Dependent Parameters
Parameters](references/qualitative-parameters.md)
--------------------------------------------------------------------------------
A threshold parameter with fixed range (extension pattern):
# R/param_my_threshold.R
#' Threshold value
#'
#' A threshold parameter for filtering or classification decisions.
#'
#' @param range A two-element vector with the lower and upper bounds.
#' @param trans A transformation object (default NULL for no transformation).
#'
#' @details
#' This parameter is used for models or recipes that require a threshold value.
#'
#' @examples
#' my_threshold()
#' my_threshold(range = c(0, 0.5))
#'
#' @export
my_threshold <- function(range = c(0, 1), trans = NULL) {
dials::new_quant_param(
type = "double",
range = range,
inclusive = c(TRUE, TRUE),
trans = trans,
label = c(my_threshold = "Threshold Value"),
finalize = NULL
)
}A penalty parameter on log scale (extension pattern):
# R/param_my_penalty.R
#' Penalty amount
#'
#' A penalty parameter for regularization on log scale.
#'
#' @param range A two-element vector with the lower and upper bounds
#' (in log10 units).
#' @param trans A transformation object (default log10 transformation).
#'
#' @details
#' This parameter uses a log10 transformation, so `range = c(-5, 0)`
#' represents actual penalty values from 10^-5 to 1.
#'
#' @examples
#' my_penalty() # Range: 10^-10 to 1
#' my_penalty(range = c(-5, 0)) # Range: 10^-5 to 1
#'
#' @export
my_penalty <- function(range = c(-10, 0), trans = scales::transform_log10()) {
dials::new_quant_param(
type = "double",
range = range,
inclusive = c(TRUE, TRUE),
trans = trans,
label = c(my_penalty = "Penalty Amount"),
finalize = NULL
)
}A parameter with unknown upper bound (extension pattern):
# R/param_num_features.R
#' Number of features
#'
#' The number of features to select, depends on data.
#'
#' @param range A two-element vector with the lower and upper bounds.
#' @param trans A transformation object (default NULL).
#'
#' @details
#' The upper bound is set to `unknown()` and must be finalized using
#' `finalize()` with training data.
#'
#' @examples
#' num_features()
#'
#' # Finalize with data
#' param <- num_features()
#' finalized <- dials::finalize(param, mtcars[, -1])
#' finalized$range$upper # Will be number of columns
#'
#' @export
num_features <- function(range = c(1L, dials::unknown()), trans = NULL) {
dials::new_quant_param(
type = "integer",
range = range,
inclusive = c(TRUE, TRUE),
trans = trans,
label = c(num_features = "# Features to Select"),
finalize = dials::get_p # Built-in finalize function
)
}A parameter with custom finalization logic (extension pattern):
# R/param_num_initial_terms.R
#' Number of initial MARS terms
#'
#' The number of initial terms for MARS model, depends on data.
#'
#' @param range A two-element vector with the lower and upper bounds.
#' @param trans A transformation object (default NULL).
#'
#' @details
#' The upper bound is set to `unknown()` and is finalized using a custom
#' function based on the earth package formula: min(200, max(20, 2 * ncol(x))) + 1
#'
#' @examples
#' num_initial_terms()
#'
#' # Finalize with data
#' param <- num_initial_terms()
#' finalized <- dials::finalize(param, mtcars[, -1])
#' finalized$range$upper
#'
#' @export
num_initial_terms <- function(range = c(1L, dials::unknown()), trans = NULL) {
dials::new_quant_param(
type = "integer",
range = range,
inclusive = c(TRUE, TRUE),
trans = trans,
label = c(num_initial_terms = "# Initial MARS Terms"),
finalize = get_initial_mars_terms
)
}
# Custom finalize function
get_initial_mars_terms <- function(object, x) {
# Calculate upper bound based on number of predictors
upper_bound <- min(200, max(20, 2 * ncol(x))) + 1
upper_bound <- as.integer(upper_bound)
# Get current range and update upper bound
bounds <- dials::range_get(object)
bounds$upper <- upper_bound
dials::range_set(object, bounds)
}A categorical parameter with options (extension pattern):
# R/param_aggregation.R
#' Aggregation method
#'
#' The method to use for aggregating embeddings.
#'
#' @param values A character vector of possible methods.
#'
#' @details
#' This parameter defines how embeddings are aggregated.
#' By default, no aggregation is performed.
#'
#' @examples
#' values_aggregation
#' aggregation()
#' aggregation(values = c("none", "mean"))
#'
#' # Sample values
#' set.seed(123)
#' aggregation() %>% dials::value_sample(3)
#'
#' @export
aggregation <- function(values = values_aggregation) {
dials::new_qual_param(
type = "character",
values = values,
default = "none",
label = c(aggregation = "Aggregation Method")
)
}
#' @rdname aggregation
#' @export
values_aggregation <- c("none", "min", "max", "mean", "sum")--------------------------------------------------------------------------------
packages with custom parameters
package
parameter classes
numeric parameters
categorical parameters
transformations
unknown() and finalization
grids
dials-specific testing
conventions and patterns
issues in dials
--------------------------------------------------------------------------------
Before creating custom parameters in a new package, ensure your package is properly set up:
Prerequisites](references/package-extension-prerequisites.md)
dials to DESCRIPTION ImportsTo contribute parameters to dials:
git clone https://github.com/tidymodels/dials
cd dials pak::pak() devtools::load_all()See Source Development Guide for complete setup.
--------------------------------------------------------------------------------
For rapid parameter development:
R/ directorydevtools::load_all()See Development Workflow for details.
Essential tests for all parameters:
grid_regular(), grid_random()value_sample() and value_seq() work correctlySee testing guides:
Requirements](references/package-extension-requirements.md#testing-requirements)
--------------------------------------------------------------------------------
dials follows strict naming conventions:
R/param_[name].Rtests/testthat/test-params.R (shared), test-constructors.RUse roxygen tags consistently:
#' @inheritParams new_quant_param
#' @param range A two-element vector with the lower and upper bounds.
#' @details
#' This parameter is used for...
#' @examples
#' my_param()
#' @exportSee Roxygen Documentation for complete patterns.
For qualitative parameters, create a values_* vector:
#' @rdname param_name
#' @export
values_param_name <- c("option1", "option2", "option3")This convention is strongly recommended for consistency.
--------------------------------------------------------------------------------
Requirements](references/package-extension-requirements.md#testing-requirements)
Guide](references/package-roxygen-documentation.md)
repos/dials/R/param_*.Rtests/testthat/test-params.Rneed custom tuning parameters
tunable parameters
tunable main arguments
tunable parameters
--------------------------------------------------------------------------------
Extension development:
files if implementation requires it)
Source development:
files if implementation requires it)
Files to avoid creating:
Documentation files (content belongs in roxygen comments):
QUICK_REFERENCE.md
PR-related files (content belongs in conversation):
For PRs to dials:
Where content belongs:
Creating extra documentation files clutters the codebase. All documentation should be in roxygen comments (for code) or in conversation (for PR descriptions).
See extension-guide.md Step 5 and source-guide.md "File Creation Guidelines for PRs" for detailed enforcement rules.
--------------------------------------------------------------------------------
Last Updated: 2026-03-31
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.