@@ -302,7 +302,7 @@ def majorityClassFraction(self):
302
302
self .attrs ['MajorityClassFraction' ] = dum .PC ()
303
303
return self .attrs ['MajorityClassFraction' ]
304
304
305
- def MatthewsCC (self ):
305
+ def MatthewsCC (self , ci = None ):
306
306
"""Matthews Correlation Coefficient
307
307
308
308
Examples
@@ -323,6 +323,11 @@ def MatthewsCC(self):
323
323
else :
324
324
denom = np .sqrt (np .float64 (sum_ac * sum_ab * sum_cd * sum_bd ))
325
325
self .attrs ['MatthewsCC' ] = numer / denom
326
+ if ci is not None and ci == 'bootstrap' :
327
+ self .attrs ['MatthewsCCCI95' ] = \
328
+ self ._bootstrapCI (func = 'MatthewsCC' )
329
+ return (self .attrs ['MatthewsCC' ],
330
+ self .attrs ['MatthewsCCCI95' ])
326
331
return self .attrs ['MatthewsCC' ]
327
332
328
333
def summary (self , verbose = False , ci = None ):
@@ -348,7 +353,7 @@ def summary(self, verbose=False, ci=None):
348
353
dum = self .peirce (ci = ci )
349
354
dum = self .bias (ci = ci )
350
355
dum = self .majorityClassFraction ()
351
- dum = self .MatthewsCC ()
356
+ dum = self .MatthewsCC (ci = ci )
352
357
dum = self .oddsRatio ()
353
358
dum = self .yuleQ ()
354
359
a , b , c , d = self ._abcd ()
@@ -394,7 +399,17 @@ def summary(self, verbose=False, ci=None):
394
399
print ("\n Classification Quality Metrics" )
395
400
print ("==============================" )
396
401
for key in qual :
397
- print ("{0}: {1:0.4f}" .format (key , self .attrs [key ]))
402
+ if key + 'CI95' in self .attrs :
403
+ if self .attrs [key + 'CI95' ].shape :
404
+ print ("{0}: {1:0.4f} [{2:0.4f}, {3:0.4f}]" .format (key , \
405
+ self .attrs [key ], \
406
+ self .attrs [key + 'CI95' ][0 ], \
407
+ self .attrs [key + 'CI95' ][1 ]))
408
+ else :
409
+ print ("{0}: {1:0.4f} +/- {2:0.4f}" .format (key , \
410
+ self .attrs [key ], self .attrs [key + 'CI95' ]))
411
+ else :
412
+ print ("{0}: {1:0.4f}" .format (key , self .attrs [key ]))
398
413
399
414
def _bootstrapCI (self , interval = 0.95 , nsamp = 2000 , func = None , seed = 1406 ):
400
415
""" bootstrap confidence interval
0 commit comments