37 lines
927 B
Python
37 lines
927 B
Python
import pandas as pd
|
|
import numpy as np
|
|
from os import path
|
|
from tensorflow import keras
|
|
import matplotlib.pyplot as plt
|
|
import mlflow
|
|
|
|
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)
|
|
mlflow.log_metric("rmse", results_test)
|
|
|
|
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") |