def test_balance_weights():
"""Test balanced classification error with custom weights."""
labels = [1, 1, -1, -1, -1]
predictions = [-1, -1, 1, 1, 1] # all errors
default_weights = np.abs(center(np.asarray(labels)))
exp_error = balanced_classification_error(labels, predictions)
error = balanced_classification_error(labels, predictions, default_weights)
assert_equals(exp_error, error)
null_weights = np.ones_like(labels)
exp_error = classification_error(labels, predictions)
error = balanced_classification_error(labels, predictions, null_weights)
assert_equals(exp_error, error)
# Balanced classes
labels = [1, 1, 1, -1, -1, -1]
predictions = [-1, -1, -1, 1, 1, 1] # all errors
exp_error = classification_error(labels, predictions)
error = balanced_classification_error(labels, predictions)
assert_equals(exp_error, error)
评论列表
文章目录