The problem
Online reviews drive purchasing decisions, and that makes them a target: sellers post glowing fake reviews of their own products, competitors post damning ones. Humans are notoriously bad at spotting the fakes — in the Cornell studies behind this project, human judges barely beat chance. That is what makes opinion-spam detection a strong academic problem: it is a real integrity issue for every review platform, and it is solvable only by learning subtle linguistic patterns no human would enumerate by hand. The classic benchmark is Ott et al.'s Deceptive Opinion Spam Corpus (ACL 2011): 1,600 Chicago hotel reviews, half truthful (scraped from TripAdvisor) and half deceptive (written by paid Mechanical Turk workers asked to fabricate). This project trains a two-layer LSTM classifier on that corpus. Unlike bag-of-words models that merely count words, the LSTM reads the review in order, so "not the best hotel" and "the best hotel, not" score differently — sequence genuinely matters for deception. The demo app pairs each verdict with word-level highlighting, turning the model's reasoning into something a viva examiner can see and question. The report is honest about the boundary: a model trained on hotel reviews cannot be trusted on product reviews or other languages without retraining.
How it works
- The 1,600 reviews are loaded with their truthful/deceptive labels and split 80/10/10 with stratification over sentiment and label.
- Text is lowercased, tokenized and padded to 400 tokens; a ~20k-word vocabulary is built from the training split.
- Word indices map to learned 128-d embeddings, which feed two stacked 64-unit LSTM layers with 0.4 dropout.
- The final hidden state passes through a dense sigmoid layer; binary cross-entropy loss is minimized with Adam.
- Early stopping on validation F1 prevents overfitting to the small corpus; the best checkpoint is kept.
- At inference the demo app tokenizes a pasted review, runs it through the network, and renders the verdict with word-level highlighting and cue counts.
Tech stack:
- Python 3.10, TensorFlow/Keras (LSTM model, training loop)
- NLTK (tokenization, stopwords, linguistic cue extraction)
- scikit-learn (TF-IDF baseline, metrics, confusion matrix)
- NumPy, pandas (corpus loading, split management)
- Matplotlib, Seaborn (training curves, length distributions, confusion matrix)
- Jupyter notebook (buyer-run training and evaluation)
- Flask demo app with verdict highlighting and corpus explorer
- Deceptive Opinion Spam Corpus (Ott et al., ACL 2011 — 1,600 hotel reviews)
| Parameter | Value |
|---|---|
| Model | 2-layer LSTM (64 units each, dropout 0.4) over 128-d learned embeddings; dense sigmoid output |
| Dataset | Deceptive Opinion Spam Corpus (Ott et al., ACL 2011): 1,600 reviews — 800 truthful (TripAdvisor), 800 deceptive (Mechanical Turk), 20 Chicago hotels |
| Preprocessing | Lowercase, tokenize, max 400 tokens, ~20k vocabulary from training split |
| Training | Binary cross-entropy, Adam (lr 1e-3), early stopping on validation F1; design target ≈ 88–90% accuracy on the held-out split |
| Evaluation | Accuracy, precision, recall, F1, confusion matrix — computed by the notebook on your build's held-out split |
| Baseline | TF-IDF + logistic regression in the same notebook for the LSTM-vs-bag-of-words comparison |
| Input | Raw review text (pasted or selected from the sample library) |
| Output | Verdict (deceptive/truthful) with confidence, word-level highlighting, linguistic cue counts |
Project features
- [Two-layer LSTM classifier] 64-unit LSTM layers with dropout over learned 128-d word embeddings; dense sigmoid output for P(deceptive).
- [Deceptive Opinion Spam Corpus pipeline] Loader for the 1,600-review corpus with stratified 80/10/10 splits preserving the truthful/deceptive and positive/negative balance.
- [Word-level verdict highlighting] The demo colors each word by its contribution — deceptive cues, truthful anchors, stylistic flags — so every prediction is explainable.
- [Linguistic cue dashboard] Live counts of first-person pronouns, superlatives, exclamation marks and concrete spatial details for the analyzed review.
- [Corpus explorer view] Class balance, review-length distributions and browsable labeled reviews from the dataset, for the report's data-analysis section.
- [Full evaluation notebook] Accuracy, precision, recall, F1 and confusion matrix computed on the held-out split every epoch; design target ≈ 88–90% accuracy.
- [Sequence-vs-bag-of-words comparison] A TF-IDF + logistic regression baseline in the notebook, so the report can show what the LSTM's word order actually buys.
- [Sample review library] Curated truthful and deceptive examples preloaded in the demo for quick testing and viva demonstrations.
What is included
- Complete source code (corpus loader, LSTM model, training loop, TF-IDF baseline, demo app)
- Jupyter training and evaluation notebook (buyer-run procedure: load corpus, train, evaluate, compare with baseline)
- Project report PDF (background, Ott et al. study, architecture, evaluation, error analysis, honesty limits)
- PPT presentation for final review
- Viva Q&A preparation document (LSTM vs bag-of-words, why word order matters, overfitting on small corpora, corpus limitations)
- Setup guide (environment, corpus download, training your own model, running the demo)
Limitations & prerequisites
- The corpus is hotel-only and US-English: the model cannot be trusted on product reviews, other domains, or other languages without retraining.
- The "deceptive" reviews were elicited from paid writers, not caught in the wild — real-world spam operations may write differently.
- With only 1,600 reviews, the model can overfit; the notebook's early stopping and dropout are load-bearing, not optional.
- Very short reviews carry too little linguistic signal for a reliable verdict, and the demo says so rather than guessing confidently.
- Reported accuracy is a design target for your build — the notebook computes your build's real numbers on the held-out split.
Frequently Asked Questions
Which dataset is used?
The Deceptive Opinion Spam Corpus (Ott, Choi, Cardie & Hancock, ACL 2011): 1,600 Chicago hotel reviews — 800 truthful from TripAdvisor, 800 deceptive written by Mechanical Turk workers, balanced across positive and negative sentiment.
Why an LSTM instead of a simpler classifier?
Bag-of-words models count words; the LSTM reads them in order, so negation and word order affect the score. The notebook trains a TF-IDF baseline too, so the report measures exactly what sequence modeling adds.
Is the accuracy guaranteed?
No. ≈ 88–90% is the design target (the corpus's classic SVM baseline is ~89%); your build's actual metrics come from the training notebook's held-out evaluation.
Can it detect fake Amazon or Flipkart reviews?
Not reliably — it was trained on hotel reviews. The report states this boundary explicitly, and retraining on product-review data is documented as future scope.
How does the word highlighting work?
Each token is scored by cue lexicons (first-person pronouns, superlatives, concrete detail words) combined with the model's learned signal, showing which words pushed the verdict toward deceptive or truthful.
Is this project suitable for a final-year project?
Yes — it covers NLP preprocessing, sequence modeling, the deception-detection literature, and honest evaluation, and suits Computer Science, AI/ML and Data Science students. Suitable for B.E./B.Tech final-year projects in Computer Science, AI/ML and Data Science.
Components & software requirements
- Python 3.10, TensorFlow/Keras (LSTM model, training loop)
- NLTK (tokenization, stopwords, linguistic cue extraction)
- scikit-learn (TF-IDF baseline, metrics, confusion matrix)
- NumPy, pandas (corpus loading, split management)
- Matplotlib, Seaborn (training curves, length distributions, confusion matrix)
- Jupyter notebook (buyer-run training and evaluation)
- Flask demo app with verdict highlighting and corpus explorer
- Deceptive Opinion Spam Corpus (Ott et al., ACL 2011 — 1,600 hotel reviews)
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.