-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClassificationComparisonsTwitter.py
41 lines (31 loc) · 1.36 KB
/
ClassificationComparisonsTwitter.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
import numpy as np
def compare_classification(user_data, ml_data, ground_truths):
#user comparisons
userPerformance = np.array([])
for i in np.arange(len(user_data)):
if user_data[i] == ground_truths[i]:
userPerformance = np.append(userPerformance, 1)
else:
userPerformance = np.append(userPerformance, 0)
userAccuracy = np.count_nonzero(userPerformance == 1)/userPerformance.shape[0]
#ml comparisons
networkPerformance = np.array([])
for i in np.arange(len(ml_data)):
if ml_data[i] == ground_truths[i]:
networkPerformance = np.append(networkPerformance, 1)
else:
networkPerformance = np.append(userPerformance, 0)
networkAccuracy = np.count_nonzero(networkPerformance == 1)/networkPerformance.shape[0]
if networkAccuracy > userAccuracy:
diff = 100*(networkAccuracy-userAccuracy)
diff = str(diff)
string = "The neural network beat you by " + diff + "%."
return string
elif networkAccuracy == userAccuracy:
string = "You tied with the neural network."
return string
elif networkAccuracy < userAccuracy:
diff = 100*(userAccuracy-networkAccuracy)
diff = str(diff)
string = "You beat the neural network by " + diff + "%."
return string