Skip to content

LSTM-based deep learning model that classifies emotions in tweets using TensorFlow. Built as part of a Coursera guided project.

Notifications You must be signed in to change notification settings

khaledjamal/tweet-emotion-recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tweet Emotion Recognition with TensorFlow

Python TensorFlow Status

🚀 Overview

This project implements a deep learning model using TensorFlow to classify emotions expressed in tweets. It is based on a guided Coursera project and leverages the dair-ai/emotion dataset available on Hugging Face.

The model is trained to recognize six emotion categories in tweets:

  • Joy
  • Anger
  • Sadness
  • Love
  • Fear
  • Surprise

The project includes text preprocessing, embedding, LSTM model training, and performance evaluation.

🎯 Features

  • 🔍 Emotion classification from tweet text
  • 🧠 LSTM-based deep learning model
  • 💬 Tokenization, padding, and word embeddings
  • 📊 Confusion matrix and classification report

🏗️ Project Structure

├── Tweet_Emotion_Recognition.ipynb  # Main Jupyter notebook
├── Tweet_Emotion_Recognition.pdf    # PDF export of the notebook
├── requirements.txt                 # Python dependencies
└── README.md                        # Project documentation

🔥 Technologies Used

Category Tools & Libraries
Deep Learning TensorFlow, Keras
NLP Hugging Face Datasets
Visualization Matplotlib
Data Handling NumPy
Development Jupyter Notebook

Requirements

  • Python 3.8+
  • TensorFlow
  • NumPy
  • Matplotlib
  • Scikit-learn
  • Hugging Face Datasets
  • Jupyter

Install required packages using:

pip install tensorflow numpy matplotlib scikit-learn datasets jupyter

How to Run

  1. Clone the repository:

    git clone https://github.com/your-username/tweet-emotion-recognition.git
    cd tweet-emotion-recognition
  2. (Optional) Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Open and run the notebook:

    jupyter notebook Tweet_Emotion_Recognition.ipynb

Model Architecture

The model is a Sequential neural network composed of:

  • An Embedding layer (using pre-trained GloVe vectors)
  • A Bidirectional LSTM layer with 64 units (returning sequences)
  • A second Bidirectional LSTM layer with 32 units
  • A Dense layer with ReLU activation
  • A Softmax output layer for emotion classification

Results

The model was trained and evaluated on the dair-ai/emotion dataset and achieved:

  • Validation Accuracy: ~89.5%
  • Test Accuracy: 88.5%
  • F1 Score: 88.5%

Results were visualized using a confusion matrix and classification report.

License

This project is for educational purposes and is based on a guided Coursera project: Coursera: Tweet Emotion Recognition with TensorFlow

Author

Khaled Jamal
LinkedIn

About

LSTM-based deep learning model that classifies emotions in tweets using TensorFlow. Built as part of a Coursera guided project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published