-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateData.py
81 lines (70 loc) · 2.43 KB
/
generateData.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
# interests: [
# { name: 'Creative Writing', emoji: '🖊️'},
# { name: 'Math', emoji: '➕'},
# { name: 'Teaching', emoji: '🏫'},
# { name: 'Making Friends', emoji: '🎎'},
# { name: 'Statistical Analysis', emoji: '📊'},
# { name: 'ML/AI', emoji: '🤖'},
# { name: 'Video Editing', emoji: '📹'},
# { name: 'Scrum/Agile', emoji: '🔄'},
# { name: 'Persuasion', emoji: '💬},
# { name: 'Coding', emoji: '💻'},
# { name: 'Database/SQL', emoji: '📋'},
# { name: 'Listening', emoji: '👂'},
# { name: 'Technical Writing', emoji: '📚'},
# { name: 'Troubleshooting', emoji: '💡'},
# { name: 'Negotiation', emoji: '🤝'},
# ]
import random
import numpy as np
import math
cT = [0, 0, 1, 0, 0, 7, 1, 0, 5, 5, 0, 4, 2, 10, 5, 6, 8, 3, 3]
bT = [0, 0, 0, 1, 3, 5, 6, 9, 4, 0, 0, 9, 7, 0, 0, 9, 2, 4, 10]
def randomWeight(tmp):
rand = np.random.normal(0, 0.2)
tmp = round(tmp * (rand + 1), 2)
if (tmp > 10):
tmp = 10
if (tmp < 0):
tmp = 0
return tmp
def generate(typed, num):
coders = []
for x in range(num):
coders.append(typed.copy())
for y in range(15):
# generate skills
tmp = coders[x][y+4] + .5
coders[x][y+4] = randomWeight(tmp)
# generate interests
tmp = 10 - coders[x][y+4]
coders[x].append(randomWeight(tmp))
return coders
def makeString(liste):
return '\n'.join(str(e) for e in liste)
def matches(liste):
labels = []
matches = []
for x in liste:
for y in liste:
if x != y:
diff1 = 0
diff2 = 0
# for z in range(2):
# diff1 += 1 - math.sqrt((x[z+4] - y[z+6]) ** 2) / 10
# diff2 += 1 - math.sqrt((y[z+4] - x[z+6]) ** 2) / 10
for z in range(15):
diff1 += 1 - math.sqrt((x[z+4] - y[z+19]) ** 2) / 10
diff2 += 1 - math.sqrt((y[z+4] - x[z+19]) ** 2) / 10
diff = (diff1 + diff2) / 30
matches.append(x + y)
labels.append(round(diff, 2))
return (matches, labels)
with open("matches.out", 'w') as out, open("labels.out", 'w') as out2:
random.seed(42)
coders = generate(cT, 80)
bizppl = generate(bT, 80)
allP = coders + bizppl
finalD = matches(allP)
out.write(makeString(finalD[0]))
out2.write(makeString(finalD[1]))