from tensorflow.keras.models import Sequential, load_model from tensorflow.keras import layers # from keras.layers import Flatten,Dense,Dropout, GlobalAveragePooling2D from tensorflow.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 = load_model('model_movies.h5') 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')