#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Use AI to Detect Fake Reviews in E-Commerce Websites

To detect fake reviews with AI, an e-commerce site combines three kinds of evidence: behaviour signals (unverified purchases, bursts of reviews from one account, new accounts), text signals (copied or templated wording, which a trained classifier or language model can spot) and network signals (groups of accounts that keep reviewing the same products). Each review gets a risk score, high-risk reviews are held or sent to a human moderator, and the model is retrained on the moderators' decisions. This guide shows how each layer works, with Python you can run.

Build an Expense-Sharing App for Groups and Friends

What counts as a fake review

A fake review is one that does not reflect a genuine customer's experience. Common types are paid five-star reviews, reviews written by the seller or their staff, one-star attacks on a competitor, reviews in exchange for refunds or gifts that are not disclosed, and reviews copied from another product. Regulators treat this seriously: the US Federal Trade Commission finalised a rule banning fake reviews and testimonials in 2024, and in India the Bureau of Indian Standards published IS 19000:2022, a standard for how platforms collect, moderate and publish online consumer reviews.

Layer 1: behaviour signals

Behaviour is often more reliable than text, because a fraudster can rewrite words easily but finds it harder to fake a purchase history. Useful signals:

SignalWhy it matters
Verified purchaseReviews without an order behind them carry more risk.
Account age and historyA new account whose only activity is five-star reviews is suspicious.
BurstsMany reviews for one product, or from one account, within hours.
Rating deviationRatings far from the product's long-run average, especially in a burst.
Shared devices, IPs or payment detailsSeveral "different" reviewers using the same device or card.

Here is a small, runnable example that turns some of these into a simple risk score with pandas:

import pandas as pd

reviews = pd.DataFrame({
    "review_id": [1, 2, 3, 4, 5, 6],
    "user": ["u1", "u2", "u3", "u3", "u4", "u5"],
    "rating": [4, 5, 5, 5, 2, 4],
    "verified": [True, False, False, False, True, True],
    "date": ["2026-03-01", "2026-03-02", "2026-03-02", "2026-03-02", "2026-03-05", "2026-03-09"],
    "text": [
        "Battery lasts two days, camera is average in low light.",
        "Best product ever!!! Must buy!!!",
        "Best product ever!!! Must buy!!!",
        "Amazing amazing amazing, buy now",
        "Stopped charging after a week, replacement took 10 days.",
        "Good value, a bit heavy for one-hand use.",
    ],
})

reviews["dup_text"] = reviews.duplicated("text", keep=False).astype(int)
reviews["burst"] = (reviews.groupby(["user", "date"])["review_id"].transform("count") > 1).astype(int)
reviews["shouty"] = (reviews["text"].str.count("!") >= 3).astype(int)
reviews["unverified"] = (~reviews["verified"]).astype(int)
reviews["score"] = reviews[["dup_text", "burst", "shouty", "unverified"]].sum(axis=1)

print(reviews["score"].tolist())
print(reviews.loc[reviews["score"] >= 2, "review_id"].tolist())

Output:

[0, 3, 4, 2, 0, 0]
[2, 3, 4]

Reviews 2 and 3 share identical text, are unverified and use heavy exclamation marks; review 4 comes from the same account on the same day. In production these rules become features for a model rather than a fixed score, because hand-set weights are easy to game.

Layer 2: text signals

Near-duplicate detection

Paid reviewers often reuse a template with small changes. Convert each review to a TF-IDF vector or a sentence embedding and flag pairs with very high cosine similarity across different accounts or products.

A supervised classifier

If you have reviews labelled genuine or fake (from past moderation, or a research dataset such as the Deceptive Opinion Spam corpus of hotel reviews by Ott and colleagues), a simple baseline is TF-IDF plus logistic regression with scikit-learn:

from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
from sklearn.pipeline import make_pipeline

# texts: list of review strings, labels: 1 = fake, 0 = genuine
X_train, X_test, y_train, y_test = train_test_split(
    texts, labels, test_size=0.2, stratify=labels, random_state=42)

model = make_pipeline(
    TfidfVectorizer(ngram_range=(1, 2), min_df=2, sublinear_tf=True),
    LogisticRegression(max_iter=1000, class_weight="balanced"),
)
model.fit(X_train, y_train)
print(classification_report(y_test, model.predict(X_test)))

risk = model.predict_proba(["Best product ever!!! Must buy!!!"])[0, 1]

Text models trained on one domain (hotels) transfer poorly to another (phone accessories), so retrain on your own catalogue. Fine-tuned transformer models usually beat TF-IDF, at higher cost.

LLM review

A large language model can read a flagged review with its context (product, reviewer history) and explain why it looks genuine or not, which speeds up human moderators. It should assist the moderator, not make the final call, because LLMs cannot verify a purchase and can be fooled by well-written fakes.

Layer 3: network signals

Organised fraud shows up as groups. Build a graph with reviewers and products as nodes and reviews as edges. Groups of accounts that review the same set of products within days of each other form dense clusters, which community-detection or graph neural network methods can find even when each single review looks normal.

Putting it together

  1. Score each new review with a model that combines behaviour, text and network features.
  2. Act by risk band: publish low-risk reviews, hold medium-risk ones for moderation, block very high-risk ones.
  3. Review and appeal: give sellers and customers a way to contest a removal.
  4. Retrain on moderator decisions so the model follows new tactics.
  5. Measure precision as well as recall. Removing genuine negative reviews damages customer trust and may break consumer rules.

FAQs

Can AI detect every fake review?

No. A careful fraudster with a real purchase and natural wording is hard to catch. AI raises the cost of faking reviews and catches patterns at scale; human moderation handles the hard cases.

What data do I need to start?

Review text, rating, timestamp, reviewer ID, whether the purchase is verified and, ideally, a few hundred reviews labelled by moderators.

Is a sentiment model enough?

No. Sentiment tells you whether a review is positive or negative, not whether it is genuine. It is one feature among many.

To build the text side, start with a sentiment analysis tool in Python and a customer sentiment tracker with NLP. The main Python libraries for machine learning covers the tools used above, and the CRISP-DM process is a good way to plan the project.

Placed Students

Our Clients

Partners

...