def callback_recovery(loc):
    d = loc['dict_obj']
    d.wc.append(emd(loc['dictionary'], d.generating_dict, 
                    'chordal', scale=True))
    d.wfs.append(emd(loc['dictionary'], d.generating_dict, 
                     'fubinistudy', scale=True))
    d.hc.append(hausdorff(loc['dictionary'], d.generating_dict, 
                          'chordal', scale=True))
    d.hfs.append(hausdorff(loc['dictionary'], d.generating_dict, 
                           'fubinistudy', scale=True))
    d.bd.append(beta_dist(d.generating_dict, loc['dictionary']))
    d.dr99.append(detection_rate(loc['dictionary'],
                                d.generating_dict, 0.99))
    d.dr97.append(detection_rate(loc['dictionary'],
                                d.generating_dict, 0.97))
Example #2
0
def test_correlation():
    du2 = [randn(n_features,) for i in range(n_kernels)]
    for i in range(len(du2)):
        du2[i] /= norm(du2[i])
    dm2 = [randn(n_features, n_dims) for i in range(n_kernels)]
    for i in range(len(dm2)):
        dm2[i] /= norm(dm2[i])

    assert_equal(100., detection_rate(du, du, 0.97))
    assert_not_equal(100., detection_rate(du, du2, 0.99))
    assert_equal(100., detection_rate(dm, dm, 0.97))
    assert_not_equal(100., detection_rate(dm, dm2, 0.99))
    assert_equal((100., 100.), precision_recall(du, du, 0.97))
    assert_equal((0., 0.), precision_recall(du, du2, 0.99))
    assert_true(allclose(precision_recall_points(du, du),
                            (ones(len(du)), ones(len(du)))))
    assert_true(not allclose(precision_recall_points(du, du2),
                                (ones(len(du)), ones(len(du2)))))