-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapply_man_whitney.py
71 lines (55 loc) · 1.74 KB
/
apply_man_whitney.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
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
def manWhitney(dpp, nondpp):
A = np.array(dpp)
B = np.array(nondpp)
result=stats.mannwhitneyu(A, B, alternative='two-sided')
print('p-value:',result)
return
class MakeData:
dpp = []
nondpp = []
index = 0
def __init__(self, dpp_list):
dpp_list = dpp_list
def makeData(self,mode,dpptype,index,dpp_list):
for line in dpp_list:
project = line.split(",")
if mode == 0:
if project[1].find("no") >= 0:
self.nondpp.append(float(project[index]))#ver:5,tag:6,arch:7
else:
self.dpp.append(float(project[index]))
else :
self.nondpp.append(float(project[dpptype]))
self.dpp.append(float(project[dpptype + 1]))
def getDppData(self):
return self.dpp
def getNondppData(self):
return self.nondpp
def make_plot(input_file):
dpp_list = open(input_file, 'r')
verdata = MakeData(dpp_list)
verdata.makeData(1,1,3,dpp_list)
nondppver = verdata.getNondppData()
dppver = verdata.getDppData()
print(dppver)
print(nondppver)
manWhitney(dppver,nondppver)
points = [dppver, nondppver]
fig, ax = plt.subplots()
bp = ax.boxplot(points)
#ax.set_xticklabels(['DPP', 'nonDPP'])
ax.set_xticklabels(['DPP', 'nonDPP'])
plt.ylabel('Number of commits')
plt.grid()
plt.savefig('esem-figure/rq1-commits-metrics.pdf')
plt.show()
def main():
make_plot('RQ1-all-dpp-metrics.csv',)
#rq1:RQ1-all-dpp-metrics.csv
#rq3:RQ3-before-after-commit-incDfile.csv
#RQ4-limited-project.csv
if __name__ == "__main__":
main()