-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhard_vote.py
More file actions
62 lines (37 loc) · 1.32 KB
/
hard_vote.py
File metadata and controls
62 lines (37 loc) · 1.32 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
import learner_functions as lf
import load_data as ld
def hard_vote(models, data, labels, type):
modelVotes = list()
counter = 0
for model in models:
votes = lf.make_test_prediction(model, data, labels, False)
modelVotes.append(votes.tolist())
counter += 1
finalVotes = list()
if type == 'gender':
for index in range(80):
femaleCount = 0
maleCount = 0
for modelVoteArray in modelVotes:
if modelVoteArray[index] == 'Female':
femaleCount += 1
elif modelVoteArray[index] == 'Male':
maleCount += 1
if femaleCount > maleCount:
finalVotes.append('Female')
else:
finalVotes.append('Male')
if type == 'msi':
for index in range(80):
msiHighCount = 0
msiLowCount = 0
for modelVoteArray in modelVotes:
if modelVoteArray[index] == 'MSI-High':
msiHighCount += 1
elif modelVoteArray[index] == 'MSI-Low/MSS':
msiLowCount += 1
if msiHighCount > msiLowCount:
finalVotes.append('MSI-High')
else:
finalVotes.append('MSI-Low/MSS')
return finalVotes