Should we plot a curve for each class?

I am doing a binary classification. I have unbalanced data, and I used the svm weight, trying to mitigate the situation ... As you can see, I calculated and plotted a curve for each class, and I have the following plot: enter image description here It seems that two classes are a little to one .. . and I'm not sure if I am doing the right thing or not, because for the first time for me to draw my own curve curve ... I use Scikit learns to draw ... is it right to build each class separately .. and the classifier cannot classify blue class?

this is the code i used to get the graph:

y_pred = clf.predict_proba(X_test)[:,0] # for calculating the probability of the first class
y_pred2 = clf.predict_proba(X_test)[:,1] # for calculating the probability of the second class
fpr, tpr, thresholds = metrics.roc_curve(y_test, y_pred)
auc=metrics.auc(fpr, tpr)
print "auc for the first class",auc

fpr2, tpr2, thresholds2 = metrics.roc_curve(y_test, y_pred2)
auc2=metrics.auc(fpr2, tpr2)
print "auc for the second class",auc2

# ploting the roc curve
plt.plot(fpr,tpr)
plt.plot(fpr2,tpr2)

plt.xlim([0.0,1.0])
plt.ylim([0.0,1.0])
plt.title('Roc curve')
plt.xlabel('False positive rate')
plt.ylabel('True positive rate')
plt.legend(loc="lower right")
plt.show()

I know there is a better way to write as a dictionary, for example, but I was just trying to see the curve first

+4
3

. Wikipedia ROC:)

predict_proba . , . , . , 1.

roc_curve ,

, .

, , 1. , .

, ( ). .

ROC , ROC . .

- .

predict_proba (1, , 0, , - ).

metrics.roc_curve(y_test, y_pred) , .

predict predict_proba, , . ROC. , - , .

+3

. ROC "", . 0,5 , .

0

, ROC 0 '0' y_test Boolean False .

: fpr, tpr, thresholds = metrics.roc_curve(y_test, y_pred) fpr, tpr, thresholds = metrics.roc_curve(1-y_test, y_pred)

0

Source: https://habr.com/ru/post/1625081/


All Articles