-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactionSequence.py
120 lines (92 loc) · 4.09 KB
/
actionSequence.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
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
from Markov import MarkovChainAll
from utils import configFilePath, startToSimilarMatrix2
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns
import scipy.stats as stats
from utils import matrixCorr
def googleMatrix():
return np.array(
[[854000,35100,494000,30100,17700,12100],
[54400,1660000,4010000,44800,28100,409000],
[897000,131000,15000000,166000,27800,111000],
[337000,399000,1050000,57100000,1090000,2160000],
[126000,144000,76400,11000000,16700000,3070000],
[75700,170000,450000,1290000,481000,18400000]])
if __name__ == "__main__":
totalParticipant = 24
txtFileFolder = configFilePath("FOLDER","responseFileFolder")
theAnswer = MarkovChainAll(totalParticipant, txtFileFolder)
dropOut = {3,14,24}
def subSequenceCorrPlot():
recordS = []
for participant in range(1, totalParticipant + 1):
if participant in dropOut:
continue
ma = getattr(theAnswer, "p" + str(participant)).sact.MarkovMatrix
sub = startToSimilarMatrix2(participant, "a", totalParticipant)
recordS.append(matrixCorr(ma, sub)[0])
# print(record)
# plt.bar(range(totalParticipant), record)
plt.hist(recordS, bins = 10, ec = "black", alpha = 0.5, label = "slow")
recordF = []
for participant in range(1, totalParticipant + 1):
if participant in dropOut:
continue
ma = getattr(theAnswer, "p" + str(participant)).fact.MarkovMatrix
sub = startToSimilarMatrix2(participant, "a", totalParticipant)
recordF.append(matrixCorr(ma, sub)[0])
# print(record)
# plt.bar(range(totalParticipant), record)
plt.hist(recordF, bins = 10, ec = "black", alpha = 0.5, label = "fast")
plt.legend(loc='upper right')
plt.title('Subjective and Markov Matrix Correlation Distribution')
plt.show()
# res = stats.wilcoxon(recordS, recordF)
# print(res)
accuracy = sum(i < j for i, j in zip(recordS, recordF)) / len(recordS)
print(accuracy)
def googleSequenceCorrPlot():
recordS = []
google = googleMatrix()
for participant in range(1, totalParticipant + 1):
if participant in dropOut:
continue
ma = getattr(theAnswer, "p" + str(participant)).sact.MarkovMatrix
recordS.append(matrixCorr(ma, google)[0])
# print(record)
# plt.bar(range(totalParticipant), record)
plt.hist(recordS, bins = 10, ec = "black", alpha = 0.5, label = "slow")
recordF = []
google = googleMatrix()
for participant in range(1, totalParticipant + 1):
if participant in dropOut:
continue
ma = getattr(theAnswer, "p" + str(participant)).fact.MarkovMatrix
recordF.append(matrixCorr(ma, google)[0])
# print(record)
# plt.bar(range(totalParticipant), record)
plt.hist(recordF, bins = 10, ec = "black", alpha = 0.5, label = "fast")
plt.legend(loc='upper right')
plt.title('Google and Markov Matrix Correlation Distribution')
plt.show()
# res = stats.wilcoxon(recordS, recordF)
# print(res)
accuracy = sum(i < j for i, j in zip(recordS, recordF)) / len(recordS)
print(accuracy)
def subGoogleCorrPlot():
subAndGoogle = []
for participantNumber in range(1,totalParticipant+1):
matrix1 = startToSimilarMatrix2(participantNumber, "a", totalParticipant)
matrix2 = googleMatrix()
subAndGoogle.append(matrixCorr(matrix1, matrix2)[0])
plt.hist(subAndGoogle, bins = 10, ec = "black", alpha = 0.5, label = "subAndGoogle")
plt.title('Google and Subjective Similarity Matrix Correlation Distribution')
plt.show()
# subSequenceCorrPlot()
# WilcoxonResult(statistic=40.0, pvalue=0.0009626150131225586)
# accuracy: 0.83333
# googleSequenceCorrPlot()
#WilcoxonResult(statistic=34.0, pvalue=0.0004298686981201172)
#accuracy: 0.83333
subGoogleCorrPlot()