Built to order

Disaster Tweet Classification using NLP

This project teaches a machine to read a tweet and decide whether it reports a real disaster — the hard part being figurative language like "this album is fire" or "dying of boredom." It trains on 7,613 human-labeled tweets from the public disaster-tweets dataset, starting from a TF-IDF baseline and fine-tuning DistilBERT for the final model. A live demo lets you type any tweet and watch the classifier's verdict with the exact words that pushed it toward — or away from — "disaster." Suitable for B.E./B.Tech final-year projects in AI & Machine Learning, Computer Science and IT.

Disaster Tweet Classification using NLP — project thumbnail preview
More project photos (2)

The problem

During a real disaster, Twitter fills with a mix of genuine incident reports ("forest fire near La Ronge, evacuations ordered") and figurative noise ("this traffic is a nightmare, I'm going to die"). Emergency responders want the first kind and not the second — and keyword matching fails spectacularly, because the word "fire" appears in both. This project solves it as a binary text-classification problem on the public "Natural Language Processing with Disaster Tweets" dataset: 7,613 human-labeled training tweets plus 3,263 test tweets. The project builds up in honest stages — a TF-IDF plus logistic-regression baseline that shows what linear models can and cannot do, then a fine-tuned DistilBERT that learns context ("fire" next to "album" vs next to "evacuation"), with the F1 improvement documented and explained for the viva.

How it works

  1. The 7,613 labeled tweets are cleaned (URLs, mentions and hashtags normalized; text lowercased) and split with stratification.
  2. The baseline converts tweets to TF-IDF vectors and trains logistic regression, establishing the score to beat.
  3. DistilBERT is fine-tuned for 3–4 epochs with a classification head, using the pretrained tokenizer and a learning-rate schedule.
  4. Both models are evaluated on the held-out set with accuracy, precision, recall and F1; the confusion matrix and error cases go into the report.
  5. Figurative-language probes ("this album is fire") verify the transformer handles what the baseline gets wrong.
  6. In the demo, a typed tweet is tokenized and passed through the saved model; the app shows the verdict, confidence and token-level cue highlights.

Tech stack:

  • Python 3, PyTorch, Hugging Face Transformers
  • DistilBERT (fine-tuned)
  • scikit-learn (TF-IDF baseline, metrics)
  • Pandas, NumPy
  • Jupyter Notebook (training & evaluation)
  • HTML5 + JavaScript (live demo)
  • Disaster-tweets dataset (Kaggle / Figure Eight labels)

Dataset & model details

  • Dataset: "Natural Language Processing with Disaster Tweets" — 7,613 human-labeled training tweets and 3,263 test tweets, binary labels (real disaster vs not), labels collected via Figure Eight; released as a public Kaggle competition dataset.
  • Task: Binary text classification; input = raw tweet text (≤ 280 chars), output = P(disaster).
  • Model: DistilBERT-base fine-tuned with a sequence-classification head (3 epochs, AdamW, linear warmup); TF-IDF + logistic regression as the documented baseline.
  • Metrics: F1 ≥ 0.79 on the held-out set (design target for the built-to-order fine-tuning run), plus precision/recall and accuracy. Competition-grade DistilBERT baselines report F1 around 0.79–0.82 in public notebooks; no figure is claimed as measured until the training run is executed for the order.
Parameter Value
Input Raw tweet text (max 280 chars)
Output P(disaster), binary decision
Training tweets 7,613 labeled
F1 score ≥ 0.79 (design target, not a measured claim)
Fine-tuning time Approximately 15–30 min on a free GPU (expected)
Inference Approximately 30 ms per tweet on CPU (expected)
Model files Approximately 260 MB (DistilBERT weights + tokenizer, expected)
Demo Single-file web app, runs offline after download

Project features

  • [DistilBERT fine-tuned classifier] Transformer model fine-tuned on the disaster-tweet labels, learning contextual cues instead of keyword lists.
  • [Honest baseline first] TF-IDF + logistic regression baseline with error analysis, so the report shows exactly what the transformer buys over classical NLP.
  • [Live tweet demo] Type or pick any tweet; the app returns disaster/not-disaster with confidence and highlights the words that drove the decision.
  • [Figurative-language handling] The demo and report specifically address the hard cases — "fire," "blast," "die," "crash" used figuratively — with before/after examples.
  • [Full training notebooks] Preprocessing, tokenization, baseline training, DistilBERT fine-tuning and evaluation in reproducible Jupyter notebooks.
  • [Error analysis] Misclassified tweets reviewed and categorized (sarcasm, ambiguous reports, label noise) for a genuinely interesting report section.
  • [Exported model] Fine-tuned weights plus tokenizer, so the demo classifies new tweets without retraining.

What is included

  • Baseline + fine-tuning Jupyter notebooks
  • Fine-tuned DistilBERT weights and tokenizer
  • Live tweet-classification web demo
  • Evaluation tables, confusion matrix, error-analysis section
  • Project report PDF (background, NLP concepts, transformer theory, methodology, results)
  • PPT presentation for final review
  • Viva Q&A preparation document (tokenization, TF-IDF, attention, fine-tuning, F1 vs accuracy)

Limitations & prerequisites

  • Tweets are short, noisy and English-only in this dataset — multilingual or long-form posts are out of scope.
  • Sarcasm and genuinely ambiguous reports still fool the model; the error analysis documents these honestly.
  • F1 ≥ 0.79 is a design target for the fine-tuning run, stated honestly — the report documents the actual achieved figure after training.
  • The demo's in-browser classifier is a compact illustration of the pipeline; the full fine-tuned DistilBERT ships separately.
  • Label noise exists in crowdsourced labels — noted as a bound on achievable performance.

Frequently Asked Questions

Which dataset is used and why?

The public disaster-tweets dataset — 7,613 human-labeled training tweets. It is the standard benchmark for this exact problem, and its labels capture the figurative-vs-real distinction that makes the task interesting.

Why is this harder than keyword matching?

Because "fire," "blast," "die" and "crash" appear in both real reports and figurative tweets. A keyword list cannot tell "forest fire, evacuations ordered" from "this album is fire" — the model must learn context.

What does DistilBERT add over the baseline?

The TF-IDF baseline sees word counts; DistilBERT sees word order and context, so "fire" next to "album" and "fire" next to "evacuation" get different representations. The report quantifies the F1 gap.

How does the demo highlight cues?

Disaster-leaning words and figurative/safe words are highlighted in different colors, with the running score shown — making the classifier's reasoning visible instead of a black box.

Can it monitor a live Twitter feed?

The classifier is the right core for it, but live ingestion needs API access, rate-limit handling and a streaming pipeline — listed as future scope, not included.

Is this project suitable for a final-year project?

Yes — for AI & Machine Learning, Computer Science and IT programs. It covers classical NLP, transformer fine-tuning, honest baseline comparison and a genuinely fun live demo. Suitable for B.E./B.Tech final-year projects in AI & Machine Learning, Computer Science and IT.

Components & software requirements
  • Python 3, PyTorch, Hugging Face Transformers
  • DistilBERT (fine-tuned)
  • scikit-learn (TF-IDF baseline, metrics)
  • Pandas, NumPy
  • Jupyter Notebook (training & evaluation)
  • HTML5 + JavaScript (live demo)
  • Disaster-tweets dataset (Kaggle / Figure Eight labels)

Dataset & model details

  • Dataset: "Natural Language Processing with Disaster Tweets" — 7,613 human-labeled training tweets and 3,263 test tweets, binary labels (real disaster vs not), labels collected via Figure Eight; released as a public Kaggle competition dataset.
  • Task: Binary text classification; input = raw tweet text (≤ 280 chars), output = P(disaster).
  • Model: DistilBERT-base fine-tuned with a sequence-classification head (3 epochs, AdamW, linear warmup); TF-IDF + logistic regression as the documented baseline.
  • Metrics: F1 ≥ 0.79 on the held-out set (design target for the built-to-order fine-tuning run), plus precision/recall and accuracy. Competition-grade DistilBERT baselines report F1 around 0.79–0.82 in public notebooks; no figure is claimed as measured until the training run is executed for the order.
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download abstract (PDF)

Related guides

All guides
Illustration of object tracking showing video frames with bounding boxes and persistent ID labels following people and vehicles, comparing motion prediction and appearance matching.B.E./B.Tech Computer Science and Electronics students building video analytics projects — people counting, vehicle tracking, sports analysis — who have detection working and need

Object Tracking: DeepSORT and ByteTrack Explained

Detection finds objects per frame; tracking keeps their identities across frames. This guide explains tracking-by-detection, Kalman motion models, DeepSORT's appearance embeddings vs ByteTrack's low-confidence box recovery, tracking metrics (HOTA, IDF1, ID switches), and the tuning parameters that determine real-world quality.

Read guide
Illustration of image segmentation showing U-Net's U-shaped encoder-decoder with skip connections producing pixel masks, alongside Mask R-CNN detecting instances with masks.B.E./B.Tech Computer Science and AI/ML students moving from image classification or detection to pixel-level understanding — medical imaging, defect detection, autonomous driving

Image Segmentation: U-Net and Mask R-CNN

When projects need pixel-level answers, segmentation delivers. This guide explains semantic vs instance vs panoptic segmentation, U-Net's encoder-decoder with skip connections, Mask R-CNN's parallel mask head, Dice and IoU evaluation, paired augmentation, and how to choose the right architecture for your data and question.

Read guide
Illustration of Whisper speech-to-text showing sound waves flowing into a neural network and emerging as transcribed text with timestamps and speaker labels.B.E./B.Tech Computer Science and AI/ML students adding speech-to-text to projects — voice assistants, meeting transcription, accessibility tools

Whisper for Speech-to-Text in Student Projects

Whisper transcribes speech in dozens of languages with no training required. This guide covers how it works, choosing among model sizes, running it locally with faster-whisper, handling hour-long audio, timestamps and speaker diarization, multilingual quirks, and honest evaluation with word error rate.

Read guide
Get a quotation