-
Notifications
You must be signed in to change notification settings - Fork 2
/
qf_tester.py
32 lines (25 loc) · 1.3 KB
/
qf_tester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pandas as pd
import fundingutils
def run_qf(votes_file, strategy, min_donation_threshold_amount, matching_cap_amount, matching_amount, passport_threshold):
votes = pd.read_csv(votes_file)
# Prepare votes data
votes_prep = fundingutils.prep_donations_data(votes, min_donation_threshold_amount, passport_threshold)
votes_matrix = fundingutils.pivot_votes(votes_prep)
votes_qf_matching = fundingutils.get_qf_matching(strategy, votes_matrix, matching_cap_amount, matching_amount, cluster_df = None if strategy == 'qf' else votes_matrix)
# Save the matching data to a csv file
votes_qf_matching['strategy'] = strategy
votes_qf_matching.to_csv(f'{votes_file.split(".")[0]}_matching_data.csv')
def run_test():
# Use a default csv file in the same directory
votes_file = 'Zuzalu_Events_votes.csv'
strategy = 'COCM' # can accept: 'qf', 'COCM', 'pairwise' or 'donation_profile_cluster_match'
min_donation_threshold_amount = 1
matching_cap_amount = 50
matching_amount = 166.5
passport_threshold = 15
run_qf(votes_file, strategy, min_donation_threshold_amount, matching_cap_amount, matching_amount, passport_threshold)
def main():
# Here you can add conditions or user input to decide which function to run
run_test()
if __name__ == "__main__":
main()