| # Emotion Analysis with LSTM | |
| This project implements an LSTM-based neural network for emotion analysis using the `emotion_sentimen_dataset.csv`. | |
| ## Features | |
| - **Efficient Training**: Uses a subset (20,000 samples) of the large dataset for faster experimentation while maintaining good accuracy. | |
| - **LSTM Architecture**: Embedding -> SpatialDropout -> LSTM -> Dense. | |
| - **Deployment Ready**: Includes scripts for training and real-time prediction. | |
| ## Requirements | |
| - Python 3.x | |
| - TensorFlow / Keras | |
| - Pandas, NumPy, Scikit-learn | |
| ## Files | |
| - `train_emotion_lstm.py`: Script to preprocess data, build, train, and save the model. | |
| - `predict_emotion.py`: Script to load the trained model and predict emotions from user input. | |
| - `emotion_model.h5`: The saved trained model. | |
| - `tokenizer.pickle`: Saved tokenizer for text processing. | |
| - `label_encoder_classes.npy`: Saved label encoder classes. | |
| ## Usage | |
| ### 1. Training | |
| To train the model (if you want to re-train): | |
| ```bash | |
| python train_emotion_lstm.py | |
| ``` | |
| This produces `emotion_model.h5` and necessary artifacts. | |
| ### 2. Prediction | |
| To use the model for prediction: | |
| ```bash | |
| python predict_emotion.py | |
| ``` | |
| Type any sentence when prompted, and the model will classify its emotion. | |
| ## Performance | |
| The model achieves high accuracy (>90%) on the test set even with a reduced dataset size, demonstrating efficiency. | |