All projects

Page Sentiment

A Facebook Page comment sentiment dashboard using a TF-IDF and Logistic Regression model trained on Sentiment140.

AI & Data

  • python
  • flask
  • vue
  • scikit-learn
  • tf-idf
  • logistic regression
  • sqlite
  • facebook graph api
Page Sentiment on a laptop
Page Sentiment on a tablet
Page Sentiment on a phone
The Page Sentiment interface.

Overview

Page Sentiment is a dashboard for reviewing the sentiment of comments on a Facebook Page. It fetches the latest comments on demand, runs them through a classical text-classification pipeline, and summarizes positive, neutral, and negative results in charts and tables. The backend is Flask/Python, the dashboard is Vue, and the saved scikit-learn Pipeline keeps text vectorization and classification together at prediction time.

Key features

  • Fetches the latest comments from a configured Facebook Page when the user requests an update; it does not rely on background workers, webhooks, or cron jobs.
  • Summarizes classified comments with headline totals and positive, neutral, and negative proportions.
  • Shows sentiment distribution and comment activity over time with labeled dashboard charts.
  • Surfaces the most negative comments first in a needs-attention view to help prioritize replies.
  • Breaks sentiment down by post so page owners can compare comment patterns across posts.
  • Includes a try-the-model control for entering text and viewing the classifier's prediction.
  • Displays model insights, learned positive/negative terms, training configuration, and evaluation context.
  • Supports light and dark dashboard themes with a diverging positive/negative palette and neutral midpoint.

Engineering highlights

  • Trains on Sentiment140, a 1.6-million-tweet dataset; the documented default trains on a random 200,000-row sample for iteration speed.
  • Compares unigram and bigram TF-IDF feature configurations; the README reports 80.2% held-out test accuracy for the current 200k-sample model.
  • Saves the vectorizer and classifier together in a scikit-learn Pipeline so prediction uses the same vocabulary learned during training.
  • Uses a probability band from 0.40 to 0.60 to report neutral sentiment, since the source dataset itself is binary-labeled.
  • Separates data preparation, model training, prediction, Facebook API access, SQLite persistence, and Flask routes into backend modules.
  • The Vue/Vite frontend proxies API requests during development and can build into the Flask service for single-process deployment.

Challenges and approach

A binary training dataset cannot directly label neutral comments.

The prediction layer applies a documented 0.40–0.60 probability band as a calibration rule and returns neutral for predictions in that range.

Single-word features miss meaning that depends on negation, such as 'not happy'.

The README compares bigram TF-IDF configurations, which can retain phrases such as 'not bad' as combined features; stopword removal is adjusted so negation terms are not discarded.

English-only training data is not reliable for Bangla, Banglish, or sarcasm.

The project documents these limitations explicitly; non-English or empty cleaned input is treated as neutral with zero confidence rather than presented as a confident classification.