def test_forest_reg_model(data, test):
    import numpy as np

    from mle_training.utils import data_preprocess as preprocess

    housing = data

    # Fit missing value imputer on train data
    preprocess.fit(train_data=housing)

    # Transform train and test data
    X_train, y_train = preprocess.transform(data=housing)

    # Fit model and score on training set
    forest_model = train_score.forest_reg_model(X=X_train, y=y_train)

    y_pred_model = forest_model.predict(test)[0]

    assert np.round(y_pred_model, 3) == 134796.667
Exemplo n.º 2
0
def test_model_predict(data):
    import numpy as np

    from mle_training.utils import data_preprocess as preprocess

    housing = data

    # Fit missing value imputer on train data
    preprocess.fit(train_data=housing)

    # Transform train and test data
    X_train, y_train = preprocess.transform(data=housing)

    from mle_training import train_score  # train and score module

    # Fit model and score on training set
    lin_model = train_score.linear_reg_model(X=X_train, y=y_train)

    # Score trained model on test set (can be a model stored in a pickle file)
    y_pred = predict.model_predict(model=lin_model, X=[X_train.iloc[0, :]])[0]

    assert np.round(y_pred, 3) == 136237.050