Exemple #1
0
def test_maui_updates_neural_weight_product_when_training():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)

    z_before = maui_model.fit_transform({"d1": df1, "d2": df2})
    nwp_before_fine_tuning = maui_model.get_neural_weight_product()

    maui_model.fine_tune({"d1": df1, "d2": df2})
    z_after = maui_model.transform({"d1": df1, "d2": df2})
    nwp_after_fine_tuning = maui_model.get_neural_weight_product()

    assert not np.allclose(z_before, z_after)
    assert not np.allclose(nwp_before_fine_tuning, nwp_after_fine_tuning)
def test_maui_saves_neural_weight_product():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    z = maui_model.fit_transform({"d1": df1, "d2": df2})
    nwp = maui_model.get_neural_weight_product()
    assert nwp is not None
    assert hasattr(maui_model, "nwp_")

    print(maui_model.encoder.summary())

    w1 = maui_model.encoder.layers[2].get_weights()[0]
    w2 = maui_model.encoder.layers[3].get_weights()[0]

    nwp_11 = np.dot(w1[0, :], w2[:, 0])
    assert np.allclose(nwp_11, nwp.iloc[0, 0])
Exemple #3
0
def test_maui_saves_w():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    z = maui_model.fit_transform({'d1': df1, 'd2': df2})
    w = maui_model.get_linear_weights()
    assert hasattr(maui_model, 'w_')
Exemple #4
0
def test_maui_saves_feature_correlations():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    z = maui_model.fit_transform({'d1': df1, 'd2': df2})
    assert hasattr(maui_model, 'feature_correlations')
Exemple #5
0
def test_maui_supports_not_deep_deep_vae():
    maui_model = Maui(n_hidden=None, n_latent=2, epochs=1, architecture='deep')
    z = maui_model.fit_transform({'d1': df1, 'd2': df2})
Exemple #6
0
def test_maui_runs_with_deep_not_stacked_vae():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1, architecture='deep')
    z = maui_model.fit_transform({'d1': df1, 'd2': df2})
Exemple #7
0
def test_maui_saves_w():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    z = maui_model.fit_transform({"d1": df1, "d2": df2})
    w = maui_model.get_linear_weights()
    assert w is not None
    assert hasattr(maui_model, "w_")
Exemple #8
0
def test_maui_saves_feature_correlations():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    z = maui_model.fit_transform({"d1": df1, "d2": df2})
    r = maui_model.get_feature_correlations()
    assert r is not None
    assert hasattr(maui_model, "feature_correlations_")
Exemple #9
0
def test_maui_supports_not_deep_deep_vae():
    maui_model = Maui(n_hidden=None, n_latent=2, epochs=1, architecture="deep")
    z = maui_model.fit_transform({"d1": df1, "d2": df2})
Exemple #10
0
def test_maui_runs_with_deep_not_stacked_vae():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1, architecture="deep")
    z = maui_model.fit_transform({"d1": df1, "d2": df2})