Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TweetEmotionNet : Emotion Classification with LSTM-based Architectures

TweetEmotionNet is a PyTorch-based pipeline for emotion classification of short tweets. We implement and compare several architectures from a vanilla LSTM to attention-augmented, CNN–LSTM, BiLSTM, multi-head attention, and DistilBERT fine-tuning, to identify the simplest yet most effective model.


Repository Structure

├── LSTM_model/ # Model definition, data handling, and training scripts
│ ├── model
│ │ ├── dataset.py
│ │ └── model.py
│ ├── run
│ │ ├── test.py
│ │ └── train.py
│ ├── utils
│ │ └── utils.py
│ └── main.py 
│
├── gridsearch/ # Hyperparameter-search scripts & JSON configs
│ ├── grid_bid_attention.json
│ ├── grid_attention.json
│ ├── grid_phase1.json
│ ├── grid_cnn_lstm.json
│ ├── generate_grid_search.py
│ └── run_multiple_models.py
│
├── analyze_comparison/ # Result visualization, error analysis & ranking models
│ ├── model_filter.py
│ └── model_analysis.ipynb
│
├── preprocess_dataset/ # Visualization notebook of dataset and repartition
│ └── processing_dataset.ipynb
│
├── output/ # Model checkpoints & result CSVs and JSON
│ ├── baseline_model/
│ └── best_model/
│
├── shell_scripts/ # Shell scripts to execute python file (training, testing, ranking)
│ ├─ train.sh
| ├── train_multiple.sh
| ├── test.sh
│ └── compare_model.sh
|
├── dataset.csv
├── requirements.txt
└── README.md

Installation & Dependencies

Clone the repository

git clone https://github.com/Lens11/TweetEmotionNet.git
cd TweetEmotionNet

(optional) Create a new environment

python3 -m venv venv & source venv/bin/activate

Install required dependencies

pip install -r requirements.txt

(optional) Download Pretrained Models

To download results of pretrained models I trained, you need to use (follow guidelines if needed):

sudo snap install gdrive

Then download the two results folders stored on Google Drive, output_phase1 are the results for the first gridsearch to determine the baseline model and output_results are the results for the baseline with attention-based architecture.

gdrive https://drive.google.com/drive/folders/1AoaoDj30VK1fQBh4vCGcHlyJ0GwrSHfu?usp=drive_link

Usage

Dataset

The dataset.csv file contains tweets and their emotion labels. Run preprocess_dataset/processing_dataset.ipynb to visualize tweet length distributions and other data specificity. Original data sourced from Kaggle.

Training

  1. Run a single model with your own LSTM model properties.
bash train.sh
  1. Run multiple models (especially for grid search configurations) with your own model properties.
bash train_multiple.sh

Evaluation

Evaluate any model on the test set that have a PyTorch file (.pt) or checkpoint: You will generate a JSON files with all evaluation metrics (F1, accuracy, recall, precision, auc, confusion matrix, inference time, nbr parameters, model size)

bash test.sh

Model comparison & ranking

After training, rank models by a chosen metric (e.g., valid_accuracy). You can rank models using training parameters (with metrics get by valid set during training) and the evaluation model step is not mandatory for ranking.

bash compare_model.sh

Result analysis and curve

Open analyze_comparison/model_analysis.ipynb to:

  • Plot training vs. validation loss curves for each model
  • Display confusion matrices
  • Inspect misclassified tweet examples

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages