cramR: Cram Method for Efficient Simultaneous Learning and Evaluation

Performs the Cram method, a general and efficient approach to simultaneous learning and evaluation using a generic machine learning algorithm. In a single pass of batched data, the proposed method repeatedly trains a machine learning algorithm and tests its empirical performance. Because it utilizes the entire sample for both learning and evaluation, cramming is significantly more data-efficient than sample-splitting. Unlike cross-validation, Cram evaluates the final learned model directly, providing sharper inference aligned with real-world deployment. The method naturally applies to both policy learning and contextual bandits, where decisions are based on individual features to maximize outcomes. The package includes cram_policy() for learning and evaluating individualized binary treatment rules, cram_ml() to train and assess the population-level performance of machine learning models, and cram_bandit() for on-policy evaluation of contextual bandit algorithms. For all three functions, the package provides estimates of the average outcome that would result if the model were deployed, along with standard errors and confidence intervals for these estimates. Details of the method are described in Jia, Imai, and Li (2024) <https://www.hbs.edu/ris/Publication%20Files/2403.07031v1_a83462e0-145b-4675-99d5-9754aa65d786.pdf> and Jia et al. (2025) <doi:10.48550/arXiv.2403.07031>.

Version: 0.1.0
Depends: R (≥ 3.5.0)
Imports: caret (≥ 7.0-1), grf (≥ 2.4.0), glmnet (≥ 4.1.8), stats (≥ 4.3.3), magrittr (≥ 2.0.3), doParallel (≥ 1.0.17), foreach (≥ 1.5.2), DT (≥ 0.33), data.table (≥ 1.16.4), keras (≥ 2.15.0), dplyr (≥ 1.1.4), purrr, R6, rjson, R.devices, itertools, iterators
Suggests: testthat (≥ 3.0.0), covr (≥ 3.5.1), kableExtra (≥ 1.4.0), profvis (≥ 0.4.0), devtools, waldo, knitr, rmarkdown, randomForest, gbm, nnet, withr
Published: 2025-05-14
Author: Yanis Vandecasteele [cre, aut], Michael Lingzhi Li [ctb], Kosuke Imai [ctb], Zeyang Jia [ctb], Longlin Wang [ctb]
Maintainer: Yanis Vandecasteele <yanisvdc.ensae at gmail.com>
BugReports: https://github.com/yanisvdc/cramR/issues
License: GPL-3
URL: https://github.com/yanisvdc/cramR, https://yanisvdc.github.io/cramR/
NeedsCompilation: no
Citation: cramR citation info
Materials: README NEWS
CRAN checks: cramR results

Documentation:

Reference manual: cramR.pdf
Vignettes: Cram Bandit (source, R code)
Cram Bandit Helpers (source, R code)
Cram Bandit Simulation (source, R code)
Cram ML (source, R code)
Introduction & Cram Policy part 1 (source, R code)
Cram Policy part 2 (source, R code)
Cram Policy Simulation (source, R code)
Quick Start with CRAM (source, R code)

Downloads:

Package source: cramR_0.1.0.tar.gz
Windows binaries: r-devel: not available, r-release: not available, r-oldrel: not available
macOS binaries: r-release (arm64): cramR_0.1.0.tgz, r-oldrel (arm64): cramR_0.1.0.tgz, r-release (x86_64): not available, r-oldrel (x86_64): not available

Linking:

Please use the canonical form https://CRAN.R-project.org/package=cramR to link to this page.