optpolicy_main.OptimalPolicy.evaluate#

OptimalPolicy.evaluate(allocation_df, data_df, data_title='', seed=12434)#

Evaluate allocation with potential outcome data.

Run solve() or solvefair() on this instance first. With ‘gen_method’ == ‘best_policy_score’, allocate() also initializes the instance for evaluation.

Parameters:
  • allocation_df (DataFrame) – Optimal allocation as outputed by the solve(), solvefair(), and allocate() methods. Names ‘random’, ‘observed’ and ‘best ATE’ are used for automatic reference allocations. A ValueError is raised if a supplied column name conflicts with a reference generated for this call.

  • data_df (DataFrame) – Evaluation variables for the observations in allocation_df. Both DataFrames must have the same number of rows in the same observation order. Rows are paired by position; index labels and identifier columns are not used to align them. Welfare uses the complete set of current ‘var_polscore_name’ columns when available. After fairness or estimation-risk adjustment, missing current scores trigger a fallback to the last complete available treatment block in ‘var_polscore_desc_name’. If neither is available, primary welfare measures are omitted; allocation shares and available descriptive statistics are still reported. After solvefair(), also include every variable in ‘var_protected_name_ord’ and ‘var_protected_name_unord’. These columns are required for fairness diagnostics, even when ‘_int_with_output’ is False. Pearson correlations are reported only for numeric protected columns; nonnumeric categories receive NaN for this measure. Categorical dependence measures are still computed when the distinct-value threshold permits them.

  • data_title (String, optional) – This string is used as title in outputs. The default is ‘’.

  • seed (Integer, optional) – Seed for random number generators. The default is 12434.

Returns:

results_all_dic –

‘results_dic’: Dictionary with one entry per population and allocation rule.

Keys are ‘All <allocation>’ and, when observed treatments are available, ‘Switchers <allocation>’. Switchers receive a different treatment from their observed treatment; this subset is specific to each allocation rule. Reference allocations are added automatically: ‘random’, ‘observed’ when available, and ‘best ATE’ when welfare scores are available. ‘best ATE’ assigns everyone the treatment with the highest mean policy score minus its treatment cost. Each entry contains ‘treatment share’ and ‘number of observations’. When welfare scores are available, gross mean welfare is stored under the same key as the outer entry, and net mean welfare under ‘welfare net of costs’. Additional score summaries and fairness diagnostics are included when applicable.

’outpath’Path or None

Directory in which output is saved. None if _int_with_output is False.

Return type:

Dictionary