29 lines
680 B
Python
29 lines
680 B
Python
|
import pandas as pd
|
||
|
import numpy as np
|
||
|
from tensorflow import keras
|
||
|
from sklearn.metrics import accuracy_score, f1_score
|
||
|
import matplotlib.pyplot as plt
|
||
|
|
||
|
|
||
|
model = keras.models.load_model('trained_model')
|
||
|
|
||
|
test_df = pd.read_csv('test.csv')
|
||
|
test_x = test_df['reviews.text'].to_numpy()
|
||
|
test_y = test_df['reviews.doRecommend'].to_numpy()
|
||
|
|
||
|
# print(test_y.shape)
|
||
|
# print(test_x.shape)
|
||
|
|
||
|
predictions = model.predict(test_x)
|
||
|
|
||
|
predictions = [1 if p > 0.5 else 0 for p in predictions]
|
||
|
|
||
|
accuracy = accuracy_score(test_y, predictions)
|
||
|
f1 = f1_score(test_y, predictions)
|
||
|
|
||
|
file = open('evaluation.txt', 'w')
|
||
|
file.writelines(accuracy.__str__() + '\n')
|
||
|
file.writelines(f1.__str__())
|
||
|
file.close()
|
||
|
|