4 Copyright (c) 2016, Braun Kai, Gehrung Joachim, Heizmann Heinrich, Meissner Pascal 7 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 13 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 import matplotlib.pyplot
as plt
23 thresholdForValueIncreasing = 0.1
24 thresholdForValueIncreasingStandalone = 0.001
25 thresholdForValueIncreasingStandaloneLog = 0.00001
30 colors = [
'Salmon',
'Khaki',
'GreenYellow',
'Aquamarine',
'Thistle',
'Moccasin']
36 samplesPerKernel = 100
44 for samples
in range(1, maxSamples + 1):
45 for sceneobjects
in range(0, maxSceneobjects):
46 experiment = str(samples * samplesPerKernel) +
'_' + str(sceneobjects).zfill(2)
47 pathExperimentCsv = pathToCsv +
'/' + experiment +
'/' + experiment +
'.csv' 50 numberOfTurns = sum(1
for row
in csv.reader(open(pathExperimentCsv,
'rb'), delimiter=
','))
53 numberOfTurns /= (sceneobjects + 1)
54 print 'Evaluating experiment ' + experiment +
'. Number of turns is ' + str(numberOfTurns) +
'.' 56 print 'Evaluating experiment ' + experiment +
'.' 59 with open(pathExperimentCsv,
'rb')
as csvfile:
60 reader = csv.reader(csvfile, delimiter=
',')
67 for turn
in range(0, numberOfTurns - 1):
71 for i
in range(0, sceneobjects):
72 turnScore += float(reader.next()[1])
73 turnScore /= (sceneobjects + 1)
75 turnScore += float(reader.next()[6])
77 score.append(turnScore)
82 psmScore.append(np.array(score[6:]).mean())
84 psmScore.append(np.array(score).mean())
92 for samples
in range(1, maxSamples + 1):
93 yLabels.append(samples * samplesPerKernel)
96 data = np.zeros((maxSceneobjects, maxSamples))
97 labels = np.zeros((maxSamples, maxSceneobjects))
98 for x
in range(0, maxSamples):
99 for y
in range(0, maxSceneobjects):
100 value = psmScore[x * (maxSceneobjects) + y]
117 y_pos = np.arange(len(yLabels))
120 fig = plt.figure(figsize=(10,4))
121 ax = fig.add_subplot(111)
125 left = np.zeros(len(yLabels))
126 for i, d
in enumerate(data):
127 patch_handles.append(ax.barh(y_pos, d, color=colors[i % len(colors)], align=
'center', label=
'%i' % (i + 1), left=left))
131 for j
in xrange(len(patch_handles)):
132 for i, patch
in enumerate(patch_handles[j].get_children()):
136 x = 0.5 * patch.get_width() + bl[0] + textoffsetX
137 y = 0.5 * patch.get_height() + bl[1] + textoffsetY
141 if labels[i,j] > 110:
142 ax.text(x,y,
"%10.2f" % (labels[i,j]), ha=
'center', fontweight=
'bold', fontsize=15)
144 if labels[i,j] > 1.5:
145 ax.text(x,y,
"%10.2f" % (labels[i,j]), ha=
'center', fontweight=
'bold', fontsize=15)
149 ax.set_yticklabels(yLabels)
153 ax.set_xlabel(
'Laufzeit in Millisekunden', fontweight=
'bold')
154 ax.set_ylabel(
'Datenpunkte pro Trajektorie', fontweight=
'bold')
157 ax.legend(loc=
'upper center', bbox_to_anchor=(0.5, 1.08), ncol=6, fancybox=
True, shadow=
True)
161 plt.savefig(pathToImage)
171 for obj
in range(1, maxSceneobjects + 1):
172 for evidence
in range(1, maxSceneobjects + 1):
173 pathExperimentCsv = pathToCsv +
'/obj_' + str(obj) +
'_run_' + str(evidence) +
'/run_' + str(obj) +
'.csv' 175 print 'Evaluating ' + str(obj) +
' object(s) with ' + str(evidence) +
' evidences.' 178 numberOfTurns = sum(1
for row
in csv.reader(open(pathExperimentCsv,
'rb'), delimiter=
','))
179 numberOfTurns /= (maxSceneobjects + 1)
182 with open(pathExperimentCsv,
'rb')
as csvfile:
183 reader = csv.reader(csvfile, delimiter=
',')
190 for turn
in range(0, numberOfTurns - 1):
193 for i
in range(0, obj):
194 turnScore += float(reader.next()[1])
196 score.append(turnScore / obj)
200 psmScore.append(np.array(score[6:]).mean())
208 for samples
in range(1, maxSceneobjects + 1):
209 yLabels.append(samples)
212 data = np.zeros((maxSceneobjects, maxSceneobjects))
213 labels = np.zeros((maxSceneobjects, maxSceneobjects))
214 for x
in range(0, maxSceneobjects):
215 for y
in range(0, maxSceneobjects):
216 value = psmScore[x * (maxSceneobjects) + y]
240 y_pos = np.arange(len(yLabels))
243 fig = plt.figure(figsize=(10,4))
244 ax = fig.add_subplot(111)
248 left = np.zeros(len(yLabels))
249 for i, d
in enumerate(data):
250 patch_handles.append(ax.barh(y_pos, d, color=colors[i % len(colors)], align=
'center', label=
'%i' % (i + 1), left=left))
254 for j
in xrange(len(patch_handles)):
255 for i, patch
in enumerate(patch_handles[j].get_children()):
259 x = 0.5 * patch.get_width() + bl[0] + textoffsetX
260 y = 0.5 * patch.get_height() + bl[1] + textoffsetY
264 ax.text(x,y,
"%10.2f" % (labels[i,j]), ha=
'center', va=
'center', fontweight=
'bold', fontsize=15)
268 ax.set_yticklabels(yLabels)
272 ax.set_xlabel(
'Laufzeit in Millisekunden', fontweight=
'bold')
273 ax.set_ylabel(
'Objekte pro Szene', fontweight=
'bold')
276 ax.legend(loc=
'upper center', bbox_to_anchor=(0.5, 1.08), ncol=6, fancybox=
True, shadow=
True)
284 plt.savefig(pathToImage)
294 for obj
in range(1, maxSceneobjects + 1):
295 sceneId =
'run_' + str(obj).zfill(2)
296 pathExperimentCsv = pathToCsv +
'/' + sceneId +
'/' + sceneId +
'.csv' 298 print 'Evaluating ' + str(obj) +
' object(s) with ' + str(obj) +
' evidences.' 301 numberOfTurns = sum(1
for row
in csv.reader(open(pathExperimentCsv,
'rb'), delimiter=
','))
307 reader = csv.reader(open(pathExperimentCsv,
'rb'), delimiter=
',')
314 for turn
in range(0, numberOfTurns - 1):
318 for i
in range(0, obj):
319 turnScore += float(reader.next()[1])
322 turnScore += float(reader.next()[6])
324 score.append(turnScore)
329 objScore = np.array(score[6:]).mean() / 1000
331 objScore = np.array(score).mean() / 1000
335 psmScore.append(objScore)
342 xData = np.arange(1.0, maxSceneobjects + 1, 1.0)
343 yData = np.array(psmScore)
346 fig = plt.figure(figsize=(10,4))
347 ax = fig.add_subplot(111)
351 ax.set_xlabel(
'Objekte pro Szene', fontweight=
'bold')
352 ax.set_ylabel(
'Laufzeit in Sekunden', fontweight=
'bold')
354 ax.legend(loc=
'upper center', bbox_to_anchor=(0.5, 1.08), ncol=6, fancybox=
True, shadow=
True)
360 ax.plot(xData, yData,
'ro-')
363 plt.savefig(pathToImage)
368 pathToExperiments =
'/home/joachim/Schreibtisch/Evaluation/Laufzeitmessung' 376 generateRuntimePlotStandalone(pathToExperiments +
'/standalone/runtime/PSM', pathToExperiments +
'/images/PSM_standalone.png', 5,
False, -1.2, 0.05)
380 if __name__ ==
"__main__":
def generateRuntimePlotStandalone(pathToCsv, pathToImage, maxSceneobjects, useLog, textoffsetX, textoffsetY)
def generateRuntimePlot(pathToCsv, pathToImage, meanOverTurns, xtics, textoffsetX, textoffsetY)
def generateRuntimePlotKickass(pathToCsv, pathToImage, maxSceneobjects, useLog, meanOverTurns)