add recommender to repository

This commit is contained in:
hannes.kuchelmeister
2020-05-04 10:49:59 +02:00
parent 67ae83e0bd
commit 719f3d5ea7
51 changed files with 5792 additions and 0 deletions

1
data_gen/gen.bat Normal file
View File

@@ -0,0 +1 @@
python gen_diagram.py

115
data_gen/gen_diagram.py Normal file
View File

@@ -0,0 +1,115 @@
import matplotlib.pyplot as plt
import pandas as pd
import os
def setAxLinesBW(ax):
"""
Take each Line2D in the axes, ax, and convert the line style to be
suitable for black and white viewing.
"""
MARKERSIZE = 3
COLORMAP = {
'#ff7f0e': {'marker': None, 'dash': [3,4]},
'#1f77b4': {'marker': None, 'dash': [1,1]},
'#2ca02c': {'marker': None, 'dash': (None,None)}
}
lines_to_adjust = ax.get_lines()
try:
lines_to_adjust += ax.get_legend().get_lines()
except AttributeError:
pass
for line in lines_to_adjust:
origColor = line.get_color()
line.set_color('black')
line.set_dashes(COLORMAP[origColor]['dash'])
line.set_marker(COLORMAP[origColor]['marker'])
line.set_markersize(MARKERSIZE)
def setFigLinesBW(fig):
"""
Take each axes in the figure, and for each line in the axes, make the
line viewable in black and white.
"""
for ax in fig.get_axes():
setAxLinesBW(ax)
def load_data_frame(path):
frame = pd.read_csv(path, index_col=0).T
frame.index = frame.index.astype(int)
return frame
def new_fig(subplot_row=1, subplot_column=2, dpi=300, title="Untitled"):
figure, axes = plt.subplots(subplot_row, subplot_column, sharey=True)
#figure.tight_layout(pad=1.5)
for axis in axes:
axis.tick_params(
axis="y", # both major and minor ticks are affected
left=True,
labelleft=True,
labelright=True)
figure.canvas.set_window_title(title)
figure.dpi = dpi
figure.set_figwidth(4 * subplot_column)
figure.set_figheight(4 * subplot_row)
return axes
happy_dictator = load_data_frame("./{}".format("happy_dictator.csv"))
unhappy_dictator = load_data_frame("./{}".format("unhappy_dictator.csv"))
axes = new_fig()
axes[0].set_title("satisfaction")
#axes[0].set_xlim(x_lim)
axes[0].set_xlabel("tc")
axes[0].set_ylabel("number of people")
happy_dictator.plot(ax=axes[0])
setAxLinesBW(axes[0])
axes[1].set_title("dissatisfaction")
axes[1].set_xlabel("tc")
axes[1].set_ylabel("number of people")
#axes[1].set_xlim(x_lim)
unhappy_dictator.plot(ax=axes[1])
setAxLinesBW(axes[1])
plt.savefig("./dictator.pdf",format="pdf")
happy_change = load_data_frame("./{}".format("happy_change.csv"))
unhappy_change = load_data_frame("./{}".format("unhappy_change.csv"))
axes = new_fig()
axes[0].set_title("satisfaction change")
#axes[0].set_xlim(x_lim)
axes[0].set_xlabel("tc")
axes[0].set_ylabel("number of people")
happy_change.plot(ax=axes[0])
setAxLinesBW(axes[0])
axes[1].set_title("dissatisfaction change")
axes[1].set_xlabel("tc")
axes[1].set_ylabel("number of people")
#axes[1].set_xlim(x_lim)
unhappy_change.plot(ax=axes[1])
setAxLinesBW(axes[1])
plt.savefig("./change.pdf",format="pdf")
plt.show()
plt.close()

View File

@@ -0,0 +1,4 @@
,10,20,30,40,50,60,63,65,67,70,73,75,77,80,81,82,83,84,85,87,90,91,92,93,94
heterogenous,0.079,0.166,0.256,0.232,0.375,0.631,0.625,0.605,0.561,0.501,0.427,0.351,0.255,0.153,0.083,0.062,-0.002,-0.048,-0.14,-0.282,-0.442,-0.568,-0.633,-0.802,-0.895
random,0.01,0.05,0.099,0.153,0.266,0.533,0.611,0.668,0.716,0.773,0.831,0.858,0.869,0.853,0.848,0.83,0.804,0.769,0.737,0.643,0.405,0.243,0.137,-0.155,-0.337
homogenous,0,0,0,0,0,0,0,0,0,0,0.004,0.005,0.006,0.011,0.011,0.014,0.026,0.031,0.048,0.078,0.164,0.21,0.267,0.303,0.271
1 10 20 30 40 50 60 63 65 67 70 73 75 77 80 81 82 83 84 85 87 90 91 92 93 94
2 heterogenous 0.079 0.166 0.256 0.232 0.375 0.631 0.625 0.605 0.561 0.501 0.427 0.351 0.255 0.153 0.083 0.062 -0.002 -0.048 -0.14 -0.282 -0.442 -0.568 -0.633 -0.802 -0.895
3 random 0.01 0.05 0.099 0.153 0.266 0.533 0.611 0.668 0.716 0.773 0.831 0.858 0.869 0.853 0.848 0.83 0.804 0.769 0.737 0.643 0.405 0.243 0.137 -0.155 -0.337
4 homogenous 0 0 0 0 0 0 0 0 0 0 0.004 0.005 0.006 0.011 0.011 0.014 0.026 0.031 0.048 0.078 0.164 0.21 0.267 0.303 0.271

View File

@@ -0,0 +1,4 @@
,10,20,30,40,50,60,63,65,67,70,73,75,77,80,81,82,83,84,85,87,90,91,92,93,94
heterogenous,3.7541875,3.805,3.654,3.594,3.343,2.807,2.683,2.61,2.535,2.387,2.263,2.192,2.136,2.014,1.948,1.916,1.837,1.814,1.746,1.638,1.448,1.352,1.312,1.235,1.186
random,3.989,3.945,3.878,3.8,3.655,3.262,3.138,3.041,2.938,2.781,2.618,2.51,2.404,2.229,2.141,2.102,2.024,1.992,1.88,1.727,1.513,1.396,1.324,1.183,1.121
homogenous,4,4,4,4,4,4,4,4,4,4,3.996,3.995,3.994,3.989,3.988,3.985,3.971,3.963,3.944,3.905,3.756,3.596,3.443,3.025,2.674
1 10 20 30 40 50 60 63 65 67 70 73 75 77 80 81 82 83 84 85 87 90 91 92 93 94
2 heterogenous 3.7541875 3.805 3.654 3.594 3.343 2.807 2.683 2.61 2.535 2.387 2.263 2.192 2.136 2.014 1.948 1.916 1.837 1.814 1.746 1.638 1.448 1.352 1.312 1.235 1.186
3 random 3.989 3.945 3.878 3.8 3.655 3.262 3.138 3.041 2.938 2.781 2.618 2.51 2.404 2.229 2.141 2.102 2.024 1.992 1.88 1.727 1.513 1.396 1.324 1.183 1.121
4 homogenous 4 4 4 4 4 4 4 4 4 4 3.996 3.995 3.994 3.989 3.988 3.985 3.971 3.963 3.944 3.905 3.756 3.596 3.443 3.025 2.674

View File

@@ -0,0 +1,4 @@
,10,20,30,40,50,60,63,65,67,70,73,75,77,80,81,82,83,84,85,87,90,91,92,93,94
heterogenous,0,-0.079,-0.166,-0.256,-0.232,-0.375,-0.417,-0.474,-0.589,-0.631,-0.625,-0.605,-0.561,-0.501,-0.501,-0.464,-0.427,-0.377,-0.351,-0.255,-0.153,-0.083,-0.062,0.002,0.048
random,0,-0.01,-0.05,-0.099,-0.153,-0.266,-0.336,-0.377,-0.441,-0.533,-0.611,-0.668,-0.716,-0.773,-0.783,-0.818,-0.831,-0.841,-0.858,-0.869,-0.853,-0.848,-0.83,-0.804,-0.769
homogenous,0,0,0,0,0,0,0,0,0,0,0,0,0,-0.002,-0.002,-0.003,-0.004,-0.004,-0.005,-0.006,-0.011,-0.011,-0.014,-0.026,-0.031
1 10 20 30 40 50 60 63 65 67 70 73 75 77 80 81 82 83 84 85 87 90 91 92 93 94
2 heterogenous 0 -0.079 -0.166 -0.256 -0.232 -0.375 -0.417 -0.474 -0.589 -0.631 -0.625 -0.605 -0.561 -0.501 -0.501 -0.464 -0.427 -0.377 -0.351 -0.255 -0.153 -0.083 -0.062 0.002 0.048
3 random 0 -0.01 -0.05 -0.099 -0.153 -0.266 -0.336 -0.377 -0.441 -0.533 -0.611 -0.668 -0.716 -0.773 -0.783 -0.818 -0.831 -0.841 -0.858 -0.869 -0.853 -0.848 -0.83 -0.804 -0.769
4 homogenous 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.002 -0.002 -0.003 -0.004 -0.004 -0.005 -0.006 -0.011 -0.011 -0.014 -0.026 -0.031

View File

@@ -0,0 +1,4 @@
,10,20,30,40,50,60,63,65,67,70,73,75,77,80,81,82,83,84,85,87,90,91,92,93,94
heterogenous,0,0.081,0.195,0.346,0.406,0.657,0.762,0.859,1.052,1.193,1.317,1.39,1.465,1.613,1.65,1.71,1.737,1.793,1.808,1.864,1.986,2.052,2.084,2.163,2.186
random,0,0.011,0.055,0.122,0.2,0.345,0.448,0.513,0.604,0.738,0.862,0.959,1.062,1.219,1.253,1.34,1.382,1.451,1.49,1.596,1.771,1.859,1.898,1.976,2.008
homogenous,0,0,0,0,0,0,0,0,0,0,0,0,0,0.002,0.002,0.003,0.004,0.004,0.005,0.006,0.011,0.012,0.015,0.029,0.037
1 10 20 30 40 50 60 63 65 67 70 73 75 77 80 81 82 83 84 85 87 90 91 92 93 94
2 heterogenous 0 0.081 0.195 0.346 0.406 0.657 0.762 0.859 1.052 1.193 1.317 1.39 1.465 1.613 1.65 1.71 1.737 1.793 1.808 1.864 1.986 2.052 2.084 2.163 2.186
3 random 0 0.011 0.055 0.122 0.2 0.345 0.448 0.513 0.604 0.738 0.862 0.959 1.062 1.219 1.253 1.34 1.382 1.451 1.49 1.596 1.771 1.859 1.898 1.976 2.008
4 homogenous 0 0 0 0 0 0 0 0 0 0 0 0 0 0.002 0.002 0.003 0.004 0.004 0.005 0.006 0.011 0.012 0.015 0.029 0.037