Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

plotting roc curve

# Import necessary modules
from sklearn.metrics import roc_curve

# Compute predicted probabilities: y_pred_prob
y_pred_prob = logreg.predict_proba(X_test)[:,1]

# Generate ROC curve values: fpr, tpr, thresholds
fpr, tpr, thresholds = roc_curve(y_test, y_pred_prob)

# Plot ROC curve
plt.plot([0, 1], [0, 1], 'k--')
plt.plot(fpr, tpr)
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('ROC Curve')
plt.show()
Comment

roc curve

# Import roc_curve
from sklearn.metrics import roc_curve

# Generate ROC curve values: fpr, tpr, thresholds
fpr, tpr, thresholds = roc_curve(y_test, y_pred_probs)

plt.plot([0, 1], [0, 1], 'k--')

# Plot tpr against fpr
plt.plot(fpr, tpr)
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('ROC Curve for Diabetes Prediction')
plt.show()
Comment

roc curve

y_pred_logreg_proba = classifier_logreg.predict_proba(X_test)
from sklearn.metrics import roc_curve
fpr, tpr, thresholds = roc_curve(y_test, y_pred_logreg_proba[:,1])
plt.figure(figsize=(6,4))
plt.plot(fpr,tpr,'-g',linewidth=1)
plt.plot([0,1], [0,1], 'k--' )
plt.title('ROC curve for Logistic Regression Model')
plt.xlabel("False Positive Rate")
plt.ylabel('True Positive Rate')
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: datetime conversion 
Python :: python modulo 
Python :: python docstring 
Python :: simple python program for beginners 
Python :: what is a python module 
Python :: check for null values in rows pyspark 
Python :: python built in libraries 
Python :: how to run python on ios 
Python :: change the format of date in python 
Python :: append element to list py 
Python :: how to store categorical variables in separate dataframe 
Python :: how to define a dictionary in python 
Python :: python calling method from constructor 
Python :: google youtuve api 
Python :: create dictionary without removing duplicates from dataframe 
Python :: extend list pyton 
Python :: pandas drop columns 
Python :: Syntax of Python Frozenset 
Python :: python list copy 
Python :: random generator python 
Python :: subarrays in python 
Python :: python logical operators code 
Python :: how to activate venv python 
Python :: prompt python 
Python :: string length python 
Python :: how to install python 
Python :: search object in array python 
Python :: Sys Gets os name ,which u using 
Python :: numpy.empty sorce code 
Python :: python mark function as no return 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =