Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

true positive true negative manually

# True Positive (TP): we predict a label of 1 (positive), and the true label is 1.
TP = np.sum(np.logical_and(pred_labels == 1, true_labels == 1))
 
# True Negative (TN): we predict a label of 0 (negative), and the true label is 0.
TN = np.sum(np.logical_and(pred_labels == 0, true_labels == 0))
 
# False Positive (FP): we predict a label of 1 (positive), but the true label is 0.
FP = np.sum(np.logical_and(pred_labels == 1, true_labels == 0))
 
# False Negative (FN): we predict a label of 0 (negative), but the true label is 1.
FN = np.sum(np.logical_and(pred_labels == 0, true_labels == 1))
 
print 'TP: %i, FP: %i, TN: %i, FN: %i' % (TP,FP,TN,FN)
Comment

PREVIOUS NEXT
Code Example
Python :: How to Get the Difference Between Sets in Python 
Python :: pandas drop duplicates from column 
Python :: python regex match words 
Python :: negative index in python list 
Python :: discord.py embeds 
Python :: python bool to string 
Python :: python create list from range 
Python :: procfile heroku python example 
Python :: are tuples mutable 
Python :: removexa0 python 
Python :: python Program to check if a given year is leap year 
Python :: python capture desktop as video source 
Python :: feature scaling in python 
Python :: open and read a file in python 
Python :: remove specific word from string using python 
Python :: sort rows in csv file using python pandas 
Python :: Reverse an string Using Recursion in Python 
Python :: merge two dictionaries in a single expression 
Python :: django group by 
Python :: python get file path from in os.walk 
Python :: python how to convert csv to array 
Python :: python remove string from string 
Python :: make entry bigger in tkinter python 
Python :: pandas replace row values based on condition 
Python :: fillna with mode pandas 
Python :: python check if class has function 
Python :: convert price to float python 
Python :: standard scaler vs min max scaler 
Python :: python kivy 
Python :: discord.py fetch channel 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =