Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

True Positive, True Negative, False Positive, False Negative in scikit learn

#According to scikit-learn documentation,

#http://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html#sklearn.metrics.confusion_matrix

#By definition a confusion matrix C is such that C[i, j] is equal to the number of observations known to be in group i but predicted to be in group j.

#Thus in binary classification, the count of true negatives is C[0,0], false negatives is C[1,0], true positives is C[1,1] and false positives is C[0,1].

CM = confusion_matrix(y_true, y_pred)

TN = CM[0][0]
FN = CM[1][0]
TP = CM[1][1]
FP = CM[0][1]
Comment

PREVIOUS NEXT
Code Example
Python :: Python update to beginning of dictionary 
Python :: every substring python 
Python :: pydub create empty track 
Python :: sns prevent legend 
Python :: convert pdf to excel python 
Python :: dataframe concatenate 
Python :: how to chose version of python 
Python :: how to make bak files with python 
Python :: access icloud doc on jupyter notebook 
Python :: what are postcondition errors in python 
Python :: call python from bash shell 
Python :: cv2 remove black borders on images 
Python :: python sort() and sorted() 
Python :: scipy.optimize.curve_fit 3D 
Python :: add space before and after string python 
Python ::  
Python :: sorted set in python 
Python :: python indian currency formatter 
Python :: subprocess the system cannot find the file specifie 
Python :: how to save string json to json object python 
Python :: Getting the first element from each list in a column of lists 
Python :: flask get request port 
Python :: numpy sort multidimensional array 
Python :: pyqt5 app styles 
Python ::  
Python :: convert file dta in csv 
Python :: python - subtracting dictionary values 
Python :: check if element is in list 
Python :: compiling python code 
Python ::  
ADD CONTENT
Topic
Content
Source link
Name
7+3 =