@@ -161,8 +161,7 @@ def test_precision_recall_f_binary_single_class():
161
161
162
162
@ignore_warnings
163
163
def test_precision_recall_f_extra_labels ():
164
- """Test handling of explicit additional (not in input) labels to PRF
165
- """
164
+ # Test handling of explicit additional (not in input) labels to PRF
166
165
y_true = [1 , 3 , 3 , 2 ]
167
166
y_pred = [1 , 1 , 3 , 2 ]
168
167
y_true_bin = label_binarize (y_true , classes = np .arange (5 ))
@@ -202,7 +201,7 @@ def test_precision_recall_f_extra_labels():
202
201
203
202
@ignore_warnings
204
203
def test_precision_recall_f_ignored_labels ():
205
- """ Test a subset of labels may be requested for PRF"""
204
+ # Test a subset of labels may be requested for PRF
206
205
y_true = [1 , 1 , 2 , 3 ]
207
206
y_pred = [1 , 3 , 3 , 3 ]
208
207
y_true_bin = label_binarize (y_true , classes = np .arange (5 ))
@@ -323,6 +322,7 @@ def test_cohen_kappa():
323
322
assert_almost_equal (cohen_kappa_score (y1 , y2 ), .8013 , decimal = 4 )
324
323
325
324
325
+ @ignore_warnings
326
326
def test_matthews_corrcoef_nan ():
327
327
assert_equal (matthews_corrcoef ([0 ], [1 ]), 0.0 )
328
328
assert_equal (matthews_corrcoef ([0 , 0 ], [0 , 1 ]), 0.0 )
@@ -647,8 +647,8 @@ def test_multilabel_hamming_loss():
647
647
assert_equal (hamming_loss (y1 , y2 ), 1 / 6 )
648
648
assert_equal (hamming_loss (y1 , y1 ), 0 )
649
649
assert_equal (hamming_loss (y2 , y2 ), 0 )
650
- assert_equal (hamming_loss (y2 , np . logical_not ( y2 ) ), 1 )
651
- assert_equal (hamming_loss (y1 , np . logical_not ( y1 ) ), 1 )
650
+ assert_equal (hamming_loss (y2 , 1 - y2 ), 1 )
651
+ assert_equal (hamming_loss (y1 , 1 - y1 ), 1 )
652
652
assert_equal (hamming_loss (y1 , np .zeros (y1 .shape )), 4 / 6 )
653
653
assert_equal (hamming_loss (y2 , np .zeros (y1 .shape )), 0.5 )
654
654
@@ -807,6 +807,7 @@ def test_precision_recall_f1_score_multilabel_2():
807
807
0.1666 , 2 )
808
808
809
809
810
+ @ignore_warnings
810
811
def test_precision_recall_f1_score_with_an_empty_prediction ():
811
812
y_true = np .array ([[0 , 1 , 0 , 0 ], [1 , 0 , 0 , 0 ], [0 , 1 , 1 , 0 ]])
812
813
y_pred = np .array ([[0 , 0 , 0 , 0 ], [0 , 0 , 0 , 1 ], [0 , 1 , 1 , 0 ]])
@@ -1142,11 +1143,11 @@ def test_hinge_loss_binary():
1142
1143
1143
1144
def test_hinge_loss_multiclass ():
1144
1145
pred_decision = np .array ([
1145
- [0.36 , - 0.17 , - 0.58 , - 0.99 ],
1146
+ [+ 0.36 , - 0.17 , - 0.58 , - 0.99 ],
1146
1147
[- 0.54 , - 0.37 , - 0.48 , - 0.58 ],
1147
1148
[- 1.45 , - 0.58 , - 0.38 , - 0.17 ],
1148
1149
[- 0.54 , - 0.38 , - 0.48 , - 0.58 ],
1149
- [- 2.36 , - 0.79 , - 0.27 , 0.24 ],
1150
+ [- 2.36 , - 0.79 , - 0.27 , + 0.24 ],
1150
1151
[- 1.45 , - 0.58 , - 0.38 , - 0.17 ]
1151
1152
])
1152
1153
y_true = np .array ([0 , 1 , 2 , 1 , 3 , 2 ])
@@ -1167,10 +1168,10 @@ def test_hinge_loss_multiclass():
1167
1168
def test_hinge_loss_multiclass_missing_labels_with_labels_none ():
1168
1169
y_true = np .array ([0 , 1 , 2 , 2 ])
1169
1170
pred_decision = np .array ([
1170
- [1.27 , 0.034 , - 0.68 , - 1.40 ],
1171
+ [+ 1.27 , 0.034 , - 0.68 , - 1.40 ],
1171
1172
[- 1.45 , - 0.58 , - 0.38 , - 0.17 ],
1172
- [- 2.36 , - 0.79 , - 0.27 , 0.24 ],
1173
- [- 2.36 , - 0.79 , - 0.27 , 0.24 ]
1173
+ [- 2.36 , - 0.79 , - 0.27 , + 0.24 ],
1174
+ [- 2.36 , - 0.79 , - 0.27 , + 0.24 ]
1174
1175
])
1175
1176
error_message = ("Please include all labels in y_true "
1176
1177
"or pass labels as third argument" )
@@ -1181,7 +1182,7 @@ def test_hinge_loss_multiclass_missing_labels_with_labels_none():
1181
1182
1182
1183
def test_hinge_loss_multiclass_with_missing_labels ():
1183
1184
pred_decision = np .array ([
1184
- [0.36 , - 0.17 , - 0.58 , - 0.99 ],
1185
+ [+ 0.36 , - 0.17 , - 0.58 , - 0.99 ],
1185
1186
[- 0.55 , - 0.38 , - 0.48 , - 0.58 ],
1186
1187
[- 1.45 , - 0.58 , - 0.38 , - 0.17 ],
1187
1188
[- 0.55 , - 0.38 , - 0.48 , - 0.58 ],
@@ -1209,12 +1210,12 @@ def test_hinge_loss_multiclass_invariance_lists():
1209
1210
y_true = ['blue' , 'green' , 'red' ,
1210
1211
'green' , 'white' , 'red' ]
1211
1212
pred_decision = [
1212
- [0.36 , - 0.17 , - 0.58 , - 0.99 ],
1213
+ [+ 0.36 , - 0.17 , - 0.58 , - 0.99 ],
1213
1214
[- 0.55 , - 0.38 , - 0.48 , - 0.58 ],
1214
- [- 1.45 , - 0.58 , - 0.38 , - 0.17 ],
1215
+ [- 1.45 , - 0.58 , - 0.38 , - 0.17 ],
1215
1216
[- 0.55 , - 0.38 , - 0.48 , - 0.58 ],
1216
- [- 2.36 , - 0.79 , - 0.27 , 0.24 ],
1217
- [- 1.45 , - 0.58 , - 0.38 , - 0.17 ]]
1217
+ [- 2.36 , - 0.79 , - 0.27 , + 0.24 ],
1218
+ [- 1.45 , - 0.58 , - 0.38 , - 0.17 ]]
1218
1219
dummy_losses = np .array ([
1219
1220
1 - pred_decision [0 ][0 ] + pred_decision [0 ][1 ],
1220
1221
1 - pred_decision [1 ][1 ] + pred_decision [1 ][2 ],
0 commit comments