Exemplo n.º 1
0
def test_train_model():
    X_train = np.array([1, 2, 3, 4, 5, 6]).reshape(-1, 1)
    y_train = np.array([10, 9, 8, 8, 6, 5])
    X_test = np.array([3, 4]).reshape(-1, 1)
    y_test = np.array([8, 7])
    data = {
        "train": {
            "X": X_train,
            "y": y_train
        },
        "test": {
            "X": X_test,
            "y": y_test
        }
    }

    run = Mock(Run)
    reg = train_model(run, data, alpha=1.2)

    run.log.assert_called_with("mse",
                               0.029843893480256872,
                               description='Mean squared error metric')

    preds = reg.predict([[1], [2]])
    np.testing.assert_equal(preds, [9.93939393939394, 9.03030303030303])
Exemplo n.º 2
0
def test_train_model():
    X_train = np.array([1, 2, 3, 4, 5, 6]).reshape(-1, 1)
    y_train = np.array([10, 9, 8, 8, 6, 5])
    X_test = np.array([3, 4]).reshape(-1, 1)
    y_test = np.array([8, 7])
    data = {
        "train": {
            "X": X_train,
            "y": y_train
        },
        "test": {
            "X": X_test,
            "y": y_test
        }
    }

    run = Mock(Run)
    reg = train_model(run, data, alpha=1.2)

    _, call2 = run.log.call_args_list
    nameValue, descriptionDict = call2
    name, value = nameValue
    description = descriptionDict['description']
    assert (name == 'mse')
    np.testing.assert_almost_equal(value, 0.029843893480257067)
    assert (description == 'Mean squared error metric')

    preds = reg.predict([[1], [2]])
    np.testing.assert_equal(preds, [9.93939393939394, 9.03030303030303])
Exemplo n.º 3
0
def test_train_model():
    X_train = np.array([1, 2, 3, 4, 5, 6]).reshape(-1, 1)
    y_train = np.array([10, 9, 8, 8, 6, 5])
    data = {"train": {"X": X_train, "y": y_train}}

    reg_model = train_model(data, {"alpha": 1.2})

    preds = reg_model.predict([[1], [2]])
    np.testing.assert_equal(preds, [9.93939393939394, 9.03030303030303])