Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions sklearn/utils/tests/test_class_weight.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ def test_compute_class_weight_balanced_unordered():
assert_almost_equal(np.dot(cw, class_counts), y.shape[0])
assert_array_almost_equal(cw, [2., 1., 2. / 3])

def test_class_weight_with_string_label():
y = np.asarray(["A","A","A","B","B","C"])
classes = np.unique(y)
class_weights = {c: 1.0 for c in classes}
class_weights['D'] = 1.0 # This should get a proper ValueError
cw = assert_raises(ValueError, compute_class_weight, class_weights,
classes, y)
return

def test_compute_sample_weight():
# Test (and demo) compute_sample_weight.
Expand Down