hardhat is a developer focused package designed to ease the creation of new modeling packages, while simultaneously promoting good R modeling package standards as laid out by the set of opinionated Conventions for R Modeling Packages.
hardhat has four main goals:
Easily, consistently, and robustly preprocess data at fit time and prediction time with
Provide one source of truth for common input validation functions, such as checking if new data at prediction time contains the same required columns used at fit time.
Provide extra utility functions for additional common tasks, such as adding intercept columns, standardizing
predict()output, and extracting valuable class and factor level information from the predictors.
Reimagine the base R preprocessing infrastructure of
stats::model.frame()using the stricter approaches found in
The idea is to reduce the burden of creating a good modeling interface as much as possible, and instead let the package developer focus on writing the core implementation of their new model. This benefits not only the developer, but also the user of the modeling package, as the standardization allows users to build a set of “expectations” around what any modeling function should return, and how they should interact with it.
You can install the released version of hardhat from CRAN with:
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("tidymodels/hardhat")
To learn about how to use hardhat, check out the vignettes:
vignette("mold", "hardhat"): Learn how to preprocess data at fit time with
vignette("forge", "hardhat"): Learn how to preprocess new data at prediction time with
vignette("package", "hardhat"): Learn how to use
forge()to help in creating a new modeling package.
You can also watch Max Kuhn discuss how to use hardhat to build a new modeling package from scratch at the XI Jornadas de Usuarios de R conference here.
This project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
For questions and discussions about tidymodels packages, modeling, and machine learning, please post on RStudio Community.
If you think you have encountered a bug, please submit an issue.
Either way, learn how to create and share a reprex (a minimal, reproducible example), to clearly communicate about your code.
Check out further details on contributing guidelines for tidymodels packages and how to get help.