The problem
Fake Online Review Detection Using TF-IDF and Logistic Regression is a machine-learning project that flags deceptive online reviews by learning the word patterns that separate fabricated reviews from truthful ones. It turns each review into a TF-IDF feature vector of word unigrams and bigrams, then trains a logistic regression classifier on 1,600 labeled hotel reviews to output a fake-or-genuine verdict with a probability score. Shoppers rely on reviews, yet businesses plant phony praise or competitor-bashing reviews that humans spot at barely 61% accuracy, while platforms and customers need a defensible automated signal. Manual auditing does not scale, and rule-based filters miss the linguistic tells. This project answers that gap with a transparent text-classification pipeline: no black box, every verdict is explained by showing which words and phrases pushed the score toward fake or genuine. A live browser demo ships with the project, so the classifier can be tried on any review text and its reasoning inspected word by word.
How it works
The pipeline runs in two phases. In the training phase, 1,600 labeled hotel reviews from the Ott et al. deceptive-opinion-spam corpus are cleaned, tokenized and converted into TF-IDF vectors over word unigrams and bigrams; a logistic regression model then learns a weight for every term, rewarding words that discriminate fake from genuine reviews while downweighting common words. The trained model is evaluated with stratified 5-fold cross-validation, reporting accuracy, precision, recall, F1 and ROC-AUC. In the inference phase, a new review follows the same preprocessing, is vectorized with the fitted vocabulary, and receives a sigmoid probability that becomes the fake-or-genuine verdict with a confidence score. The dashboard breaks that probability down into per-term contributions, so the top words and phrases that pushed the decision are visible as bars. Every step uses standard, auditable components: scikit-learn, TF-IDF vectorization and logistic regression — no black-box model.
- The 1,600 labeled reviews (800 deceptive, 800 genuine) are loaded with their polarity labels and split with stratified 5-fold cross-validation for honest evaluation.
- Text is cleaned and tokenized: lowercasing, punctuation stripping, English stopword removal, then word unigrams and bigrams are extracted.
- A TF-IDF vectorizer is fitted on the training folds, converting each review into a sparse vector where rare, discriminative terms carry the most weight.
- A logistic regression classifier with L2 regularization is trained on the TF-IDF matrix; the regularization strength is chosen by grid search on the training folds.
- The trained model is evaluated on each held-out fold: accuracy, precision, recall, F1, ROC-AUC and the confusion matrix are recorded for the report.
- For a new review, the dashboard applies the identical preprocessing, vectorizes it with the fitted vocabulary, outputs the sigmoid probability as the verdict, and renders the top term contributions as explanation bars.
Tech stack:
- Python 3, scikit-learn (TF-IDF + logistic regression)
- pandas, NumPy (data handling)
- Jupyter Notebook (training & evaluation)
- Matplotlib (metrics and confusion-matrix plots)
- HTML, CSS, JavaScript (ReviewShield browser dashboard)
- Ott et al. deceptive-opinion-spam corpus (Cornell)
Dataset & model details
- Dataset: Deceptive Opinion Spam Corpus (Ott et al., Cornell) — 1,600 hotel reviews across 20 Chicago hotels: 800 deceptive (written by Amazon Mechanical Turk workers) and 800 truthful (sourced from TripAdvisor, Expedia, Hotels.com, Orbitz, Priceline and Yelp), with 400 positive-polarity and 400 negative-polarity reviews in each class.
- Task: Binary text classification; input = raw review text, output = fake/genuine label with a probability score.
- Model: Logistic regression with L2 regularization on TF-IDF vectors over word (1,2)-grams (stopwords removed, sublinear term frequency); the fitted vocabulary and weights are shipped with the project.
- Metrics: Accuracy, precision, recall, F1-score, ROC-AUC and confusion matrix from stratified 5-fold cross-validation. Design target: approximately 85% cross-validation accuracy. Published reference on this corpus: 89.8% with an SVM using bigram + LIWC features (Ott et al.); human judges managed approximately 61% on the same task. No accuracy is claimed as measured until the training run is executed for the order.
| Parameter | Value |
|---|---|
| Task | Binary text classification (fake vs genuine review) |
| Corpus size | 1,600 labeled reviews |
| Class balance | 800 deceptive / 800 genuine; 400 positive + 400 negative polarity per class |
| Corpus coverage | 20 Chicago hotels |
| Features | TF-IDF over word (1,2)-grams; vocabulary approximately 1,000–2,000 terms (corpus-dependent, design target) |
| Model | Logistic regression, L2-regularized |
| Evaluation | Stratified 5-fold cross-validation |
| Accuracy | Approximately 85% cross-validation accuracy (design target, not a measured claim) |
| Metrics reported | Accuracy, precision, recall, F1, ROC-AUC, confusion matrix |
| Inference latency | Single-digit milliseconds per review, measured live by the demo (browser- and machine-dependent) |
| Demo | Single-file HTML/CSS/JS app; runs offline after download |
| Delivery timeline | Approximately 2–3 weeks from order confirmation (expected; depends on customization scope) |
Project features
ReviewShield, the dashboard at the heart of this project, delivers four capabilities that make the classifier genuinely usable rather than a notebook-only experiment. First, paste-a-review analysis: type or paste any review and get an instant fake-or-genuine verdict with a confidence bar, with inference measured live in single-digit milliseconds in the browser. Second, explainable verdicts: every decision is decomposed into the top contributing TF-IDF terms, shown as red and green bars so the exact words and bigrams that pushed the score are visible. Third, corpus statistics and the full training pipeline: the dataset tab documents the 1,600-review Ott et al. corpus with class and polarity breakdowns and walks through the text-to-verdict flow. Fourth, transparent model evaluation: the dashboard trains a real logistic regression in the browser and reports its metrics openly, while the shipped notebook evaluates on the full corpus with cross-validation. Together these turn a text-classification assignment into a project that can be demonstrated, questioned and defended in a viva.
- [Paste-a-review classifier] Paste any review text and get an instant fake-or-genuine verdict with a confidence bar and P(fake) probability; inference time is measured live and displayed for every analysis.
- [Explainable verdict bars] Every decision is decomposed into its top contributing TF-IDF terms, drawn as red (pushes fake) and green (pushes genuine) bars, so the reasoning is inspectable word by word.
- [Live in-browser training] The dashboard trains a real TF-IDF + logistic regression model on an embedded 48-review sample at page load and shows vocabulary size, training time and held-out metrics.
- [Corpus documentation] The dataset tab records the full Ott et al. corpus facts: 1,600 reviews, 800 deceptive / 800 genuine, 400 positive + 400 negative polarity per class, 20 Chicago hotels.
- [Full training notebook] A documented Jupyter notebook covers corpus loading, preprocessing, TF-IDF fitting, logistic regression training with regularization tuning, and stratified 5-fold cross-validation.
- [Metrics and plots] Accuracy, precision, recall, F1, ROC-AUC and a confusion matrix are computed on the full corpus and included with interpretation notes for the report.
- [N-gram comparison study] The notebook repeats the measured (1,1) vs (1,2) vs (1,3) n-gram comparison done during the build, so the feature-range choice is defended with numbers, not intuition.
- [Configurable decision threshold] The classification threshold can be adjusted in code to trade precision against recall, documented with an example for the viva.
What is included
- Complete training and evaluation Jupyter notebook (preprocessing, TF-IDF, logistic regression, grid search, 5-fold CV)
- Trained logistic regression model with the fitted TF-IDF vocabulary and weights
- ReviewShield browser dashboard: paste-a-review analysis, explainable verdict bars, corpus documentation, live training view
- Evaluation report section: accuracy, precision, recall, F1, ROC-AUC, confusion matrix with interpretation notes
- Project report PDF (background, corpus details, methodology, n-gram study, results, limitations)
- PPT presentation for final review
- Viva Q&A preparation document (TF-IDF intuition, logistic regression, regularization, cross-validation, evaluation metrics)
Limitations & prerequisites
- The corpus was written in 2011 by paid crowd workers — modern LLM-generated fake reviews use different language, so performance on today's AI-written spam is expected to be lower and is not covered by the design target.
- Approximately 85% cross-validation accuracy is a design target stated honestly — the report documents the actual achieved figure after the training run.
- Detection is content-based only: no reviewer-behavior signals (reviewer history, posting bursts, account metadata) are used.
- Very short reviews give the classifier few terms to score, so confidence drops on one- or two-line texts.
- The corpus is artificially balanced (800/800); real platforms have far fewer fake reviews, so the operating threshold needs retuning for deployment.
- The browser demo trains on a 48-review embedded sample purely to make the pipeline inspectable — full-corpus results come from the notebook, and the two are labeled separately everywhere.
Frequently Asked Questions
Which dataset is used and why?
The Ott et al. Deceptive Opinion Spam Corpus from Cornell: 1,600 hotel reviews across 20 Chicago hotels — 800 deceptive, written by Amazon Mechanical Turk workers, and 800 truthful, sourced from TripAdvisor and other travel sites, with 400 positive-polarity and 400 negative-polarity reviews in each class. It is the field's gold-standard labeled dataset for this task, so every result is comparable against published work rather than an unverifiable private scrape.
Why TF-IDF and logistic regression instead of deep learning?
Because the problem is genuinely solvable with transparent methods and the corpus is small (1,600 reviews). TF-IDF plus logistic regression is the honest baseline: every verdict can be traced to specific words, training takes seconds, and the viva discussion stays on fundamentals the student can defend. A transformer variant can be added as an optional extension comparing both approaches.
Is the accuracy guaranteed?
No — approximately 85% cross-validation accuracy is a design target, not a promise, and the final figure depends on the train/test splits, preprocessing choices and regularization tuning used in the build. The report documents whatever the training run actually achieves rather than claiming a number up front. For reference, the published best on this corpus is 89.8% (SVM, Ott et al.) and human judges reached only about 61%.
Can it catch AI-generated fake reviews?
Not reliably as shipped: the model learns the language of 2011-era human-written fakes, while LLM-generated spam follows different statistical patterns that this training data never showed it. Catching modern AI-written reviews needs fresh labeled data and retraining, which is documented as future scope in the report rather than claimed as a current capability.
Can this project be customized?
Yes. Realistic customizations include training on a different review domain (product or restaurant reviews) with a supplied labeled dataset, adding a transformer-based comparison model, a batch-upload mode for scanning many reviews at once, or wrapping the classifier in a REST API. Each option is scoped separately with its own timeline and effort estimate.
Is this project suitable for a final-year project?
Yes — for Computer Science, IT and AI/ML programs, where it demonstrates text preprocessing, TF-IDF feature engineering, logistic regression, cross-validation discipline and explainable AI on a real published dataset. The working dashboard demo gives examiners something concrete to interact with, and the viva Q&A document covers every concept the project uses.
Components & software requirements
- Python 3, scikit-learn (TF-IDF + logistic regression)
- pandas, NumPy (data handling)
- Jupyter Notebook (training & evaluation)
- Matplotlib (metrics and confusion-matrix plots)
- HTML, CSS, JavaScript (ReviewShield browser dashboard)
- Ott et al. deceptive-opinion-spam corpus (Cornell)
Dataset & model details
- Dataset: Deceptive Opinion Spam Corpus (Ott et al., Cornell) — 1,600 hotel reviews across 20 Chicago hotels: 800 deceptive (written by Amazon Mechanical Turk workers) and 800 truthful (sourced from TripAdvisor, Expedia, Hotels.com, Orbitz, Priceline and Yelp), with 400 positive-polarity and 400 negative-polarity reviews in each class.
- Task: Binary text classification; input = raw review text, output = fake/genuine label with a probability score.
- Model: Logistic regression with L2 regularization on TF-IDF vectors over word (1,2)-grams (stopwords removed, sublinear term frequency); the fitted vocabulary and weights are shipped with the project.
- Metrics: Accuracy, precision, recall, F1-score, ROC-AUC and confusion matrix from stratified 5-fold cross-validation. Design target: approximately 85% cross-validation accuracy. Published reference on this corpus: 89.8% with an SVM using bigram + LIWC features (Ott et al.); human judges managed approximately 61% on the same task. No accuracy 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 free synopsis (PDF)
Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.