ium_434684/ium_zadanie6_evaluation.py

32 lines
884 B
Python
Raw Normal View History

2021-05-15 19:22:55 +02:00
from tensorflow.keras.models import Sequential, load_model
2021-05-15 19:01:17 +02:00
from tensorflow.keras import layers
2021-05-02 22:20:05 +02:00
# from keras.layers import Flatten,Dense,Dropout, GlobalAveragePooling2D
2021-05-15 19:01:17 +02:00
from tensorflow.keras.optimizers import Adam
2021-05-02 22:20:05 +02:00
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')
2021-05-15 19:22:55 +02:00
model = 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:
2021-05-16 11:30:13 +02:00
f.write('%f\n' % error)
2021-05-02 22:20:05 +02:00
errors = np.genfromtxt('evaluation.txt')
fig = plt.figure()
plt.plot(errors)
plt.title('Evaluation of trained models')
plt.ylabel('Mean squared error')
2021-05-15 19:42:46 +02:00
fig.savefig('mean_square_error.png')