-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculateTtest.py
40 lines (32 loc) · 1.38 KB
/
calculateTtest.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
__author__ = 'Umberto'
from baseline import baseline
from unionOfClassifiers import runMethod2
from SVMScript import runMethod1
predictionsFromBaseline = baseline()
predictionsFromMethod2 = runMethod2()
predictionsFromMethod1 = runMethod1()
#flatten predictions
predictionsFromBaseline = [val for sublist in predictionsFromBaseline for val in sublist]
predictionsFromMethod2 = [val for sublist in predictionsFromMethod2 for val in sublist]
predictionsFromMethod1 = [val for sublist in predictionsFromMethod1 for val in sublist]
from scipy import stats
if(len(predictionsFromBaseline) != len(predictionsFromMethod2)):
print('Error predictions from method 2 have different lengths!')
else:
r1 = stats.ttest_ind(predictionsFromBaseline, predictionsFromMethod2)
print(r1)
r2 = stats.ttest_ind(predictionsFromBaseline, predictionsFromMethod2, equal_var = False)
print(r2)
#
# (8.6566243900008022, 8.3173929492649013e-18)
# (8.6566243900008022, 1.2765689781551307e-17)
if(len(predictionsFromBaseline) != len(predictionsFromMethod1)):
print('Error predictions from method 1 have different lengths!')
else:
r1 = stats.ttest_ind(predictionsFromBaseline, predictionsFromMethod1)
print(r1)
r2 = stats.ttest_ind(predictionsFromBaseline, predictionsFromMethod1, equal_var = False)
print(r2)
#
# (0.38934989764282057, 0.6970488281708882)
# (0.38934989764282057, 0.69704943709052203)