Commit
•
e1e9768
1
Parent(s):
08fd9fc
Create functions.py
Browse files- functions.py +20 -0
functions.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
|
3 |
+
# Used to test if all the listed attributes of all team members and applicants are the same
|
4 |
+
def all_equal(attribute_list):
|
5 |
+
return len(set(attribute_list)) == 1
|
6 |
+
|
7 |
+
# I decided to treat all attributes as independent from eachother, since large negative covariances between attributes made the cdf go to 0 very quickly
|
8 |
+
def make_independent(cov_matrix):
|
9 |
+
dim = len(cov_matrix)
|
10 |
+
for i in range(dim):
|
11 |
+
for j in range(dim):
|
12 |
+
if not i==j:
|
13 |
+
cov_matrix[i,j] = 0
|
14 |
+
return cov_matrix
|
15 |
+
|
16 |
+
# Define compatibility as the geometric mean of the probabilities for each attribute that a person on the team will have a lower value
|
17 |
+
def compatibility(model, attributes, candidate_dict):
|
18 |
+
num_attributes = len(attributes)
|
19 |
+
candidate_values = [candidate_dict[attribute] for attribute in attributes]
|
20 |
+
return model.cdf(np.array(candidate_values))**(1/num_attributes)
|