IUM_06
This commit is contained in:
parent
89f3b6ec3d
commit
652ca06460
@ -1,25 +1,18 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import tensorflow as tf
|
||||
|
||||
# Load the test data
|
||||
test_data = pd.read_csv('./beer_reviews_test.csv')
|
||||
X_test = test_data[['review_aroma', 'review_appearance', 'review_palate', 'review_taste']]
|
||||
y_test = test_data['review_overall']
|
||||
|
||||
# Load the model
|
||||
model = tf.keras.models.load_model('beer_review_sentiment_model.h5')
|
||||
|
||||
# Make predictions
|
||||
predictions = model.predict(X_test)
|
||||
|
||||
# Check the shape of the predictions
|
||||
print(f'Predictions shape: {predictions.shape}')
|
||||
|
||||
# If predictions have more than one dimension, select only one dimension
|
||||
if len(predictions.shape) > 1:
|
||||
predictions = predictions[:, 0]
|
||||
|
||||
# Save predictions and actual data to a CSV file
|
||||
results = pd.DataFrame({'Predictions': predictions, 'Actual': y_test})
|
||||
results.to_csv('beer_review_sentiment_predictions.csv', index=False)
|
@ -3,7 +3,6 @@ from sklearn.metrics import accuracy_score, precision_recall_fscore_support, mea
|
||||
from math import sqrt
|
||||
import sys
|
||||
|
||||
# Load the predictions data
|
||||
data = pd.read_csv('beer_review_sentiment_predictions.csv')
|
||||
y_pred = data['Predictions']
|
||||
y_test = data['Actual']
|
||||
@ -11,7 +10,6 @@ y_test_binary = (y_test >= 3).astype(int)
|
||||
|
||||
build_number = sys.argv[1]
|
||||
|
||||
# Calculate metrics
|
||||
accuracy = accuracy_score(y_test_binary, y_pred.round())
|
||||
precision, recall, f1, _ = precision_recall_fscore_support(y_test_binary, y_pred.round(), average='micro')
|
||||
rmse = sqrt(mean_squared_error(y_test, y_pred))
|
||||
|
Loading…
Reference in New Issue
Block a user