Advertisement
Guest User

ROC plot

a guest
Jan 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. def plotROC(X_train_res, y_train_res, X_test, y_test):
  2.     cl = MultinomialNB()
  3.     cl.fit(X_train_res, y_train_res)
  4.     res = cl.predict_proba(X_test)
  5.  
  6.  
  7.  
  8.     x = np.transpose(res)[0]
  9.     rc = roc_curve(y_test, x)
  10.     print(y_test[:5])
  11.     print(x[:5])
  12.     aucl = auc(rc[0], rc[1])
  13.  
  14.  
  15.  
  16.     lw=2
  17.     plt.plot(rc[0],rc[1], color='darkorange',
  18.                         lw=lw, label='ROC curve (area = %0.2f)' % aucl)
  19.     #plt.plot(rc2[0],rc2[1], color='deeppink',
  20.     #                    lw=lw, label='ROC curve (area = %0.2f)' % aucl)
  21.     plt.plot([0, 1], [0, 1], color='navy', lw=lw, linestyle='--')
  22.     plt.xlim([0.0, 1.0])
  23.     plt.ylim([0.0, 1.05])
  24.     plt.xlabel('False Positive Rate')
  25.     plt.ylabel('True Positive Rate')
  26.     plt.title('Receiver operating characteristic example')
  27.     plt.legend(loc="lower right")
  28.     plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement