示例#1
0
def evaluate():
    parameters = [
        {"mean": [1, 1], "std": [0.5, 1], "N": 100},
        {"mean": [1, 3], "std": [1, 1], "N": 150},
        {"mean": [3, 2], "std": [0.5, 0.5], "N": 200},
    ]
    classes, data = sample_data(parameters)
    plot_data(parameters, data)
    results = abx_numpy.abx(classes, data, lambda x, y: np.linalg.norm(x - y))
    print(results)
示例#2
0
def test_perfect_abx():
    classes, data = generate_perfect_items()
    abx_score = abx_numpy.abx(classes, data, lambda a, b: np.linalg.norm(a-b))
    assert abx_score[0] == 1.
    assert np.all(abx_score[1] == np.arange(10))
    assert np.all(abx_score[2][~np.eye(10, dtype=bool)] == 1)
示例#3
0
def test_random_abx():
    classes, data = generate_random_items()
    abx_score = abx_numpy.abx(classes, data, lambda a, b: np.linalg.norm(a-b))
    assert np.abs(abx_score[0] - 0.5) < tolerance