-
Notifications
You must be signed in to change notification settings - Fork 0
/
intersection_sets_good_guys.py
205 lines (89 loc) · 9.74 KB
/
intersection_sets_good_guys.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env python
'''
Code to read the pickle files with the set of users that are good guys accorging
to different definitions, and calculate the intersections
Created by Julia Poncela, on January 2015.
'''
import pickle
from unidecode import unidecode # to transform whatever unicode special characters into just plain ascii (otherwise networkx complains)
import histograma_bines_gral
import numpy
from scipy import stats
def main():
coop_threshold=0.75
print "cooperation threshold", coop_threshold
# list_type_definitions=["All","lowerHarmony","higherHarmony", "PD", "higherPD", "lowerPD", "SH","SD"]
filename="../Results/list_all_users.pickle"
list_all_users=pickle.load(open(filename, 'rb'))
filename="../Results/list_good_guys_lowerHarmony_threshold_coop"+str(coop_threshold)+".pickle"
list_good_guys_lowerHarmony=pickle.load(open(filename, 'rb'))
filename="../Results/list_bad_guys_lowerHarmony_threshold_coop"+str(coop_threshold)+".pickle"
list_bad_guys_lowerHarmony=pickle.load(open(filename, 'rb'))
filename="../Results/list_good_guys_higherHarmony_threshold_coop"+str(coop_threshold)+".pickle"
list_good_guys_higherHarmony=pickle.load(open(filename, 'rb'))
filename="../Results/list_bad_guys_higherHarmony_threshold_coop"+str(coop_threshold)+".pickle"
list_bad_guys_higherHarmony=pickle.load(open(filename, 'rb'))
filename="../Results/list_good_guys_PD_threshold_coop"+str(coop_threshold)+".pickle"
list_good_guys_PD=pickle.load(open(filename, 'rb'))
filename="../Results/list_bad_guys_PD_threshold_coop"+str(coop_threshold)+".pickle"
list_bad_guys_PD=pickle.load(open(filename, 'rb'))
filename="../Results/list_good_guys_SH_threshold_coop"+str(coop_threshold)+".pickle"
list_good_guys_SH=pickle.load(open(filename, 'rb'))
filename="../Results/list_bad_guys_SH_threshold_coop"+str(coop_threshold)+".pickle"
list_bad_guys_SH=pickle.load(open(filename, 'rb'))
filename="../Results/list_good_guys_SD_threshold_coop"+str(coop_threshold)+".pickle"
list_good_guys_SD=pickle.load(open(filename, 'rb'))
filename="../Results/list_bad_guys_SD_threshold_coop"+str(coop_threshold)+".pickle"
list_bad_guys_SD=pickle.load(open(filename, 'rb'))
coop_threshold=0.25
filename="../Results/list_good_guys_lowerPD_threshold_coop"+str(coop_threshold)+".pickle"
list_good_guys_lowerPD=pickle.load(open(filename, 'rb'))
filename="../Results/list_bad_guys_lowerPD_threshold_coop"+str(coop_threshold)+".pickle"
list_bad_guys_lowerPD=pickle.load(open(filename, 'rb'))
filename="../Results/list_good_guys_higherPD_threshold_coop"+str(coop_threshold)+".pickle"
list_good_guys_higherPD=pickle.load(open(filename, 'rb'))
filename="../Results/list_bad_guys_higherPD_threshold_coop"+str(coop_threshold)+".pickle"
list_bad_guys_higherPD=pickle.load(open(filename, 'rb'))
print
print "intersection between All (",len(list_all_users),") and good lowerHarmony (",len(list_good_guys_lowerHarmony),"): ", len(list(set(list_all_users)& set(list_good_guys_lowerHarmony))), float(len(list_good_guys_lowerHarmony))/len(list_all_users)*100.,"%"
print "intersection between All (",len(list_all_users),") and good higherHarmony (",len(list_good_guys_higherHarmony),"): ", len(list(set(list_all_users)& set(list_good_guys_higherHarmony))), float(len(list_good_guys_higherHarmony))/len(list_all_users)*100.,"%"
print "intersection between All (",len(list_all_users),") and good PD (",len(list_good_guys_PD),"): ", len(list(set(list_all_users)& set(list_good_guys_PD))), float(len(list_good_guys_PD))/len(list_all_users)*100.,"%"
print "intersection between All (",len(list_all_users),") and good lowerPD (",len(list_good_guys_lowerPD),"): ", len(list(set(list_all_users)& set(list_good_guys_lowerPD))), float(len(list_good_guys_lowerPD))/len(list_all_users)*100.,"%"
print "intersection between All (",len(list_all_users),") and bad lowerPD (",len(list_bad_guys_lowerPD),"): ", len(list(set(list_all_users)& set(list_bad_guys_lowerPD))), float(len(list_bad_guys_lowerPD))/len(list_all_users)*100.,"%"
print "intersection between All (",len(list_all_users),") and good higherPD (",len(list_good_guys_higherPD),"): ", len(list(set(list_all_users)& set(list_good_guys_higherPD))), float(len(list_good_guys_higherPD))/len(list_all_users)*100.,"%"
print "intersection between All (",len(list_all_users),") and bad higherPD (",len(list_bad_guys_higherPD),"): ", len(list(set(list_all_users)& set(list_bad_guys_higherPD))), float(len(list_bad_guys_higherPD))/len(list_all_users)*100.,"%"
print "intersection between All (",len(list_all_users),") and good SH (",len(list_good_guys_SH),"): ", len(list(set(list_all_users)& set(list_good_guys_SH))), float(len(list_good_guys_SH))/len(list_all_users)*100.,"%"
print "intersection between All (",len(list_all_users),") and good SD (",len(list_good_guys_SD),"): ", len(list(set(list_all_users)& set(list_good_guys_SD))), float(len(list_good_guys_SD))/len(list_all_users)*100.,"%"
print
print
print "intersection between good lowerHarmony (",len(list_good_guys_lowerHarmony),") and good higherHarmony (",len(list_good_guys_higherHarmony),"): ", len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_higherHarmony))), " (of a max of:", min([len(list_good_guys_lowerHarmony),len(list_good_guys_higherHarmony)]),")",float(len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_higherHarmony))))/ min([len(list_good_guys_lowerHarmony),len(list_good_guys_higherHarmony)])*100., "%"
print "intersection between good lowerHarmony (",len(list_good_guys_lowerHarmony),") and good PD (",len(list_good_guys_PD),"): ", len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_PD))), " (of a max of:", min([len(list_good_guys_lowerHarmony),len(list_good_guys_PD)]),")",float(len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_PD))))/ min([len(list_good_guys_lowerHarmony),len(list_good_guys_PD)])*100., "%"
print "intersection between good lowerHarmony (",len(list_good_guys_lowerHarmony),") and good SH (",len(list_good_guys_SH),"): ", len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_SH))), " (of a max of:", min([len(list_good_guys_lowerHarmony),len(list_good_guys_SH)]),")",float(len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_SH))))/ min([len(list_good_guys_lowerHarmony),len(list_good_guys_SH)])*100., "%"
print "intersection between good lowerHarmony (",len(list_good_guys_lowerHarmony),") and good SD (",len(list_good_guys_SD),"): ", len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_SD))), " (of a max of:", min([len(list_good_guys_lowerHarmony),len(list_good_guys_SD)]),")",float(len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_SD))))/ min([len(list_good_guys_lowerHarmony),len(list_good_guys_SD)])*100., "%"
print
print
print "intersection between good PD (",len(list_good_guys_PD),") and good SH (",len(list_good_guys_SH),"): ", len(list(set(list_good_guys_PD)& set(list_good_guys_SH))), " (of a max of:", min([len(list_good_guys_PD),len(list_good_guys_SH)]),")",float(len(list(set(list_good_guys_PD)& set(list_good_guys_SH))))/ min([len(list_good_guys_PD),len(list_good_guys_SH)])*100., "%"
print "intersection between good PD (",len(list_good_guys_PD),") and good SD (",len(list_good_guys_SD),"): ", len(list(set(list_good_guys_PD)& set(list_good_guys_SD))),float(len(list(set(list_good_guys_PD)& set(list_good_guys_SD))))/ min([len(list_good_guys_PD),len(list_good_guys_SD)])*100., "%"
print
print
print "intersection between good SH (",len(list_good_guys_SH),") and good SD (",len(list_good_guys_SD),"): ", len(list(set(list_good_guys_SH)& set(list_good_guys_SD))), " (of a max of:", min([len(list_good_guys_SD),len(list_good_guys_SH)]),")",float(len(list(set(list_good_guys_SH)& set(list_good_guys_SD))))/ min([len(list_good_guys_SH),len(list_good_guys_SD)])*100., "%"
print
print
##### dummies:
print "intersection between bad lower Harmony (",len(list_bad_guys_lowerHarmony),") and good higherPD (",len(list_good_guys_higherPD),"): ", len(list(set(list_good_guys_higherPD)& set(list_bad_guys_lowerHarmony))), " (of a max of:", min([len(list_bad_guys_lowerHarmony),len(list_good_guys_higherPD)]),")",float(len(list(set(list_bad_guys_lowerHarmony)& set(list_good_guys_higherPD))))/ min([len(list_bad_guys_lowerHarmony),len(list_good_guys_higherPD)])*100., "%"
print
print
print "intersection between good lower Harmony (",len(list_good_guys_lowerHarmony),") and good higherPD (",len(list_good_guys_higherPD),"): ", len(list(set(list_good_guys_higherPD)& set(list_good_guys_lowerHarmony))), " (of a max of:", min([len(list_good_guys_lowerHarmony),len(list_good_guys_higherPD)]),")",float(len(list(set(list_good_guys_lowerHarmony)& set(list_good_guys_higherPD))))/ min([len(list_good_guys_lowerHarmony),len(list_good_guys_higherPD)])*100., "%"
print
print
print "intersection between bad lower Harmony (",len(list_bad_guys_lowerHarmony),") and bad higherPD (",len(list_bad_guys_higherPD),"): ", len(list(set(list_bad_guys_higherPD)& set(list_bad_guys_lowerHarmony))), " (of a max of:", min([len(list_bad_guys_lowerHarmony),len(list_bad_guys_higherPD)]),")",float(len(list(set(list_bad_guys_lowerHarmony)& set(list_bad_guys_higherPD))))/ min([len(list_bad_guys_lowerHarmony),len(list_bad_guys_higherPD)])*100., "%"
print
######################################
######################################
######################################
if __name__ == '__main__':
# if len(sys.argv) > 1:
# graph_filename = sys.argv[1]
main()
#else:
# print "Usage: python script.py "