The Majoritarian module provides access to the implementations of the majoritarian rank aggregation methods of FLAGR.These methods are based on the majority criterion, that under several circumstances, identify the “winning” elements. The module includes three classes which are described below: CondorcetWinners, CopelandWinners and OutrankingApproach. Each method implements different scenarios for the majority criterion.
Implementation file
pyflagr/pyflagr/Majoritarian.py
The CondorcetWinners and CopelandWinners Python classes
Both classes derive from RAM, a base class defined in the RAM module. They inherit the flagr_lib connector from RAM, and through it, they obtain access to the respective exposed functions of FLAGR.
The constructor of CondorcetWinners determines the data types of the input arguments and the return type of the Condorcet() exposed function. Similarly, the constructor of CopelandWinners determines the data types of the input arguments and the return type of the Copeland() exposed function. Both constructors accept just one argument:
| Parameter | Type | Default | Description |
eval_pts |
Integer, Optional. Considered only if rels_file or rels_df is set. |
10 | Determines the elements in the aggregate list on which the evaluation measures (i.e. Precision, and nDCG) will be computed. For example, for eval_pts=10 FLAGR will compute Average Precision, \(P@1, P@2, ... P@10\) and \(N@1, N@2, ... N@10\). |
CondorcetWinners and CopelandWinners also include an aggregate() function which receives the user-defined parameters and passes them to the Condorcet() and Copeland() exposed functions respectively. The arguments of aggregate() are:
| Parameter | Type | Default | Description |
input_file |
String - Required, unless input_df is set. |
Empty String | A CSV file that contains the input lists to be aggregated. |
input_df |
Pandas DataFrame - Required, unless input_file is set. |
None |
A Pandas DataFrame that contains the input lists to be aggregated. Note: If both input_file and input_df are set, only the former is used; the latter is ignored. |
rels_file |
String, Optional. | Empty String | A CSV file that contains the relevance judgements of the involved list elements. If such a file is passed, FLAGR will evaluate the generated aggregate list/s by computing several retrieval effectiveness evaluation measures. The results of the evaluation will be stored in the eval_df DataFrame. Otherwise, no evaluation will take place and eval_df will be empty. |
rels_df |
Pandas DataFrame, Optional. | None |
A Pandas DataFrame that contains the relevance judgements of the involved list elements. If such a dataframe is passed, FLAGR will evaluate the generated aggregate list/s by computing several retrieval effectiveness evaluation measures. The results of the evaluation will be stored in the eval_df DataFrame. Otherwise, no evaluation will take place and eval_df will be empty.Note: If both rels_file and rels_df are set, only the former is used; the latter is ignored. |
output_dir |
String, Optional. | Temporary directory (OS-specific) | The directory where the output files (aggregate lists and evaluation) will be stored. If it is not set, the default location will be used. |
The OutrankingApproach Python class
This class can be used to execute the Outranking Approach of Farah and Vanderpooten, 2007. Similarly to the other majoritarian methods, OutrankingApproach derives from RAM, a base class defined in the RAM module. It also inherits the flagr_lib connector from RAM and obtains access to the OutrankingApproach() exposed function of FLAGR.
The constructor of OutrankingApproach determines the data types of the input arguments and the return type of the OutrankingApproach() exposed function. Observe the similarity between the members of self.flagr_lib.OutrankingApproach.argtypes and the input arguments of the OutrankingApproach() exposed function.
| Parameter | Type | Default | Description |
eval_pts |
Integer, Optional. Considered only if rels_file or rels_df is set. |
10 | Determines the elements in the aggregate list on which the evaluation measures (i.e. Precision, and nDCG) will be computed. For example, for eval_pts=10 FLAGR will compute Average Precision, \(P@1, P@2, ... P@10\) and \(N@1, N@2, ... N@10\). |
preference |
Hyperparameter, Float, Optional. | 0.00 | The value of the preference threshold. |
veto |
Hyperparameter, Float, Optional. | 0.75 | The value of the veto threshold. |
concordance |
Hyperparameter, Float, Optional. | 0.00 | The value of the concordance threshold. |
discordance |
Hyperparameter, Float, Optional. | 0.25 | The value of the discordance threshold. |
OutrankingApproach includes an aggregate() function which receives the user-defined parameters and passes them to the OutrankingApproach() exposed function. The arguments of this function are identical to the ones of the other majoritarian methods.
The following interactive block diagram depicts the architecture of PyFLAGR and its linkage to the FLAGR shared library.
