Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tweet Emotion Detection

Overview

The Tweet Emotion Detection Model is a Python-based application leveraging Natural Language Processing (NLP) techniques to classify the emotions conveyed in tweets. This tool aims to analyze tweet content and detect emotions such as joy, sadness, fear, neutral, anger, and shame. It uses a trained machine learning model and offers a user-friendly interface powered by Streamlit.

Features

  • Fetch tweets directly from a given Twitter/X URL.
  • Predict emotions like happy, sad, fear, anger, surprise, neutral, disgust, and shame.
  • Emoji mapping for better visual interpretation.
  • Probability chart using Altair for prediction confidence.
  • Simple web UI powered by Streamlit.

Tech Stack

  • Python 3
  • Streamlit – Web app framework
  • scikit-learn – Model training & prediction
  • pandas, numpy – Data processing
  • Altair – Data visualization
  • joblib – Model loading
  • Requests – Fetch tweet content

Project Structure

├── app.py # Main Streamlit app ├── text_emotion.pkl # Pre-trained ML model ├── tweet_dataset.csv # Dataset used for training ├── Text_Emotion_Detection.ipynb # Notebook for model training └── README.md # Project documentation

Installation & Usage

Clone the repository

git clone https://github.com/yourusername/tweet-emotion-detection.git
cd tweet-emotion-detection

Dataset Details

The dataset used for training contains text samples labeled with emotions. It underwent several preprocessing steps:

  • Removal of stop words, user handles, and special characters using the Neat Text library.
  • Addition of a column for cleaned text to prepare the data for model training.

Model Training

The model was trained using Scikit-learn with the following algorithms:

  1. Support Vector Machines (SVM): For robust classification by finding optimal decision boundaries.
  2. Random Forest Classifier: Utilizes an ensemble of decision trees for accurate predictions.
  3. Logistic Regression: Effective for categorical output prediction.

`The dataset was split:

  • 70% Training Set: Used for model training.
  • 30% Testing Set: Used for evaluating the model's performance.

##Install dependencies

pip install -r requirements.txt

##Run the app

streamlit run app.py

##Open in Browser

 http://localhost:8501

Paste a Tweet/X URL and see the detected emotion.

##Example

https://twitter.com/elonmusk/status/123456789

##Output: Emotion: happy 😂 Confidence: 0.92

About

Tweet Emotion Detection app built with Streamlit. Fetches tweet text from a URL, applies a trained NLP model to detect the dominant emotion, and visualizes prediction probabilities alongside expressive emoji icons in a clean, intuitive interface.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages