-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomp.py
130 lines (99 loc) · 3.9 KB
/
comp.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
120
121
122
123
124
125
126
127
128
129
130
"""
This script calculates the difference between no of detected FPs in Manual and AMAP-APP results.
It is not used in the application.
"""
# Python Imports
import glob
# Libary Imports
import os
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import numpy as np
# Local Imports
manual_path = "/home/arash/Desktop/UoC-AMAP/publication/nat_met_data/manual/results/"
amap_path = "/home/arash/Desktop/UoC-AMAP/publication/nat_met_data/AMAP/results_dl/"
app_path = "/home/arash/Desktop/UoC-AMAP/publication/nat_met_data/AMAP-APP/"
manual_list = glob.glob(manual_path + '/**/*', recursive=True)
amap_list = glob.glob(amap_path + '/**/*', recursive=True)
app_list = glob.glob(app_path + '/**/*', recursive=True)
manual_list = [x for x in manual_list if x.endswith(".xls")]
amap_list = [x for x in amap_list if x.endswith(".xls")]
app_list = [x for x in app_list if (x.endswith(".csv") and ("all_params" not in x) and ("SD_length_grid_index" not in x))]
manual_dict = {os.path.splitext(os.path.basename(x))[0].rstrip("_overview_Results_FP_analysis").lower(): x for x in manual_list}
amap_dict = {os.path.splitext(os.path.basename(x))[0].rstrip("_Results_FP_analysis").lower(): x for x in amap_list}
app_dict = {os.path.splitext(os.path.basename(x))[0].rstrip("_fp_params").lower(): x for x in app_list}
print("Missing in APP")
for item in manual_dict:
if item not in app_dict.keys():
print(item)
print("Missing in Manual")
for item in app_dict:
if item not in manual_dict.keys():
print(item)
print("----------------")
app_no_list = list()
ama_no_list = list()
for key in app_dict.keys():
print(key)
manual_fp = pd.read_csv(manual_dict[key])
auto_fp = pd.read_csv(app_dict[key])
amap_fp = pd.read_csv(amap_dict[key])
print("Manual FP: ", manual_fp.shape[0])
print("APP FP: ", auto_fp.shape[0])
print("AMAP FP: ", amap_fp.shape[0])
app_no_list.append(auto_fp.shape[0])
ama_no_list.append(amap_fp.shape[0])
no_correlation, no_p_value = stats.pearsonr(app_no_list,
ama_no_list)
print("Correlation coefficient:", no_correlation)
print("p-value:", no_p_value)
app_data = np.array(app_no_list)
ama_data = np.array(ama_no_list)
diff = app_data - ama_data
ratio = diff / ama_data
mean_diff = np.mean(ratio)
std_diff = np.std(ratio)
print("Mean difference:", mean_diff)
print("STD difference:", std_diff)
x = np.arange(len(app_data))
# Width of the bars
width = 0.35
# Create bar chart
fig, ax = plt.subplots()
bars1 = ax.bar(x - width/2, app_data, width, label='AMAP-APP', color='blue')
bars2 = ax.bar(x + width/2, ama_data, width, label='AMAP', color='red')
# Add labels and legend
ax.set_xlabel('Data Point Index')
ax.set_ylabel('No of FPs')
ax.set_title('AMAP-APP vs AMAP')
ax.set_xticks([])
ax.legend()
# Show plot
plt.savefig('amap-vs-app-FPs-BarChart.png', bbox_inches='tight', dpi=300)
# Calculate absolute difference between corresponding elements
abs_diff = np.abs(np.array(ama_data) - np.array(app_data))
ratio_diff = abs_diff / ama_data
# Calculate percentiles
percentiles = np.percentile(ratio_diff, [0, 25, 50, 75, 100])
plt.plot(range(len(ratio_diff)),
ratio_diff, 'o', color='blue', alpha=0.3, label='_nolegend_')
# Mark percentiles with vertical lines
for percentile in percentiles:
plt.axhline(y=percentile, color='red', linestyle='--')
# Add labels and title
plt.xlabel('Data Point Index')
plt.ylabel('Ratio of Absolute Difference to AMAP')
plt.title('Percentiles of Ratio of Absolute Difference')
plt.savefig('amap-vs-app-FPs-Percentile.png', bbox_inches='tight', dpi=300)
# Create a box plot of the ratio
plt.figure(figsize=(4, 6))
plt.boxplot(ratio_diff)
# Remove x-axis values
plt.xticks([])
# Add labels and title
plt.xlabel('')
plt.ylabel('Ratio of Absolute Difference')
plt.title('Ratio of Absolute Difference to AMAP')
# Show plot
plt.savefig('amap-vs-app-FPs-BoxPlot.png', bbox_inches='tight', dpi=300)