ium_434760/evaluate.py

37 lines
927 B
Python
Raw Normal View History

2021-04-29 23:45:22 +02:00
import pandas as pd
import numpy as np
from os import path
from tensorflow import keras
import matplotlib.pyplot as plt
2021-05-16 23:41:55 +02:00
import mlflow
2021-04-29 23:45:22 +02:00
model_name = "model.h5"
input_columns=["Age","Nationality","Position","Club"]
model = keras.models.load_model(model_name)
test_data=pd.read_csv('test.csv')
X_test=test_data[input_columns].to_numpy()
Y_test=test_data[["Overall"]].to_numpy()
#MeanSquaredError
results_test = model.evaluate(X_test, Y_test, batch_size=128)
2021-05-16 23:41:55 +02:00
mlflow.log_metric("rmse", results_test)
2021-04-29 23:45:22 +02:00
with open('results.txt', 'a+', encoding="UTF-8") as f:
f.write(str(results_test) +"\n")
with open('results.txt', 'r', encoding="UTF-8") as f:
lines = f.readlines()
fig = plt.figure(figsize=(5,5))
chart = fig.add_subplot()
chart.set_ylabel("Mean squared error")
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")