Ab sofort ist der Login auf der Weboberfläche von git.fh-muenster.de bevorzugt über FH Muenster SSO möglich.

Commit 3d41c25c authored by Daniel Lukats's avatar Daniel Lukats

added colors to evaluation script

parent ded4bd7d
......@@ -7,9 +7,9 @@ import sys
from collections import deque
from dataclasses import dataclass, field
from sklearn.kernel_ridge import KernelRidge
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
from typing import List, Tuple, Union
from matplotlib.lines import Line2D
@dataclass
......@@ -76,6 +76,7 @@ def setup():
:return: None
"""
plt.rcParams['figure.figsize'] = (16, 9)
plt.rcParams['font.size'] = 20
plt.grid(alpha=0.25)
axes = plt.gca()
axes.spines['top'].set_visible(False)
......@@ -93,31 +94,44 @@ def create_plot(experiment: Experiment,
:param plot:
:return:
"""
colors = ['#0077BB', '#33BBEE', '#009988', '#EE7733']
colors = ['#009988', '#33BBEE', '#0077BB', '#EE7733']
setup()
data_x = []
data_y = []
for i, run in enumerate(experiment.runs):
plt.scatter(run.steps, run.values, label=f'Run {i+1}', color=colors[i])
plt.scatter(run.steps, run.values, label=f'Run {i+1}', color=colors[i], s=18)
data_x += run.steps
data_y += run.values
plt.plot(comparison[0], comparison[1], color='black', label='Trendline')
plt.title(f'{experiment.game}')
plt.xlabel('Time step')
plt.ylabel('Score')
plt.legend()
make_legend(colors, trend=False)
plt.tight_layout(pad=1.04)
if plot:
plt.show()
else:
path = os.path.join(experiment.path, experiment.game)
plt.savefig(path)
if default_trend is not None:
plt.plot(default_trend[0], default_trend[1], label='Trendline (default config)', color=colors[3])
plt.legend()
plt.savefig(path + '_default')
plt.plot(default_trend[0], default_trend[1], label='Trendline (reference)', color=colors[3])
make_legend(colors)
plt.tight_layout(pad=1.08)
plt.savefig(path + '_reference')
plt.clf()
def make_legend(colors: List,
trend: bool = True):
legend_elements = [Line2D([0], [0], color='black', lw=4, label='Trendline'),
Line2D([0], [0], marker='o', color='w', label='Run 1', markerfacecolor=colors[0], markersize=15),
Line2D([0], [0], marker='o', color='w', label='Run 2', markerfacecolor=colors[1], markersize=15),
Line2D([0], [0], marker='o', color='w', label='Run 3', markerfacecolor=colors[2], markersize=15)]
if trend:
legend_elements.insert(1, Line2D([0], [0], color=colors[3], lw=4, label='Trendline (reference)'))
plt.gca().legend(handles=legend_elements)
def create_trendline(data: Experiment,
window: int,
):
......@@ -135,29 +149,6 @@ def create_trendline(data: Experiment,
return data_x[:-window//2], trend_y[window//2:]
def create_trendline_poly(data_x: List,
data_y: List,
degree: int,
):
coeffs = np.polynomial.polynomial.polyfit(data_x, data_y, degree)
data_x = sorted(data_x)
poly_y = np.polynomial.polynomial.polyval(data_x, coeffs)
return data_x, poly_y
def create_trendline_isotonic(data: Experiment):
data_x = []
data_y = []
for run in data.runs:
data_x += run.steps
data_y += run.values
data_x = np.array(data_x).reshape(1, -1)
data_y = np.array(data_y).reshape(1, -1)
kernel = KernelRidge(alpha=1.5).fit(data_x, data_y)
y = kernel.predict(data_x).flatten()
return data_x.flatten(), y
def parse(directory: str):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment