Skip to content

About

Sentiment analysis of tweets

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🐦 Sentiment Analysis on Twitter Data

A comprehensive machine learning pipeline designed to classify the sentiment of Twitter data using both traditional statistical methods and deep learning architectures.

  • Project Timeline: September 2025

📌 Project Overview

Twitter data is inherently noisy due to:

  • Informal language
  • Slang and abbreviations
  • High noise-to-signal ratio

This project implements a full Natural Language Processing (NLP) pipeline—from raw data cleaning to advanced sequence modeling—to classify tweets into sentiment categories.


🛠️ Technical Workflow

1️⃣ Data Cleaning & Preprocessing

To handle noisy Twitter data, the following steps were applied:

  • Noise Removal

    • Removed URLs, HTML tags, mentions (@user), and special characters using Regex
  • Stopword Removal

    • Eliminated common words (e.g., the, is)
  • Tokenization & Lemmatization

    • Converted text into tokens
    • Reduced words to their base/root forms

2️⃣ Feature Extraction

Two approaches were used to represent text numerically:

  • TF-IDF (Term Frequency–Inverse Document Frequency)

    • Captures importance of words across the dataset
  • Word Embeddings

    • Dense vector representations capturing semantic meaning and context

3️⃣ Model Architectures

🔹 Logistic Regression

  • Baseline linear classifier
  • Performs well with TF-IDF features
  • Fast and interpretable

🔹 LSTM (Long Short-Term Memory)

  • A type of Recurrent Neural Network (RNN)
  • Captures sequential dependencies in text
  • Handles context and long-range relationships

📊 Evaluation & Performance

Models were evaluated on balanced datasets using:

Metric Description
Precision Measures correctness of positive predictions
Recall Measures ability to find all positive samples
F1-Score Harmonic mean of precision and recall

📈 Results

  • LSTM outperformed traditional methods in capturing nuanced sentiment
  • Logistic Regression provided a strong and efficient baseline

🚀 Getting Started

📌 Prerequisites

  • Python 3.10+
  • TensorFlow / Keras
  • Scikit-learn
  • NLTK or SpaCy

1. Clone Repository

git clone https://github.com/yourusername/twitter-sentiment-analysis.git

2. Install Dependencies

pip install -r requirements.txt

3. Run Training

python src/models.py

🧠 Key Insights

  • Preprocessing is critical (~80% of performance gains)

    • Effective noise removal significantly improved model performance
  • Context Matters

    • Word embeddings + LSTM outperform TF-IDF for:
      • Sarcasm detection
      • Multi-word sentiment patterns

📌 Summary

This project demonstrates:

  • End-to-end NLP pipeline design
  • Handling noisy real-world text data
  • Feature engineering for text classification
  • Comparison of classical ML vs deep learning approaches
  • Importance of contextual understanding in sentiment analysis

About

Sentiment analysis of tweets

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages