@ignore_warnings
def test_sensitivity_specificity_ignored_labels():
 y_true = [1, 1, 2, 3]
 y_pred = [1, 3, 3, 3]
 specificity_13 = partial(specificity_score, y_true, y_pred, labels=[1, 3])
 specificity_all = partial(specificity_score, y_true, y_pred, labels=None)
 assert_allclose([1.0, 0.33], specificity_13(average=None), rtol=R_TOL)
 assert_allclose(np.mean([1.0, 0.33]), specificity_13(average='macro'), rtol=R_TOL)
 assert_allclose(np.average([1.0, 0.33], weights=[2.0, 1.0]), specificity_13(average='weighted'), rtol=R_TOL)
 assert_allclose((3.0 / (3.0 + 2.0)), specificity_13(average='micro'), rtol=R_TOL)
 for average in ['macro', 'weighted', 'micro']:
  assert_not_equal(specificity_13(average=average), specificity_all(average=average))

@ ignore_warnings def test_sensitivity_specificity_ignored_labels ( ) : y_true = [ 1 , 1 , 2 , 3 ] y_pred = [ 1 , 3 , 3 , 3 ] specificity_13 = partial ( specificity_score , y_true , y_pred , labels = [ 1 , 3 ] ) specificity_all = partial ( specificity_score , y_true , y_pred , labels = None ) assert_allclose ( [ 1.0 , 0.33 ] , specificity_13 ( average = None ) , rtol = R_TOL ) assert_allclose ( np . mean ( [ 1.0 , 0.33 ] ) , specificity_13 ( average = 'macro' ) , rtol = R_TOL ) assert_allclose ( np . average ( [ 1.0 , 0.33 ] , weights = [ 2.0 , 1.0 ] ) , specificity_13 ( average = 'weighted' ) , rtol = R_TOL ) assert_allclose ( ( 3.0 / ( 3.0 + 2.0 ) ) , specificity_13 ( average = 'micro' ) , rtol = R_TOL ) for average in [ 'macro' , 'weighted' , 'micro' ] : assert_not_equal ( specificity_13 ( average = average ) , specificity_all ( average = average ) )
test a subset of labels may be requested for ss .