optpolicy_main.OptimalPolicy.allocate#
- OptimalPolicy.allocate(data_df, data_title='', fair_adjust_decision_vars=False)#
Allocate observations to treatment state.
For ‘policy_tree’, ‘policy tree old’ and ‘bps_classifier’, first run solve() or solvefair() on this instance to fit the allocation rule. With ‘best_policy_score’, allocate() computes allocations directly from the supplied policy scores and does not require prior training.
- Parameters:
data_df (DataFrame) – Input data with at least features or policy scores (depending on algorithm).
data_title (String, optional) – This string is used as title in outputs. The default is ‘’.
fair_adjust_decision_vars (Boolean, optional) – Controls recomputation of decision-variable fairness adjustments. Use True only after
solvefair()with'fair_adjust_target'set to'xvariables'or'scores_xvariables'. True recomputes adjusted variables and replaces existing columns with those names. With False, available adjusted variables are reused; missing adjusted decision variables required by the trained rule are computed automatically. Best-policy-score allocation does not require decision variables, so False does not trigger their adjustment. If all current policy-score columns are supplied, earlier risk and fairness inputs are unnecessary for best-policy-score allocation unless True requests variable adjustment. On an instance that has not usedsolvefair(), this option has no effect. The default is False.
- Returns:
results – 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.
- ’outpath’Path or None
Directory in which output is saved. None if _int_with_output is False.
- Return type:
Dictionary.