optpolicy_main.OptimalPolicyVersions.solve#

OptimalPolicyVersions.solve(data_df, data_title='')#

Solve for optimal allocation rule.

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 (Dictionary.) – Contains the results. This dictionary has the following structure: ‘allocation_df’ : DataFrame

    Allocations to treatment versions, with one row per observation used for allocation and one column per allocation rule. Entries are integer codes starting at zero. Main treatments follow the order of keys in ‘policyscores_dict’; their versions follow the order of the corresponding score names. Codes run consecutively across all main treatments. A main treatment without separate versions occupies one code. The input features and policy scores are not included.

    ’result_dic’Dictionary or list

    Additional information about the fitted allocation rules. For ‘policy_tree’, a list with the ‘result_dic’ of the main tree first, followed by one entry per main treatment, in ‘policyscores_dict’ order. Each subsequent entry is the ‘result_dic’ of its version tree, or None if no version tree was fitted. For other methods, the underlying OptimalPolicy instance’s ‘result_dic’ dictionary. Contents depend on the allocation method and output settings.

    ’outpath’Path or None

    Directory in which output is saved. None if params_optpol sets _int_with_output to False.

  • data_df (DataFrame) – Second item of the returned tuple. Contains the retained training observations, in the same row order as ‘allocation_df’, with an index starting at zero. Rows removed during preparation are excluded. For ‘policy_tree’, this includes removals in version trees. For other methods, any separate feature-selection sample is also excluded. Input columns are retained, with names converted to lowercase. An identifier column may be added during preparation.