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

Please cite us if you use the software

# # Example-5 (Sample weights) # ## Environment check # Checking that the notebook is running on Google Colab or not. # In[1]: import sys try: import google.colab get_ipython().system('{sys.executable} -m pip -q -q install pycm') except: pass # ## Without weights # In[2]: from pycm import ConfusionMatrix y_test = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2] y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2] # In[3]: cm1=ConfusionMatrix(y_test, y_pred) cm1 # In[4]: print(cm1) # ## With random weights # In[5]: from random import randint,seed seed(100) weights = [randint(1, 10) for i in range(len(y_test))] weights[2]*=9 # In[6]: cm2=ConfusionMatrix(y_test, y_pred, sample_weight=weights) cm2 # In[7]: print(cm2) # # #