Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. # Listing 18
  2. x3=np.arange(1,51)
  3. y3=np.zeros(50)
  4. y3[25:50]= 1
  5. y3[20:25:2] = 1
  6. y3[25:29:2] = 0
  7.  
  8. x3 = x3.reshape(-1, 1)
  9. clf = linear_model.LogisticRegression(C=1e5, solver='lbfgs')
  10. clf.fit(x3, y3)
  11.  
  12. sigmuid_prob = logistic_mispredict_proba(x3).flatten()
  13. prob = logistic_mispredict_proba(x3_test)
  14.  
  15. plt.scatter(x3, y3, color='black', zorder=10)
  16.  
  17. plt.plot(x3_test, prob, color='red', linewidth=5)
  18. plt.xlabel("x" , fontsize=14)
  19. plt.ylabel("p" , fontsize=14)
  20.  
  21. plt.show()
  22.  
  23. fpr, tpr, threshold = metrics.roc_curve(y3, sigmuid_prob)
  24. roc_auc = metrics.auc(fpr, tpr)
  25.  
  26. plt.plot(fpr, tpr, 'b', label = "AUC = %0.2f" % roc_auc)
  27. plt.legend(loc = "upper left")
  28. plt.plot([0,1],[0,1], 'r--')
  29. plt.xlabel("False Positive Rate" , fontsize=12)
  30. plt.ylabel("True Positive Rate" , fontsize=12)
  31.  
  32. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement