def test_predict(self, data):
        raw_model = VW()
        raw_model.fit(data.x, data.y)

        model = VWRegressor()
        model.fit(data.x, data.y)

        assert np.allclose(raw_model.predict(data.x), model.predict(data.x))
        # ensure model can make multiple calls to predict
        assert np.allclose(raw_model.predict(data.x), model.predict(data.x))
Example #2
0
    def test_predict(self, data):
        raw_model = VW()
        raw_model.fit(data.x, data.y)

        model = VWRegressor()
        model.fit(data.x, data.y)

        assert np.allclose(raw_model.predict(data.x), model.predict(data.x))
        # ensure model can make multiple calls to predict
        assert np.allclose(raw_model.predict(data.x), model.predict(data.x))
Example #3
0
def test_save_load(tmp_path):
    train_file = str(tmp_path / "train.model")

    X = [[1, 2], [3, 4], [5, 6], [7, 8]]
    y = [1, 2, 3, 4]

    model_before = VWRegressor(l=100)
    model_before.fit(X, y)
    before_saving = model_before.predict(X)

    model_before.save(train_file)

    model_after = VWRegressor(l=100)
    model_after.load(train_file)
    after_loading = model_after.predict(X)

    assert all([a == b for a, b in zip(before_saving, after_loading)])
Example #4
0
from vowpalwabbit.sklearn_vw import VWRegressor

X = [[1, 2], [3, 4], [5, 6], [7, 8]]
y = [1, 2, 3, 4]

model = VWRegressor(l=100)
model.fit(X, y)
print(model.predict(X))
model.save("/tmp/train.model")

model2 = VWRegressor(l=100)
model2.load("/tmp/train.model")
print(model2.predict(X))