33 lines
883 B
Python
33 lines
883 B
Python
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')
|
|
|
|
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')
|