#!/usr/bin/env python # coding: utf-8 #

Please cite us if you use the software

# # Example-3 (Activation threshold) # ## Binary classification # In[1]: from pycm import ConfusionMatrix def activation1(i): if i<0.75: return 1 else: return 0 # In[2]: y_actual = [1,1,0,1,1,0] y_pred = [0.65,0.34,0.80,0.54,0.32,0.12] # In[3]: cm = ConfusionMatrix(y_actual,y_pred,threshold=activation1) cm.classes # In[4]: print(cm) # ## Multiclass classification # In[5]: def activation2(i): ref = ["cat","dog","ship"] return ref[i.index(max(i))] # In[6]: y_actual = ["ship","cat","dog","cat","dog","ship"] y_pred = [[90,433,600],[345,100,2],[100,90,10],[432,102,80],[156,402,2],[73,20,532]] # In[7]: cm2 = ConfusionMatrix(y_actual,y_pred,threshold=activation2) cm2.classes # In[8]: print(cm2)