Menu

Making Predictions

Making Predictions

After training, we use the testing dataset to evaluate how well the model performs on unseen data.

The predict() method generates predictions for each review in the testing set.

Predict the Labels

y_pred = model.predict(X_test)

View the First Few Predictions

print(y_pred[:10])

Compare Actual and Predicted Labels

comparison = pd.DataFrame({
"Actual": y_test.values,
"Predicted": y_pred
})
comparison.head(10)

Explanation

This comparison allows us to see whether the model correctly classified each review.

  • Actual → True label from the dataset.
  • Predicted → Label predicted by the model.