ium_434788/Zadanie_06_evaluate.py
Dominik Strzako ca74151be3 hotfix :)
2021-05-15 16:40:43 +02:00

38 lines
971 B
Python

import pandas as pd
import numpy as np
from os import path
from tensorflow import keras
import sys
import matplotlib.pyplot as plt
from sklearn.metrics import accuracy_score, classification_report
model = keras.models.load_model('wine_model.h5')
print('evaluating')
test_df =pd.read_csv('test.csv')
y_test = test_df.quality
x_test = test_df.drop(['quality'], axis= 1)
x_test=((x_test-x_test.min())/(x_test.max()-x_test.min())) #Normalizacja
y_pred = model.predict(x_test)
y_pred = np.around(y_pred, decimals=0)
results = accuracy_score(y_test,y_pred)
with open('results.txt', 'a+', encoding="UTF-8") as f:
f.write(str(results) +"\n")
with open('results.txt', 'r', encoding="UTF-8") as f:
lines = f.readlines()
fig = plt.figure(figsize=(10,10))
chart = fig.add_subplot()
chart.set_ylabel("Accuracy")
chart.set_xlabel("Number of build")
x = np.arange(0, len(lines), 1)
y = [float(x) for x in lines]
print(y)
plt.plot(x,y,"ro")
plt.savefig("evaluation.png")