EEG / gru /run.py
dreamnotfound's picture
Upload 4 files
39770c3
raw
history blame contribute delete
953 Bytes
import numpy as np
import pandas as pd
import tensorflow as tf
# Load the trained GRU model
loaded_model = tf.keras.models.load_model('save/gru_model.keras')
# Load new data for prediction
new_data = pd.read_csv('input/data.csv') # Replace with the path to your new data CSV file
# Preprocess the new data (similar to how you preprocessed the training data)
# Assuming the new_data has the same features as the training data
X_new = new_data.drop('label', axis=1)
# Make predictions on new data
predicted_labels = loaded_model.predict_classes(X_new)
# Map predicted labels back to emotions using the label_mapping dictionary
reverse_label_mapping = {v: k for k, v in label_mapping.items()}
predicted_emotions = [reverse_label_mapping[label] for label in predicted_labels]
# Add predicted emotions to the new_data DataFrame
new_data['predicted_emotion'] = predicted_emotions
# Print the new_data DataFrame with predicted emotions
print(new_data)