예제 #1
0
def test_maui_model_saves_feature_names_to_disk():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    maui_model = maui_model.fit({"d1": df1, "d2": df2})
    with tempfile.TemporaryDirectory() as tmpdirname:
        maui_model.save(tmpdirname)
        maui_model_from_disk = Maui.load(tmpdirname)
    assert maui_model.feature_names == maui_model_from_disk.feature_names
예제 #2
0
def test_maui_model_loads_model_without_feature_names_from_disk_and_warns():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    maui_model = maui_model.fit({"d1": df1, "d2": df2})
    with tempfile.TemporaryDirectory() as tmpdirname:
        maui_model.save(tmpdirname)
        os.remove(os.path.join(tmpdirname, "maui_feature_names.txt"))
        with pytest.warns(MauiWarning):
            maui_model_from_disk = Maui.load(tmpdirname)
        assert maui_model_from_disk.feature_names is None
예제 #3
0
파일: test_maui.py 프로젝트: frenkiboy/maui
def test_maui_can_load_from_folder():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    maui_model = maui_model.fit({"d1": df1, "d2": df2})
    with tempfile.TemporaryDirectory() as tmpdirname:
        maui_model.save(tmpdirname)
        maui_model_from_disk = Maui.load(tmpdirname)

    assert maui_model_from_disk.n_latent == maui_model.n_latent
    assert np.allclose(maui_model.vae.get_weights()[0],
        maui_model_from_disk.vae.get_weights()[0])
    assert np.allclose(
        maui_model.transform({"d1": df1, "d2": df2}),
        maui_model_from_disk.transform({"d1": df1, "d2": df2})
        )