Feature Importance
One advantage of Logistic Regression is that it assigns a coefficient to each feature (word). Words with larger coefficients have a greater influence on the prediction.
By examining these coefficients, we can identify which words contribute most strongly to classifying reviews as fake or genuine.
Get Feature Names
feature_names = tfidf.get_feature_names_out()
Extract Model Coefficients
coefficients = model.coef_[0]
Create a DataFrame
importance = pd.DataFrame({
"Word": feature_names,
"Coefficient": coefficients
})
Top Words Associated with Fake Reviews
importance.sort_values(
by="Coefficient",
ascending=False
).head(20)
Top Words Associated with Genuine Reviews
importance.sort_values(
by="Coefficient",
ascending=True
).head(20)
Explanation
Positive coefficients indicate words that are more strongly associated with fake reviews, while negative coefficients indicate words more commonly associated with genuine reviews.
Examining feature importance helps us understand how the model makes its predictions and can provide valuable insights into linguistic patterns within the dataset.









