Menu

Review Length Analysis

Review Length Analysis

Review length is an important feature that can sometimes help identify fake reviews. Fake reviews may be unusually short or excessively long compared to genuine reviews.

We'll calculate the number of words in each review and analyze their distribution.

Calculate Review Length

df['review_length'] = df['clean_review'].apply(lambda x: len(x.split()))

Display the First Few Rows

df[['clean_review', 'review_length']].head()

Plot Review Length Distribution

plt.figure(figsize=(8,5))
plt.hist(df['review_length'], bins=40)
plt.title("Distribution of Review Length")
plt.xlabel("Number of Words")
plt.ylabel("Frequency")
plt.show()

Explanation

The histogram shows how many reviews fall into different word-count ranges.

This visualization helps identify whether the dataset contains unusually long or short reviews.