add plot to eval script
All checks were successful
s444417-training/pipeline/head This commit looks good
s444417-evaluation/pipeline/head This commit looks good

This commit is contained in:
s444417 2022-05-04 17:39:39 +02:00
parent 314653785d
commit b60eaddffc

View File

@ -1,7 +1,9 @@
import csv
import os
import sys
import pandas as pd
import tensorflow as tf
import matplotlib.pyplot as plt
cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
modelPath = 'MyModel_tf'
@ -24,7 +26,10 @@ new_model = tf.keras.models.load_model(modelPath)
# Evaluate the restored model
loss = new_model.evaluate(house_price_test_features, house_price_test_expected, verbose=2)
print(loss)
print("------\n")
print(f"loss result: ${loss}\n")
print("------")
#print('Restored model, accuracy: {:5.2f}%'.format(100 * acc))
count = 0
@ -36,3 +41,20 @@ except:
with open('trainResults.csv', 'a+') as trainResults:
trainResults.write(f"{count},{loss}" + "\n")
try:
x = []
y = []
with open('trainResults.csv', 'r') as trainResults:
plots = csv.reader(trainResults, delimiter = ',')
for row in plots:
x.append(row[0])
y.append(row[1])
plt.bar(x, y, color = 'g', label = "loss")
plt.xlabel('builds')
plt.ylabel('losses')
plt.title('loss for build')
plt.legend()
plt.show()
except:
pass