Пример #1
0
def test_omni_embed():
    """
    We compare the difference of norms of OmniBar and ABar.
    ABar is the lowest variance estimate of the latent positions X.
    OmniBar should be reasonablly close to ABar when n_vertices is high. 
    """
    def compute_bar(arr):
        n = arr.shape[0] // 2
        return (arr[:n] + arr[n:]) / 2

    X, A1, A2 = generate_data(1000)
    Abar = (A1 + A2) / 2

    np.random.seed(11)
    omni = OmnibusEmbed(n_components=3)
    OmniBar = compute_bar(omni.fit_transform([A1, A2]))

    omni = OmnibusEmbed(n_components=3)
    ABar = compute_bar(omni.fit_transform([Abar, Abar]))

    tol = 1.0e-2
    assert allclose(norm(OmniBar, axis=1),
                    norm(ABar, axis=1),
                    rtol=tol,
                    atol=tol)
Пример #2
0
    def run(diag_aug):
        X, A1, A2 = generate_data(1000, seed=2)
        Abar = (A1 + A2) / 2

        omni = OmnibusEmbed(n_components=3, diag_aug=diag_aug)
        OmniBar = compute_bar(omni.fit_transform([A1, A2]))

        omni = OmnibusEmbed(n_components=3, diag_aug=diag_aug)
        ABar = compute_bar(omni.fit_transform([Abar, Abar]))

        tol = 1.0e-2
        assert allclose(norm(OmniBar, axis=1),
                        norm(ABar, axis=1),
                        rtol=tol,
                        atol=tol)