ium_464979/IUM_05-predict.py

19 lines
614 B
Python
Raw Normal View History

2024-04-16 18:58:43 +02:00
import pandas as pd
import numpy as np
import tensorflow as tf
test_data = pd.read_csv('./beer_reviews_test.csv')
X_test = test_data[['review_aroma', 'review_appearance', 'review_palate', 'review_taste']]
model = tf.keras.models.load_model('beer_review_sentiment_model.h5')
tokenizer = tf.keras.preprocessing.text.Tokenizer(num_words=10000)
X_test_seq = tokenizer.texts_to_sequences(X_test)
X_test_pad = tf.keras.preprocessing.sequence.pad_sequences(X_test_seq, maxlen=100)
predictions = model.predict(X_test_pad)
np.savetxt('beer_review_sentiment_predictions.csv', predictions, delimiter=',', fmt='%.10f')