roc curve sklearn
from sklearn.svm import SVC # Train the support vector machine classifier svm = SVC(kernel='rbf', probability=True, random_state=42) svm.fit(X_train_scaled, y_train) # Calculate the predicted probabilities y_pred_proba = svm.predict_proba(X_test_scaled)[:, 1] # Compute the ROC curve fpr, tpr, thresholds = roc_curve(y_test, y_pred_proba) roc_auc = auc(fpr, tpr) # Plot the ROC curve plt.figure() plt.plot(fpr, tpr, color='darkorange', lw=2, label=f'ROC curve (area = {roc_auc:.2f})') plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--') 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.show()