ium_470607/lab5/eval/eval.py

28 lines
619 B
Python
Raw Normal View History

2021-05-14 21:52:14 +02:00
import csv
2021-05-16 23:01:34 +02:00
import matplotlib.pyplot as plt
2021-05-02 22:01:32 +02:00
import pandas as pd
2021-05-16 13:01:57 +02:00
from tensorflow.keras.models import load_model
2021-05-02 22:01:32 +02:00
X_test = pd.read_csv('test.csv')
2021-05-14 21:52:14 +02:00
Y_test = X_test.pop('stabf')
Y_test = pd.get_dummies(Y_test)
2021-05-02 22:01:32 +02:00
2021-05-16 13:01:57 +02:00
model = load_model('grid-stability-dense.h5')
2021-05-15 22:30:25 +02:00
2021-05-14 21:52:14 +02:00
results = model.evaluate(X_test, Y_test, batch_size=64)
2021-05-02 22:01:32 +02:00
2021-05-14 21:52:14 +02:00
with open('eval.csv', 'a', newline='') as fp:
wr = csv.writer(fp, dialect='excel')
wr.writerow(results)
2021-05-16 13:01:57 +02:00
2021-05-16 23:01:34 +02:00
metrics = pd.read_csv('eval.csv', header=None, names=['loss', 'accuracy'])
fig = plt.figure()
plt.plot(metrics.accuracy)
plt.ylabel('Accuracy')
plt.xlabel('Build no.')
fig.savefig('plot.png')