Skip to content

M1325-source/Sentiment-Analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŸ Twitter Sentiment Analyzer โ€” Explainable AI Dashboard

Advanced NLP pipeline using TF-IDF + Logistic Regression with Explainable AI token attribution, batch CSV processing, and a live Streamlit dashboard.

Live Demo Python Stars


๐Ÿ”— Live Demo

๐Ÿ‘‰ Try it live โ†’

Type any text or upload a CSV and get instant sentiment predictions with explainability!


๐ŸŽฏ Overview

A fully interactive Sentiment Analysis Dashboard that goes beyond basic positive/negative prediction โ€” it shows which words drove the sentiment using Explainable AI token attribution.

Built for:

  • Social media analysis (tweets, reviews)
  • Customer feedback classification
  • Batch processing of large text datasets

โœจ Features

๐Ÿ” Real-Time Text Analysis

  • Enter any text and get instant prediction
  • Positive / Negative classification
  • Confidence score with visual gauge bar

๐Ÿ“Š CSV Batch Processing (Report Studio)

  • Upload any CSV with a text column
  • Full predictions table with sentiment labels
  • Sentiment distribution bar chart
  • Positive + Negative word clouds
  • Dataset summary metrics

๐Ÿง  Explainable AI (Token Attribution)

  • Highlights top positive words boosting sentiment
  • Highlights top negative words lowering sentiment
  • Weighted importance score per word
  • Makes the model transparent and interpretable

๐ŸŽจ Modern Dark-Themed UI

  • Professional dashboard layout
  • Two-tab interface: Live Analyzer + CSV Studio
  • Clean typography and animated components

๐Ÿ—๏ธ System Architecture

Raw Text Input
      โ”‚
      โ–ผ
Text Cleaning (NLTK)
      โ”‚
      โ–ผ
TF-IDF Vectorization
      โ”‚
      โ–ผ
Logistic Regression Model
      โ”‚
      โ”œโ”€โ”€โ–บ Sentiment Prediction (Positive/Negative)
      โ”œโ”€โ”€โ–บ Confidence Score
      โ””โ”€โ”€โ–บ Token Weight Attribution (Explainability)
                  โ”‚
                  โ–ผ
         Streamlit Dashboard

โš™๏ธ Tech Stack

Component Technology
ML Model Logistic Regression (scikit-learn)
Feature Engineering TF-IDF Vectorizer
Explainability Token Weight Attribution
NLP Preprocessing NLTK
Visualizations Matplotlib, WordCloud
UI & Deployment Streamlit + Streamlit Cloud

๐Ÿ“ Project Structure

Sentiment-Analysis/
โ”‚
โ”œโ”€โ”€ app.py                     โ† Streamlit dashboard (main entry)
โ”œโ”€โ”€ sentiment_utils.py         โ† Prediction + Explainability engine
โ”œโ”€โ”€ train_model.py             โ† Model training script
โ”œโ”€โ”€ test_analysis.py           โ† Local testing script
โ”œโ”€โ”€ requirements.txt
โ”‚
โ””โ”€โ”€ models/
    โ”œโ”€โ”€ sentiment_model.joblib     โ† Trained model
    โ””โ”€โ”€ tfidf_vectorizer.joblib    โ† Fitted vectorizer

๐Ÿš€ Run Locally

# Clone the repo
git clone https://github.com/M1325-source/Sentiment-Analysis.git
cd Sentiment-Analysis

# Install dependencies
pip install -r requirements.txt

# Run the app
streamlit run app.py

Open http://localhost:8501 in your browser.


๐Ÿ“Š Model Performance

Metric Score
Algorithm Logistic Regression
Features TF-IDF (n-grams)
Dataset Twitter Sentiment140
Accuracy ~85%+

๐Ÿ”ฎ Future Enhancements

  • BERT / Transformer-based model upgrade
  • Multi-class sentiment (Very Positive, Neutral, Very Negative)
  • Real-time Twitter API integration
  • Aspect-based sentiment analysis
  • REST API endpoint for programmatic access

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Manisha Priya โ€” AI/ML Engineer

โญ Star this repo if you found it useful!

About

Advanced Twitter Sentiment Analyzer built using TF-IDF and Logistic Regression, featuring a production-style interactive Streamlit dashboard https://sentiment-analysis-58bkiqua6elowgtt5wnkjc.streamlit.app/

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages