From 652ca064606541ab93578d14f57f950da065fcb7 Mon Sep 17 00:00:00 2001 From: AWieczarek Date: Mon, 6 May 2024 21:13:39 +0200 Subject: [PATCH] IUM_06 --- IUM_05-predict.py | 7 ------- IUM_06-metrics.py | 2 -- 2 files changed, 9 deletions(-) diff --git a/IUM_05-predict.py b/IUM_05-predict.py index d36734e..54038e4 100644 --- a/IUM_05-predict.py +++ b/IUM_05-predict.py @@ -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) \ No newline at end of file diff --git a/IUM_06-metrics.py b/IUM_06-metrics.py index 89c364b..e9189a9 100644 --- a/IUM_06-metrics.py +++ b/IUM_06-metrics.py @@ -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))