hardhat
Creating Modeling Packages with hardhat
The hardhat package provides infrastructure for building modeling packages with consistent interfaces. It standardizes preprocessing via mold() (training) and forge() (prediction), handling formula, XY, and recipe inputs uniformly.
Quick Reference
| Task | Function |
|---|---|
| Preprocess training data | mold(x, y) or mold(formula, data) |
| Preprocess prediction data | forge(new_data, blueprint) |
| Create model object | new_model(..., blueprint, class) |
| XY blueprint | default_xy_blueprint(intercept = TRUE) |
| Formula blueprint | default_formula_blueprint(intercept = TRUE) |
| Recipe blueprint | default_recipe_blueprint(intercept = TRUE) |
| Format numeric predictions | spruce_numeric(pred) |
| Format class predictions | spruce_class(pred) |
| Format probability predictions | spruce_prob(pred) |
| Validate univariate outcome | validate_outcomes_are_univariate(outcomes) |
| Validate prediction size | validate_prediction_size(pred, new_data) |
More from jsperger/llm-r-skills
ggplot2
Use when working with R ggplot2 package, especially ggplot2 4.0+ features. Covers S7 migration (@ property access), theme defaults with ink/paper/accent, element_geom(), from_theme(), theme shortcuts (theme_sub_*), palette themes, labels with dictionary/attributes, discrete scale improvements (palette, continuous.limits, minor_breaks, sec.axis), position aesthetics (nudge_x/nudge_y, order), facet_wrap dir/space/layout, boxplot/violin/label styling, stat_manual(), stat_connect(), coord reversal.
41rlang-conditions
>
13targets-pipelines
>
12tidy-evaluation
>
11tidymodels-overview
This skill should be used when working with R tidymodels packages, including when the user asks to "create a tidymodels workflow", "build a recipe", "tune a model", "use parsnip", "set up resampling", "create a workflow_set", "compare models", "stack models", or mentions tidymodels packages like recipes, parsnip, workflows, workflowsets, tune, rsample, yardstick, or stacks. Provides ecosystem context before package-specific skills.
11metaprogramming
>
10