Menu

ROC Curve

ROC Curve

The Receiver Operating Characteristic (ROC) Curve evaluates the model's ability to distinguish between fake and genuine reviews across different classification thresholds.

A curve closer to the top-left corner indicates better model performance.

Import Required Functions

from sklearn.metrics import roc_curve

Calculate Prediction Probabilities

y_prob = model.predict_proba(X_test)[:,1]

Compute the ROC Curve

fpr, tpr, thresholds = roc_curve(y_test, y_prob)

Plot the ROC Curve

plt.figure(figsize=(7,6))

plt.plot(fpr, tpr, label='Logistic Regression')

plt.plot([0,1],[0,1],'--')

plt.xlabel("False Positive Rate")

plt.ylabel("True Positive Rate")

plt.title("ROC Curve")

plt.legend()

plt.show()

Explanation

The ROC Curve illustrates the trade-off between the True Positive Rate and the False Positive Rate.

A curve farther away from the diagonal reference line indicates better classification performance.