-1
$\begingroup$

I am new to ML. I have a question so I am evaluating my SVM model.

Example:

SVM_MODEL = svm.SVC() 
SVM_MODEL.fit(X_train,y_train) 
SVM_OUTPUT = SVM_MODEL.predict(X_test)

And I want to plot my roc curve and AUC value for it is this the correct code?

fpr1, tpr1, thresholds = metrics.roc_curve(y_valid, SVM_OUTPUT, pos_label=0)
plt.ylabel(“True Positive Rate”)
plt.xlabel(“False Positive Rate”)
plt.title(“ROC Curve”)
plt.plot(tpr1,fpr1)
plt.show()
auc = np.trapz(fpr1,tpr1)
print(‘Area Under ROC Curve:’, auc)
$\endgroup$
0
$\begingroup$

If you already know sklearn then you should use this.

from sklearn.metrics import plot_precision_recall_curve
from sklearn.metrics import plot_roc_curve

Documentation for you.

Regarding the AUC, it will be shown on the graph automatically.

AUC curve

$\endgroup$
  • $\begingroup$ Hello, Thank you so much for sharing. One last question that is this how we plot roc curve plt.plot(tpr1,fpr1) ? First, we pass true positive rates and then false positive? $\endgroup$ – harshini sewani Nov 24 '20 at 0:20
  • $\begingroup$ I gave you exactly how you plot it with an example just click on the link and read the first sentence. plot_roc_curve(model,X_test,y_test) it cant get any easier. $\endgroup$ – ombk Nov 24 '20 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.