예제 #1
0
def test_cbm_objective_function_floats():
    y_true = pd.Series([0, 0, 0, 1, 1, 1, 1, 1, 1, 1])
    y_predicted = pd.Series([0, 0, 1, 0, 0, 0, 0, 1, 1, 1])
    cbm = CostBenefitMatrix(true_positive=5.1,
                            true_negative=-1.2,
                            false_positive=-6.7,
                            false_negative=-0.1)
    assert np.isclose(cbm.objective_function(y_true, y_predicted),
                      ((3 * 5.1) + (-1.2 * 2) + (1 * -6.7) + (4 * -0.1)) / 10)
예제 #2
0
def test_cbm_objective_function(data_type, make_data_type):
    y_true = pd.Series([0, 0, 0, 1, 1, 1, 1, 1, 1, 1])
    y_predicted = pd.Series([0, 0, 1, 0, 0, 0, 0, 1, 1, 1])
    y_true = make_data_type(data_type, y_true)
    y_predicted = make_data_type(data_type, y_predicted)
    cbm = CostBenefitMatrix(true_positive=10,
                            true_negative=-1,
                            false_positive=-7,
                            false_negative=-2)
    assert np.isclose(cbm.objective_function(y_true, y_predicted),
                      ((3 * 10) + (-1 * 2) + (1 * -7) + (4 * -2)) / 10)