cramR0.1.1 package

Cram Method for Efficient Simultaneous Learning and Evaluation

BatchContextualEpsilonGreedyPolicy

Batch Contextual Epsilon-Greedy Policy

BatchContextualLinTSPolicy

Batch Contextual Thompson Sampling Policy

BatchLinUCBDisjointPolicyEpsilon

Batch Disjoint LinUCB Policy with Epsilon-Greedy

ContextualLinearBandit

Contextual Linear Bandit Environment

cram_bandit_est

Cram Bandit Policy Value Estimate

cram_bandit_sim

Cram Bandit Simulation

cram_bandit_var

Cram Bandit Variance of the Policy Value Estimate

cram_bandit

Cram Bandit: On-policy Statistical Evaluation in Contextual Bandits

cram_estimator

Cram Policy Estimator for Policy Value Difference (Delta)

cram_expected_loss

Cram ML Expected Loss Estimate

cram_learning

Cram Policy Learning

cram_ml

Cram ML: Simultaneous Machine Learning and Evaluation

cram_policy_value_estimator

Cram Policy: Estimator for Policy Value (Psi)

cram_policy

Cram Policy: Efficient Simultaneous Policy Learning and Evaluation

cram_simulation

Cram Policy Simulation

cram_var_expected_loss

Cram ML: Variance Estimate of the crammed expected loss estimate

cram_variance_estimator_policy_value

Cram Policy: Variance Estimate of the crammed Policy Value estimate (P...

cram_variance_estimator

Cram Policy: Variance Estimate of the crammed Policy Value Difference ...

fit_model_ml

Cram ML: Fit Model ML

fit_model

Cram Policy: Fit Model

get_betas

Generate Reward Parameters for Simulated Linear Bandits

LinUCBDisjointPolicyEpsilon

LinUCB Disjoint Policy with Epsilon-Greedy Exploration

ml_learning

Cram ML: Generalized ML Learning

model_predict_ml

Cram ML: Predict with the Specified Model

model_predict

Cram Policy: Predict with the Specified Model

set_model

Cram Policy: Set Model

test_baseline_policy

Validate or Set the Baseline Policy

test_batch

Validate or Generate Batch Assignments

validate_params_fnn

Cram Policy: Validate Parameters for Feedforward Neural Networks (FNNs...

validate_params

Cram Policy: Validate User-Provided Parameters for a Model

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>.

  • Maintainer: Yanis Vandecasteele
  • License: GPL-3
  • Last published: 2025-08-24