Exemplo n.º 1
0
def test_fbeta(caplog):
    """Unit test of fbeta_scorer"""

    caplog.set_level(logging.INFO)

    golds = np.array([0, 1, 0, 1, 0, 1])
    preds = np.array([0, 0, 0, 0, 0, 1])

    metric_dict = fbeta_scorer(golds, None, preds, pos_label=1, beta=2)
    assert isequal(metric_dict, {"f2": 0.3846153846153846})

    metric_dict = fbeta_scorer(golds, None, preds, pos_label=0, beta=2)
    assert isequal(metric_dict, {"f2": 0.8823529411764706})
Exemplo n.º 2
0
def test_fbeta(caplog):
    """Unit test of fbeta_scorer."""
    caplog.set_level(logging.INFO)

    metric_dict = fbeta_scorer(GOLDS, PROBS, PREDS, pos_label=1, beta=2)
    assert isequal(metric_dict, {"f2": 0.3846153846153846})

    metric_dict = fbeta_scorer(GOLDS, None, PREDS, pos_label=1, beta=2)
    assert isequal(metric_dict, {"f2": 0.3846153846153846})

    metric_dict = fbeta_scorer(GOLDS, None, PREDS, pos_label=0, beta=2)
    assert isequal(metric_dict, {"f2": 0.8823529411764706})

    metric_dict = fbeta_scorer(PROB_GOLDS, PROBS, PREDS, pos_label=1, beta=2)
    assert isequal(metric_dict, {"f2": 0.3846153846153846})

    metric_dict = fbeta_scorer(PROB_GOLDS, None, PREDS, pos_label=1, beta=2)
    assert isequal(metric_dict, {"f2": 0.3846153846153846})

    metric_dict = fbeta_scorer(PROB_GOLDS, None, PREDS, pos_label=0, beta=2)
    assert isequal(metric_dict, {"f2": 0.8823529411764706})