Beispiel #1
0
def test_invalid_normalize():
    omnibus.Omnibus(normalize="l2")
    omnibus.Omnibus(normalize=None)
    omnibus.Omnibus(normalize="max")

    with pytest.raises(ValueError):
        omnibus.Omnibus(normalize="blah")
Beispiel #2
0
def test_fit():
    n_components = 2
    embedder = omnibus.Omnibus(n_components=n_components)
    n_views = 4
    n = 25
    m = 25
    Xs = []
    for _ in range(n_views):
        X = np.random.rand(n, m)
        Xs.append(X)
    embedder.fit(Xs)
    assert len(embedder.embeddings_ == n_views)
Beispiel #3
0
def test_omnibus_embedding_no_normalize():
    n_components = 2
    embedder = omnibus.Omnibus(n_components=n_components, normalize=None)
    n_views = 4
    n = 25
    m = 25
    Xs = []
    for _ in range(n_views):
        X = np.random.rand(n, m)
        Xs.append(X)
    embeddings = embedder.fit_transform(Xs)

    assert len(embeddings) == n_views
Beispiel #4
0
###############################################################################
# Case 1: Two Identical Views
# ---------------------------
# For this setting, we generate two identical numpy matrices as our views.
# Since the information is identical in each view, the resulting embedded views
# should also be similar. We run omnibus on default parameters.

# 100 x 50 matrices
X_1 = np.random.rand(100, 50)
X_2 = X_1.copy()

Xs = [X_1, X_2]

# Running omnibus
embedder = omnibus.Omnibus()
embeddings = embedder.fit_transform(Xs)

###############################################################################
# Visualizing the Results
# ^^^^^^^^^^^^^^^^^^^^^^^

Xhat1, Xhat2 = embeddings

fig, ax = plt.subplots(figsize=(10, 10))
ct = ax.scatter(Xhat1[:, 0],
                Xhat1[:, 1],
                marker='s',
                label='View 1',
                cmap="tab10",
                s=100)
Beispiel #5
0
def test_default_constructor():
    omnibus.Omnibus()
Beispiel #6
0
def test_embeddings_default_none():
    omni = omnibus.Omnibus()
    assert omni.embeddings_ == None
Beispiel #7
0
def test_invalid_n_iter():
    with pytest.raises(ValueError):
        omnibus.Omnibus(n_iter=-1)

    with pytest.raises(ValueError):
        omnibus.Omnibus(n_iter=0)
Beispiel #8
0
def test_invalid_algorithm():
    omnibus.Omnibus(algorithm="full")

    with pytest.raises(ValueError):
        omnibus.Omnibus(algorithm="blah")
Beispiel #9
0
def test_invalid_metric():
    omnibus.Omnibus(distance_metric="yule")
    with pytest.raises(ValueError):
        omnibus.Omnibus(distance_metric="blah")
Beispiel #10
0
def test_invalid_components():
    with pytest.raises(ValueError):
        omnibus.Omnibus(n_components=-1)

    with pytest.raises(ValueError):
        omnibus.Omnibus(n_components=0)