-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_avg_pos_prefixes.py
240 lines (186 loc) · 7.42 KB
/
plot_avg_pos_prefixes.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import pandas as pd
import numpy as np
import os
from statistics import mode
from statistics import mean
from statistics import median
from scipy.stats.stats import spearmanr
import csv
from math import isnan
path_dir = "/Users/stephanf/Dropbox/Dokumente/Masterstudium/Masterthesis/NonMyopicOutput"
data_1 = pd.read_csv(os.path.join(path_dir, "results_traffic_fines_1_opt_threshold.csv"), delimiter=";")
data_2 = pd.read_csv(os.path.join(path_dir, "results_traffic_fines_1_2prefixes_threshold.csv"), delimiter=";")
data_3 = pd.read_csv(os.path.join(path_dir, "results_traffic_fines_1_3prefixes_threshold.csv"), delimiter=";")
print("loaded all traffic_fines as pandas data frames")
data_5_cost = data_1.loc[data_1['metric'] == "cost_avg"]
data_6_cost = data_2.loc[data_2['metric'] == "cost_avg"]
data_7_cost = data_3.loc[data_3['metric'] == "cost_avg"]
del data_1
del data_2
del data_3
data_5_cost['cost_avg_6'] = data_6_cost['value']
data_5_cost['cost_avg_7'] = data_7_cost['value']
del data_6_cost
del data_7_cost
print("filtered all pandas data frames")
positions5 = []
positions6 = []
positions7 = []
positions8 = []
positions9 = []
for row in data_5_cost.itertuples():
if row.early_type == "linear":
values = []
values.append(row.value)
values.append(row.cost_avg_6)
values.append(row.cost_avg_7)
correlValues = values
values = sorted(values)
positions5.append(values.index(row.value)+1)
positions6.append(values.index(row.cost_avg_6)+1)
positions7.append(values.index(row.cost_avg_7)+1)
print("1 Prefix")
print("mean: " + str(mean(positions5)))
print("mode: " + str(mode(positions5)))
print("median: " + str(median(positions5)))
print("avg_cost:" + str(mean(data_5_cost['value'])))
print("2 Prefixes")
print("mean: " + str(mean(positions6)))
print("mode: " + str(mode(positions6)))
print("median: " + str(median(positions6)))
print("avg_cost:" + str(mean(data_5_cost['cost_avg_6'])))
print("3 Prefixes")
print("mean: " + str(mean(positions7)))
print("mode: " + str(mode(positions7)))
print("median: " + str(median(positions7)))
print("avg_cost:" + str(mean(data_5_cost['cost_avg_7'])))
fileName = "/Users/stephanf/Dropbox/Dokumente/Masterstudium/Masterthesis/testresults/NonMyopicRanking/test_trafficfines.csv"
with open(fileName, 'w', newline='') as csvResultFile:
csvWriter = csv.writer(csvResultFile, delimiter=';', quoting=csv.QUOTE_NONE)
printRow = []
printRow.append("dataset")
printRow.append("c_action")
printRow.append("c_miss")
printRow.append("c_com")
printRow.append("early_type")
printRow.append("value")
csvWriter.writerow(printRow)
for row in data_5_cost.itertuples():
printRow = []
printRow.append(row.dataset)
printRow.append(row.c_action)
printRow.append(row.c_miss)
printRow.append(row.c_com)
printRow.append(row.early_type)
HitRatios = []
HitRatios.append(1)
HitRatios.append(2)
HitRatios.append(3)
values = []
values.append(row.value*-1)
values.append(row.cost_avg_6*-1)
values.append(row.cost_avg_7*-1)
correlValues = values
test = spearmanr(HitRatios, values)
if row.value == row.cost_avg_6 and row.value == row.cost_avg_7:
printRow.append(0.0)
else:
printRow.append(test.correlation)
csvWriter.writerow(printRow)
# print(str(test.correlation))
data_1 = pd.read_csv(os.path.join(path_dir, "results_bpic2017_cancelled_opt_threshold.csv"), delimiter=";")
data_2 = pd.read_csv(os.path.join(path_dir, "results_bpic2017_cancelled_2prefixes_threshold.csv"), delimiter=";")
data_3 = pd.read_csv(os.path.join(path_dir, "results_bpic2017_cancelled_3prefixes_threshold.csv"), delimiter=";")
print("loaded all bpic2017_cancelled as pandas data frames")
data_5_cost = data_1.loc[data_1['metric'] == "cost_avg"]
data_6_cost = data_2.loc[data_2['metric'] == "cost_avg"]
data_7_cost = data_3.loc[data_3['metric'] == "cost_avg"]
del data_1
del data_2
del data_3
data_5_cost['cost_avg_6'] = data_6_cost['value']
data_5_cost['cost_avg_7'] = data_7_cost['value']
del data_6_cost
del data_7_cost
fileName = "/Users/stephanf/Dropbox/Dokumente/Masterstudium/Masterthesis/testresults/NonMyopicRanking/test_bpic2017_cancelled.csv"
with open(fileName, 'w', newline='') as csvResultFile:
csvWriter = csv.writer(csvResultFile, delimiter=';', quoting=csv.QUOTE_NONE)
printRow = []
printRow.append("dataset")
printRow.append("c_action")
printRow.append("c_miss")
printRow.append("c_com")
printRow.append("early_type")
printRow.append("value")
csvWriter.writerow(printRow)
for row in data_5_cost.itertuples():
printRow = []
printRow.append(row.dataset)
printRow.append(row.c_action)
printRow.append(row.c_miss)
printRow.append(row.c_com)
printRow.append(row.early_type)
HitRatios = []
HitRatios.append(1)
HitRatios.append(2)
HitRatios.append(3)
values = []
values.append(row.value*-1)
values.append(row.cost_avg_6*-1)
values.append(row.cost_avg_7*-1)
correlValues = values
test = spearmanr(HitRatios, values)
if row.value == row.cost_avg_6 and row.value == row.cost_avg_7:
printRow.append(0.0)
else:
printRow.append(test.correlation)
csvWriter.writerow(printRow)
print(str(test.correlation))
data_1 = pd.read_csv(os.path.join(path_dir, "results_bpic2017_refused_opt_threshold.csv"), delimiter=";")
data_2 = pd.read_csv(os.path.join(path_dir, "results_bpic2017_refused_2prefixes_threshold.csv"), delimiter=";")
data_3 = pd.read_csv(os.path.join(path_dir, "results_bpic2017_refused_3prefixes_threshold.csv"), delimiter=";")
print("loaded all bpic2017_refused as pandas data frames")
data_5_cost = data_1.loc[data_1['metric'] == "cost_avg"]
data_6_cost = data_2.loc[data_2['metric'] == "cost_avg"]
data_7_cost = data_3.loc[data_3['metric'] == "cost_avg"]
del data_1
del data_2
del data_3
data_5_cost['cost_avg_6'] = data_6_cost['value']
data_5_cost['cost_avg_7'] = data_7_cost['value']
del data_6_cost
del data_7_cost
fileName = "/Users/stephanf/Dropbox/Dokumente/Masterstudium/Masterthesis/testresults/NonMyopicRanking/test_bpic2017_refused.csv"
with open(fileName, 'w', newline='') as csvResultFile:
csvWriter = csv.writer(csvResultFile, delimiter=';', quoting=csv.QUOTE_NONE)
printRow = []
printRow.append("dataset")
printRow.append("c_action")
printRow.append("c_miss")
printRow.append("c_com")
printRow.append("early_type")
printRow.append("value")
csvWriter.writerow(printRow)
for row in data_5_cost.itertuples():
printRow = []
printRow.append(row.dataset)
printRow.append(row.c_action)
printRow.append(row.c_miss)
printRow.append(row.c_com)
printRow.append(row.early_type)
HitRatios = []
HitRatios.append(1)
HitRatios.append(2)
HitRatios.append(3)
values = []
values.append(row.value*-1)
values.append(row.cost_avg_6*-1)
values.append(row.cost_avg_7*-1)
correlValues = values
test = spearmanr(HitRatios, values)
if row.value == row.cost_avg_6 and row.value == row.cost_avg_7:
printRow.append(0.0)
else:
printRow.append(test.correlation)
csvWriter.writerow(printRow)
# print(str(test.correlation))