def test_classification_report_imbalanced_multiclass_with_string_label():
 (y_true, y_pred, _) = make_prediction(binary=False)
 y_true = np.array(['blue', 'green', 'red'])[y_true]
 y_pred = np.array(['blue', 'green', 'red'])[y_pred]
 expected_report = 'pre rec spe f1 geo iba sup blue 0.83 0.79 0.92 0.81 0.86 0.74 24 green 0.33 0.10 0.86 0.15 0.44 0.19 31 red 0.42 0.90 0.55 0.57 0.63 0.37 20 avg / total 0.51 0.53 0.80 0.47 0.62 0.41 75'
 report = classification_report_imbalanced(y_true, y_pred)
 assert_equal(_format_report(report), expected_report)
 expected_report = 'pre rec spe f1 geo iba sup a 0.83 0.79 0.92 0.81 0.86 0.74 24 b 0.33 0.10 0.86 0.15 0.44 0.19 31 c 0.42 0.90 0.55 0.57 0.63 0.37 20 avg / total 0.51 0.53 0.80 0.47 0.62 0.41 75'
 report = classification_report_imbalanced(y_true, y_pred, target_names=['a', 'b', 'c'])
 assert_equal(_format_report(report), expected_report)

def test_classification_report_imbalanced_multiclass_with_string_label ( ) : ( y_true , y_pred , _ ) = make_prediction ( binary = False ) y_true = np . array ( [ 'blue' , 'green' , 'red' ] ) [ y_true ] y_pred = np . array ( [ 'blue' , 'green' , 'red' ] ) [ y_pred ] expected_report = 'pre rec spe f1 geo iba sup blue 0.83 0.79 0.92 0.81 0.86 0.74 24 green 0.33 0.10 0.86 0.15 0.44 0.19 31 red 0.42 0.90 0.55 0.57 0.63 0.37 20 avg / total 0.51 0.53 0.80 0.47 0.62 0.41 75' report = classification_report_imbalanced ( y_true , y_pred ) assert_equal ( _format_report ( report ) , expected_report ) expected_report = 'pre rec spe f1 geo iba sup a 0.83 0.79 0.92 0.81 0.86 0.74 24 b 0.33 0.10 0.86 0.15 0.44 0.19 31 c 0.42 0.90 0.55 0.57 0.63 0.37 20 avg / total 0.51 0.53 0.80 0.47 0.62 0.41 75' report = classification_report_imbalanced ( y_true , y_pred , target_names = [ 'a' , 'b' , 'c' ] ) assert_equal ( _format_report ( report ) , expected_report )
test the report with string label .