test_metrics.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:l1l2py 作者: slipguru 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号