ium_434684/ium_zadanie6_evaluation.py

33 lines
886 B
Python
Raw Normal View History

2021-05-02 22:20:05 +02:00
import tensorflow as tf
from tf.keras.models import Sequential
from tf.keras import layers
# from keras.layers import Flatten,Dense,Dropout, GlobalAveragePooling2D
from tf.keras.optimizers import Adam
import numpy as np
import pandas as pd
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt
movies_test = pd.read_csv('movies_test.csv')
x_test = movies_test.copy()
y_test = x_test.pop('rottentomatoes_audience_score')
x_test.pop('Unnamed: 0')
model = keras.models.load_model('model_movies.h5')
2021-05-02 22:20:05 +02:00
y_predicted = model.predict(x_test, batch_size=64)
error = mean_squared_error(y_test, y_predicted)
with open('evaluation.txt', 'a+') as f:
f.write('%d\n' % error)
errors = np.genfromtxt('evaluation.txt')
fig = plt.figure()
plt.plot(errors)
plt.title('Evaluation of trained models')
plt.ylabel('Mean squared error')
fig.savefig('mean_squared_error.png')