Ejemplo n.º 1
0
def test_save_to_Path():
    model = Workspace(quiet=True)
    model.learn("1 | a b c")
    model.save(Path("tmp1.model"))
    model.save("tmp2.model")
    assert filecmp.cmp("tmp1.model", "tmp2.model")
    os.remove("tmp1.model")
    os.remove("tmp2.model")
Ejemplo n.º 2
0
def test_regressor_args():
    # load and parse external data file
    data_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             "resources", "train.dat")
    model = Workspace(oaa=3, data=data_file, passes=30, c=True, k=True)
    assert model.predict("| feature1:2.5") == 1

    # update model in memory
    for _ in range(10):
        model.learn("3 | feature1:2.5")
    assert model.predict("| feature1:2.5") == 3

    # save model
    model.save("tmp.model")
    del model

    # load initial regressor and confirm updated prediction
    new_model = Workspace(i="tmp.model", quiet=True)
    assert new_model.predict("| feature1:2.5") == 3
    del new_model

    # clean up
    os.remove("{}.cache".format(data_file))
    os.remove("tmp.model")