import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import roc_curve, auc

# Example true labels and predicted probabilities
# Replace these with your actual data
y_true = np.array([0, 0, 1, 1, 0, 1, 0, 1, 1, 0])  # True labels
y_scores = np.array([0.1, 0.4, 0.35, 0.8, 0.7, 0.9, 0.2, 0.65, 0.85, 0.5])  # Predicted probabilities

# Calculate TPR and FPR
fpr, tpr, thresholds = roc_curve(y_true, y_scores)
roc_auc = auc(fpr, tpr)  # Calculate AUC

# Plotting the ROC curve
plt.figure(figsize=(8, 6))
plt.plot(fpr, tpr, color='blue', lw=2, label='ROC curve (AUC = {:.2f})'.format(roc_auc))
plt.plot([0, 1], [0, 1], color='grey', linestyle='--')  # Diagonal line (random chance)
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver Operating Characteristic (ROC) Curve')
plt.legend(loc='lower right')
plt.grid()
plt.show()