-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathmain.py
More file actions
70 lines (67 loc) · 3.34 KB
/
main.py
File metadata and controls
70 lines (67 loc) · 3.34 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Controlling Fairness and Bias in Dynamic Learning-to-Rank
#TODO Readme
author: Marco Morik
"""
from config import ex
import data_utils
import warnings; warnings.simplefilter('ignore') ##Ignores Warnings for nicer Plots. Disable for Debugging
import birkhoff
from Experiments import *
import plotting
plotting.init_plotting()
import Simulation
birkhoff.TOLERANCE = 10**(-8)
@ex.automain
def __main__(EXPERIMENT, MOVIE_RATING_FILE, PLOT_PREFIX, trials, iterations):
EXPERIMENT = int(EXPERIMENT)
if EXPERIMENT == 1:
multiple_items = [load_news_items(n=30, completly_random=True) for i in range(trials)]
items = multiple_items[0]
popularity = np.ones(len(items))
G = assign_groups(items)
if not os.path.exists(PLOT_PREFIX):
os.makedirs(PLOT_PREFIX)
collect_relevance_convergence(items, popularity, trials, click_models=["PBM_log"],
methods=["Naive", "IPS", "Fair-I-IPS"], iterations=iterations, multiple_items=multiple_items)
elif EXPERIMENT == 2:
multiple_items = [load_news_items(n=30, completly_random=True) for i in range(trials)]
items = multiple_items[0]
popularity = np.ones(len(items))
G = assign_groups(items)
if not os.path.exists(PLOT_PREFIX):
os.makedirs(PLOT_PREFIX)
collect_relevance_convergence(items, popularity, trials, click_models=["PBM_log"],
methods=["Naive", "IPS"], iterations=iterations, multiple_items=multiple_items)
elif EXPERIMENT == 3:
experiment_different_starts(False, trials, iterations, PLOT_PREFIX)
elif EXPERIMENT == 4:
compare_controller_LP(trials=trials, iterations=iterations)
elif EXPERIMENT == 5:
test_different_groups(trials, iterations, False, prefix=PLOT_PREFIX)
elif EXPERIMENT == 6:
test_different_population(trials, iterations, False,prefix=PLOT_PREFIX)
elif EXPERIMENT == 7:
data_utils.load_movie_data(movie_ranking_sample_file = MOVIE_RATING_FILE.replace("trial0.npy","trial"))
movie_experiment(PLOT_PREFIX,
["Naive", "IPS", "Pers", "Skyline-Pers"],
MOVIE_RATING_FILE,
trials=trials, iterations=iterations, binary_rel=True)
elif EXPERIMENT == 8:
data_utils.load_movie_data(movie_ranking_sample_file=MOVIE_RATING_FILE.replace("trial0.npy", "trial"))
movie_experiment(PLOT_PREFIX,
["Naive", "IPS", "Pers", "Fair-E-Pers"],
MOVIE_RATING_FILE,
trials=trials, iterations=iterations, binary_rel=True)
elif EXPERIMENT == 9:
data_utils.load_movie_data(movie_ranking_sample_file=MOVIE_RATING_FILE.replace("trial0.npy", "trial"))
movie_experiment(PLOT_PREFIX,
["Naive", "IPS", "Pers", "Fair-I-Pers"],
MOVIE_RATING_FILE,
trials=trials, iterations=iterations, binary_rel=True)
elif EXPERIMENT == 10:
data_utils.load_movie_data(movie_ranking_sample_file=MOVIE_RATING_FILE.replace("trial0.npy", "trial"))
movie_experiment(PLOT_PREFIX,
["Pers", "Fair-I-Pers", "Fair-E-Pers"],
MOVIE_RATING_FILE,
trials=trials, iterations=iterations, binary_rel=True)