optpolicy_main.OptimalPolicy.winners_losers#
- OptimalPolicy.winners_losers(data_df, welfare_df, welfare_reference_df: int = 0, outpath: None = None, title: str = '')#
Compare the winners and loser.
k-means is used to cluster groups of individuals that are similar in gains and losses from two user-provided allocations. The groups are described by the policy scores as well as the decision, protected, and materially relevant variables.
- Parameters
data_df (Dataframe) – Variables used for descriptions.
welfare_df (DataFrame) – Welfare of the allocations.
welfare_reference_df (DataFrame, optional) – Welfare of the reference allocation. The default is 0.
outpath (String or None, optional) – Path used to save the outputs.
title (String, optional) – Title used in the statistics. The default is ‘’.
- Returns
results_dict – Contains the results. This dictionary has the following structure: ‘data_plus_cluster_number_df’ : DataFrame
Cluster number (‘cluster_no’) is added to data_df.
- ’outpath’Path
Location of directory in which output is saved.
- Return type
Dictionary.