Пример #1
0
def test_score():
    X = da.from_array(X_iris, chunks=4)
    y = da.from_array(y_iris, chunks=4)

    c = Chained(sgd1)
    fit = c.fit(X, y)

    s = fit.score(X_iris, y_iris)
    assert isinstance(s, Delayed)
    res = s.compute()
    assert isinstance(res, float)

    s = fit.score(X, y)
    assert isinstance(s, Delayed)
    res = s.compute()
    assert isinstance(res, float)

    will_error = c.score(X_iris, y_iris)
    with pytest.raises(NotFittedError):
        will_error.compute()
Пример #2
0
def test_predict():
    X = da.from_array(X_iris, chunks=4)
    y = da.from_array(y_iris, chunks=4)

    c = Chained(sgd1)
    fit = c.fit(X, y)

    pred = fit.predict(X_iris)
    assert isinstance(pred, Delayed)
    res = pred.compute()
    assert isinstance(res, np.ndarray)

    pred = fit.predict(X)
    assert isinstance(pred, da.Array)
    res = pred.compute()
    assert isinstance(res, np.ndarray)

    will_error = c.predict(X_iris)
    with pytest.raises(NotFittedError):
        will_error.compute()