示例#1
0
def test_multinomial():
    print("Multinomial test")
    name = "multinomial"
    print("Create default", name, "model")
    (model, f_test) = multinomial_model_default(H2OGradientBoostingEstimator)
    print("Create custom", name, "model")
    (model2, f_test2) = multinomial_model_distribution(
        H2OGradientBoostingEstimator,
        upload_distribution(CustomDistributionMultinomial, name))
    check_model_metrics(model, model2, name)
示例#2
0
def test_binomial():
    print("Binomial tests")
    name = "Bernoulli"
    print("Create default", name, "model")
    (model, f_test) = binomial_model_default(H2OGradientBoostingEstimator,
                                             name)
    print("Create custom ", name, "model")
    (model2, f_test2) = binomial_model_distribution(
        H2OGradientBoostingEstimator,
        upload_distribution(CustomDistributionBernoulli, name))
    check_model_metrics(model, model2, name)
示例#3
0
def test_regression():
    print("Regression tests")
    name = "gaussian"
    print("Create default", name, "model")
    (model, f_test) = regression_model_default(H2OGradientBoostingEstimator,
                                               name)
    print("Create custom ", name, "model")
    (model2, f_test2) = regression_model_distribution(
        H2OGradientBoostingEstimator,
        upload_distribution(CustomDistributionGaussian, name))
    check_model_metrics(model, model2, name)
示例#4
0
def test_regression():
    print("Regression tests")
    name = "gaussian"
    print("Create default", name, "model")
    (model, f_test) = regression_model_default(H2OGradientBoostingEstimator,
                                               name)
    print("Create custom ", name, "model")
    (model2, f_test2) = regression_model_distribution(
        H2OGradientBoostingEstimator,
        upload_distribution(CustomDistributionGaussian, name))

    check_model_metrics(model, model2, name)

    print(
        "Test scoring history is without deviance if custom distribution is set."
    )
    sh = model.scoring_history().columns
    shc = model2.scoring_history().columns
    assert "training_deviance" in sh and "training_deviance" not in shc
示例#5
0
def test_worng_and_inherited_regression():
    print("Create default gaussian model")
    (model, f_test) = regression_model_default(H2OGradientBoostingEstimator,
                                               "gaussian")

    print("Create custom wrong gaussian model")
    (model2, f_test2) = regression_model_distribution(
        H2OGradientBoostingEstimator,
        upload_distribution(CustomDistributionGaussianWrong, "gaussian_w"))
    assert model.rmse(valid=False) != model2.rmse(valid=False), \
        "Training rmse is not different for default and custom gaussian model."
    assert model.rmse(valid=True) != model2.rmse(valid=True), \
        "Validation rmse is not different for default and custom gaussian model."

    print("Create custom gaussian model without inheritance")
    (model3, f_test3) = regression_model_distribution(
        H2OGradientBoostingEstimator,
        upload_distribution(CustomDistributionGaussianNoInh, "gaussian_ni"))
    check_model_metrics(model, model3, "gaussian_ni")