Menu

Understanding the Distribution of Reviews

Understanding the Distribution of Reviews

Before building a machine learning model, it is useful to understand how the reviews are distributed across different classes. This helps us determine whether the dataset is balanced or imbalanced.

A balanced dataset contains approximately the same number of fake and genuine reviews, which generally leads to better model performance.

Code

df['label'].value_counts()

Visualizing the Distribution

plt.figure(figsize=(6,4))
sns.countplot(x='label', data=df)
plt.title('Distribution of Fake and Genuine Reviews')
plt.xlabel('Review Type')
plt.ylabel('Number of Reviews')
plt.show()

Explanation

The count plot displays the number of reviews belonging to each class.

  • 0 represents Genuine Reviews.
  • 1 represents Fake Reviews.

If both classes have nearly equal counts, the dataset is considered balanced.