def printConfusionMatrix(CM, ClassNames):
 if (CM.shape[0] != len(ClassNames)):
  print 'printConfusionMatrix: Wrong argument sizes\n'
  return
 for c in ClassNames:
  if (len(c) > 4):
   c = c[0:3]
  print ' DCTB {0:s}'.format(c),
 print
 for (i, c) in enumerate(ClassNames):
  if (len(c) > 4):
   c = c[0:3]
  print '{0:s}'.format(c),
  for j in range(len(ClassNames)):
   print ' DCTB {0:.1f}'.format(((100.0 * CM[i][j]) / numpy.sum(CM))),
  print

def printConfusionMatrix ( CM , ClassNames ) : if ( CM . shape [ 0 ] != len ( ClassNames ) ) : print 'printConfusionMatrix: Wrong argument sizes\n' return for c in ClassNames : if ( len ( c ) > 4 ) : c = c [ 0 : 3 ] print ' DCTB {0:s}' . format ( c ) , print for ( i , c ) in enumerate ( ClassNames ) : if ( len ( c ) > 4 ) : c = c [ 0 : 3 ] print '{0:s}' . format ( c ) , for j in range ( len ( ClassNames ) ) : print ' DCTB {0:.1f}' . format ( ( ( 100.0 * CM [ i ] [ j ] ) / numpy . sum ( CM ) ) ) , print
this function prints a confusion matrix for a particular classification task .