evaluation
Some checks failed
s434695-evaluation/pipeline/head There was a failure building this commit

This commit is contained in:
s434695 2021-05-16 23:02:31 +02:00
parent c9eebe06d3
commit a2b9b274b2
2 changed files with 38 additions and 1 deletions

View File

@ -1 +0,0 @@
print('test')

38
evaluation.py Normal file
View File

@ -0,0 +1,38 @@
import pandas as pd
import numpy as np
from tensorflow import keras
import matplotlib.pyplot as plt
from sklearn.metrics import mean_squared_error
vgsales_model = 'vgsales_model.h5'
model = keras.models.load_model(vgsales_model)
vgsales_test = pd.read_csv('test.csv')
vgsales_test['Nintendo'] = vgsales_test['Publisher'].apply(lambda x: 1 if x=='Nintendo' else 0)
X_test = vgsales_test.drop(['Rank','Name','Platform','Year','Genre','Publisher'],axis = 1)
y_test = vgsales_test[['Nintendo']]
predictions = model.predict(X_test)
error = mean_squared_error(y_test, predictions)
print('Error: ', error)
with open('results.txt', 'a') as f:
f.write(str(error) + "\n")
with open('results.txt', 'r') as f:
lines = f.readlines()
fig = plt.figure(figsize=(5,5))
chart = fig.add_subplot()
chart.set_ylabel("MSE")
chart.set_xlabel("Build")
x = np.arange(0, len(lines), 1)
y = [float(x) for x in lines]
plt.plot(x, y, "ro")
plt.savefig("plot.png")