optpolicy_main.OptimalPolicy.solvefair#

OptimalPolicy.solvefair(data_df, data_title='')#

Solve for optimal allocation rule with fairness adjustments.

Follows the suggestions of Bearth, Lechner, Muny, Mareckova (2025, arXiV). It accepts the same arguments as solve(). The return value is a single dictionary containing ‘allocation_df’, ‘result_dic’, and ‘outpath’. Repeated calls use the variable names and adjustment settings saved on the first call. Supply the corresponding input columns again; existing fairness-adjusted columns are replaced rather than adjusted a second time. The latest call replaces the cached training data used for decision-variable adjustment during allocate(). If estrisk_adjust() was used before the first call, these input policy scores are the risk-adjusted scores. Generated column names must not coincide with another configured input variable name. Such conflicts raise ValueError; rename the conflicting input column and its keyword entry. When both scores and decision variables are adjusted, use separately named input columns for these roles; sharing a name would also share the adjusted column and raises ValueError.

Parameters:
  • data_df (DataFrame) – Input data to train particular allocation algorithm.

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

Returns:

results_all_dict – Contains the results. This dictionary has the following structure: ‘allocation_df’ : DataFrame

Treatment allocations, with one row per observation used for allocation and one column per allocation rule. Entries are treatment codes. Column names depend on the allocation method and restrictions. The input features and policy scores are not included.

’result_dic’Dictionary

Contains additional information about trained allocation rule. Only complete when keyword _int_with_output is True.

’outpath’Path or None

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

Return type:

Dictionary.