-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScoring.py
More file actions
342 lines (276 loc) · 10.3 KB
/
Scoring.py
File metadata and controls
342 lines (276 loc) · 10.3 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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
from ScoreHelpers import *
import time
def score_evaluation_5_evolution(matrix, mentors, mentees, person_dict, list):
reward_similar_text(matrix, mentors, mentees)
# reward_similar_text(matrix, mentors, mentees, list[0])
matrix = reward_same_industry(matrix, mentors, mentees, list[0])
matrix = reward_priorities(matrix, mentors, mentees, list[1])
matrix = reward_high_lix(matrix, mentors, mentees, list[2])
matrix = reward_clustered_mentors(matrix, mentors, mentees, person_dict, list[3])
matrix = punish_short_mentee_profile(matrix, mentors, mentees, list[4])
matrix = punish_lack_of_linkedin(matrix, mentors, mentees, list[5])
return matrix
def pairwise(iterable):
'''
:param iterable:
:return:
'''
"s -> (s0, s1), (s2, s3), (s4, s5), ..."
a = iter(iterable)
return zip(a, a)
class IScoring:
'''
Interface for creating scoring functions.
'''
def __init__(self, mentors, mentees, person_dict=None):
self.mentors = mentors
self.mentees = mentees
self.assignment_matrix = [[len(self.mentors)*2] * len(self.mentees) for i in range(len(self.mentors))]
self.person_dict = person_dict
self.arg_dict = {}
def calculate_score(self):
pass
def _calculate_score(self, *args):
'''
Receives a number of functions and calculates the final score.
:param args: function, score. E.g. reward_xxx, 200, reward_yyy, 100 etc
:return:
'''
self.set_args(args=args)
print("function_name;time_from_start")
start_time = time.time()
for function, score in pairwise(args):
# If we don't want to set the score, ignore it and default to method value
if score is None:
self.assignment_matrix = function(matrix=self.assignment_matrix,
mentors=self.mentors,
mentees=self.mentees,
person_dict=self.person_dict)
else:
self.assignment_matrix = function(matrix=self.assignment_matrix,
mentors=self.mentors,
mentees=self.mentees,
score=score,
person_dict=self.person_dict)
print("{};{}".format(function.__name__, time.time() - start_time))
def set_args(self, args):
arg_dict = {}
for function, score in pairwise(args):
arg_dict[function.__name__] = score
self.arg_dict = arg_dict
'''Scorefunction 1: 46%
(243) matching_result_20201220_21_26_22.csv
rating_20201220_21_26_49.csv
'''
class ScoreFunction5(IScoring):
'''
Only takes priorities into account
'''
def calculate_score(self):
self._calculate_score(
reward_priorities, 150
)
return self.assignment_matrix
'''
Scorefunction 2:
(244) matching_result_20201220_22_05_24.csv
'''
class ScoreFunction6(IScoring):
'''
Take industry and priorities
into account
'''
def calculate_score(self):
self._calculate_score(
reward_priorities, 150,
reward_same_industry, 50
)
return self.assignment_matrix
class ScoreFunction7(IScoring):
'''
Take industry, priorities,
short mentee profiles, lack of linkedin profile, lix
into account
'''
def calculate_score(self):
self._calculate_score(
reward_priorities, 150,
reward_same_industry, 50,
punish_short_mentee_profile, 100,
)
return self.assignment_matrix
class ScoreFunction8(IScoring):
def calculate_score(self):
self._calculate_score(
reward_priorities, 150,
reward_same_industry, 50,
punish_short_mentee_profile, 100,
punish_lack_of_linkedin, 30,
reward_female_gender, 30,
reward_similar_text, 20,
reward_clustered_mentors, 20
)
return self.assignment_matrix
# reward_generalist_or_specialist
class ScoreFunction9(IScoring):
def calculate_score(self):
self._calculate_score(
reward_same_industry, 50,
reward_priorities, 100,
punish_short_mentee_profile, 50,
reward_potential_priorities_mentee, 50
)
return self.assignment_matrix
class ScoreFunction10(IScoring):
''' They is an upper limitation to what priorities can do. '''
def calculate_score(self):
self._calculate_score(
reward_same_industry, 50,
reward_priorities, 100,
punish_short_mentee_profile, 50,
punish_lack_of_linkedin, 20,
reward_potential_priorities_mentee, 50,
reward_potential_priorities_mentor, 40,
punish_bachelor_mentees, 20,
reward_female_gender, 20,
)
return self.assignment_matrix
# 63 %
class ScoreFunction11(IScoring):
''' They is an upper limitation to what priorities can do. '''
def calculate_score(self):
self._calculate_score(
reward_same_industry, 50,
reward_priorities, 150,
punish_short_mentee_profile, 50,
punish_lack_of_linkedin, 20,
reward_potential_priorities_mentee, 50,
reward_potential_priorities_mentor, 40,
reward_potential_priorities_mentee_factor_refactored, 20,
reward_potential_priorities_mentor_factor_refactored, 20,
punish_bachelor_mentees, 20,
reward_female_gender, 10,
punish_missing_linkedin_picture, 10
)
return self.assignment_matrix
class ScoreFunction12(IScoring):
''' They is an upper limitation to what priorities can do. '''
def calculate_score(self):
self._calculate_score(
reward_same_industry, 50,
reward_priorities, 150,
punish_short_mentee_profile, 50,
punish_lack_of_linkedin, 20,
reward_potential_priorities_mentee, 50,
reward_potential_priorities_mentor, 40,
reward_potential_priorities_mentee_factor_refactored, 20,
reward_potential_priorities_mentor_factor_refactored, 20,
punish_bachelor_mentees, 20,
reward_female_gender, 10,
punish_missing_linkedin_picture, 10,
reward_similarity_keywords_to_texts_new, 20
)
return self.assignment_matrix
''' We still need to utilize:
- Reward potential priorities mentors
- Reward potential mentees and mentors refactored
- Reward potential mentees and mentors factor refactored
- LSH
- GloVe (similarity keywords to text) '''
# 80% - top so far
class ScoreFunction13(IScoring):
def calculate_score(self):
self._calculate_score(
#reward_similar_text, 0,
reward_same_industry, 50,
reward_priorities, 110,
#reward_clustered_mentors, 10,
punish_short_mentee_profile, 50,
punish_lack_of_linkedin, 20,
reward_potential_priorities_mentee, 60,
reward_potential_priorities_mentor, 50,
punish_bachelor_mentees, 20,
reward_female_gender, 20,
punish_missing_linkedin_picture,20,
reward_similarity_keywords_to_texts, 20
)
return self.assignment_matrix
class ScoreFunction14(IScoring):
def calculate_score(self):
self._calculate_score(
reward_same_industry, 50,
reward_priorities, 130,
punish_short_mentee_profile, 50,
punish_lack_of_linkedin, 20,
reward_potential_priorities_mentee, 60,
reward_potential_priorities_mentor, 50,
punish_bachelor_mentees, 20,
reward_female_gender, 20,
punish_missing_linkedin_picture,20,
reward_similarity_keywords_to_texts_new, 30
)
return self.assignment_matrix
class ScoreFunction15(IScoring):
def calculate_score(self):
self._calculate_score(
reward_same_industry, 50,
reward_priorities, 130,
punish_short_mentee_profile, 50,
punish_lack_of_linkedin, 20,
reward_potential_priorities_mentee_lsh, 60,
reward_potential_priorities_mentor_lsh, 50,
punish_bachelor_mentees, 20,
reward_female_gender, 20,
punish_missing_linkedin_picture, 20,
reward_similarity_keywords_to_texts_new, 30
)
return self.assignment_matrix
class ScoreFunction30(IScoring):
def calculate_score(self):
self._calculate_score(
reward_potential_priorities_mentee_lsh, 10,
reward_potential_priorities_mentor_lsh, 10
)
return self.assignment_matrix
class ScoreFunction2(IScoring):
def calculate_score(self):
self._calculate_score(
generate_random_score,0
)
return self.assignment_matrix
class ScoreFunction20(IScoring):
def calculate_score(self):
self._calculate_score(
reward_potential_priorities_mentee_lsh, 10
)
return self.assignment_matrix
class ScoreFunction21(IScoring):
def calculate_score(self):
self._calculate_score(
reward_potential_priorities_mentee_lsh, 10
)
return self.assignment_matrix
class ScoreFunctionTime(IScoring):
def calculate_score(self):
self._calculate_score(
reward_priorities,0,
reward_same_industry,0,
punish_short_mentee_profile,0,
punish_lack_of_linkedin,0,
reward_female_gender,0,
reward_potential_priorities_mentee,0,
reward_potential_priorities_mentor,0,
punish_bachelor_mentees, 0,
punish_missing_linkedin_picture,0,
reward_similarity_keywords_to_texts_new,0,
reward_similar_text,0,
reward_clustered_mentors,0,
)
return self.assignment_matrix
class ScoreFunction0(IScoring):
def calculate_score(self):
self._calculate_score(
reward_same_industry, 150,
reward_similarity_keywords_to_texts_new, 10,
)
return self.assignment_matrix