experiments.experiment_utils

Utilities used in the rest of the library

Functions

batch_predictions(model, solution, X_test, ...)

Run model forward pass in batches.

batch_predictions_custom_regime(model, ...)

Run model forward pass in batches for the custom regime.

generate_behavior_policy_episodes(...[, verbose])

Utility function for reinforcement learning to generate new episodes using the behavior policy to use in each trial.

generate_episodes_and_calc_J(**kwargs)

Calculate the expected discounted return by generating episodes

has_failed(g)

Condition for whether a value of g is unsafe.

load_regenerated_episodes(results_dir, ...)

Load the episodes generatd for each experiment trial.

load_resampled_datasets(spec, results_dir, ...)

Utility function for supervised learning to generate the resampled datasets to use in each trial.

make_batch_epoch_dict_fixedniter(niter, ...)

Convenience function for figuring out the number of epochs necessary to ensure that at each data fraction, the total number of iterations (and batch size) will stay fixed.

make_batch_epoch_dict_min_sample_repeat(...)

Convenience function for figuring out the number of epochs necessary to ensure that the number of iterations for each data frac is: max(niter_min,# of iterations such that each sample is seen num_repeat times)

prep_custom_data(trial_dataset, n_points[, ...])

Utility function for preparing data and sensitive attributes for the custom regime for a given trial with n_points (given data frac)

prep_data_for_fairlearn(spec, results_dir, ...)

Utility function for preparing features and labels for a given fairlearn trial.

prep_feat_labels(trial_dataset, n_points[, ...])

Utility function for preparing features and labels for a given trial with n_points (given data frac)

prep_feat_labels_for_baseline(spec, ...)

Utility function for preparing features and labels for a given baseline trial.

setup_SA_spec_for_exp(spec, regime, ...)

Utility function for setting up the spec object to use for a Seldonian algorithm trial

supervised_initial_solution_fn(m, x, y)

A common initial solution function used in supervised learning.

trial_arg_chunker(data_fracs, n_trials, ...)

Convenience function for parallel processing that chunks up the data fractions and trial indices as arguments for use in the map function of a ProcessPoolExecutor.