optpolicy_main.OptimalPolicy.solve#

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

Solve for optimal allocation rule. Training preparation keeps the required columns and removes rows with missing values in those columns. This cleaning is always performed. Covariate screening runs automatically for ‘policy_tree’, ‘policy tree old’ and ‘bps_classifier’. It is skipped for ‘best_policy_score’.

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

    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.

  • data_df (DataFrame) – Second item of the returned tuple. Contains the input data for the observations used to train the allocation rule. Rows removed during preparation or reserved for feature selection are excluded. Rows align with ‘allocation_df’, and the index is reset to consecutive integers starting at zero. Input columns are retained, with names converted to lowercase. An identifier column may be added during preparation.