Menu

Testing Multiple Reviews

Testing Multiple Reviews

Instead of testing one review at a time, we can classify multiple reviews simultaneously. This demonstrates how the trained model can be applied to a batch of new customer reviews.

Create Sample Reviews

reviews = [
"Excellent quality product. Highly recommended!",
"Worst purchase ever. Don't buy this.",
"Best product in the world. Buy ten immediately!",
"The delivery was quick and the packaging was neat.",
"Absolutely fantastic. Five stars for everything!"
]

Preprocess the Reviews

processed_reviews = []
for review in reviews:
review = clean_text(review)
review = remove_stopwords(review)
review = lemmatize_text(review)
processed_reviews.append(review)

Convert to TF-IDF

review_vectors = tfidf.transform(processed_reviews)

Predict the Labels

predictions = model.predict(review_vectors)

Display the Predictions

results = pd.DataFrame({

"Review": reviews,

"Prediction": predictions

})

results["Prediction"] = results["Prediction"].replace({

0: "Genuine",

1: "Fake"

})

results