Skip to content

Commit

Permalink
Plotting codes for model evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawith committed Oct 19, 2025
1 parent 894a9eb commit 2a0e53e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
29 changes: 29 additions & 0 deletions model_eval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -- coding: utf-8 -*-
"""
This script takes the model metric results stored as csv and generates plots to
visualize the performance based on the choice of hyperparameters.
"""

import pandas as pd

from visualize import plot

def main():
metric = pd.read_csv("/app/workdir/metrics.csv")
print(metric.head())
hyperparam_keys = metric.columns.tolist()
metric_keys = ["test_accuracy", "test_loss"]
[hyperparam_keys.remove(key) for key in metric_keys]

for key in hyperparam_keys:
for metric_key in metric_keys:
plot.lineplot(
data=metric,
x=key,
y=metric_key,
)

if __name__ == "__main__":
main()

# EOF
18 changes: 18 additions & 0 deletions visualize/plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# --*- coding: utf-8 -*-

import matplotlib.pyplot as plt
import seaborn as sns

def lineplot(data=None, x=None, y=None):
if data is None or x is None or y is None:
raise ValueError("Data, x, and y parameters must be provided.")

sns.lineplot(data=data, x=x, y=y)
plt.title(f"{y} by {x}")
plt.xlabel(x)
plt.ylabel(y)
plt.savefig(f"/app/workdir/figures/lineplot_{y}_by_{x}.png")
plt.close()


# EOF

0 comments on commit 2a0e53e

Please sign in to comment.