Пример #1
0
def test_train_predict_prob_XGBC_yeast3():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/yeast3.yaml")
    yeast3 = inputer.transform()
    y = yeast3[inputer.target].values
    X = yeast3[yeast3.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/XGBC.yaml")
    learner.train(X, y, checkpoint="yeast3LGBMC.ckp")
    assert learner.predict_proba(X).shape == (1484, 2)
Пример #2
0
def test_train_predict_prob_XGBC_creditdard():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/creditcard.yaml")
    creditdard = inputer.transform()
    y = creditdard[inputer.target].values
    X = creditdard[creditdard.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/XGBC.yaml")
    learner.train(X, y, checkpoint="creditdardLGBMC.ckp")
    assert learner.predict_proba(X).shape == (284807, 2)
Пример #3
0
def test_train_predict_prob_LGBC_wine():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/wine.yaml")
    wine = inputer.transform()
    y = wine[inputer.target].values
    X = wine[wine.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/LGBC.yaml")
    learner.train(X, y, target=inputer.target, checkpoint="wineLGBMC.ckp")
    assert learner.predict_proba(X).shape == (178, 3)
Пример #4
0
def test_train_predict_prob_LGBC():
    inputer = Inputers(description_filepath=
                       "../../descriptions/pre/inputers/pima-diabetes.yaml")
    diabetes = inputer.transform()
    y = diabetes[inputer.target].values
    X = diabetes[diabetes.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/LGBC.yaml")
    learner.train(X, y, checkpoint="diabetesLGBMC.ckp")
    assert learner.predict_proba(X).shape == (768, 2)
Пример #5
0
def test_learn_model_name():
    inputer = Inputers(description_filepath=
                       "../../descriptions/pre/inputers/pima-diabetes.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/RFC.yaml")
    learner.train(X, y, checkpoint="RandomForest.ckp")
    assert learner.model_name == "RandomForest"
Пример #6
0
def test_learn_train_predict_XGBC():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/wine.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/XGBC.yaml")
    learner.train(X, y, checkpoint="LGBMClassifier.ckp")
    assert learner.predict(X).shape == (178, )
Пример #7
0
def test_learn_train_predict_prob_LGBC():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/otto_group.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/LGBC.yaml")
    learner.train(X, y, checkpoint="otto_group_LGBMC.ckp")
    assert learner.predict(X).shape == (61878, )
Пример #8
0
def test_learn_train_kw_target_pima():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/wine.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/RFC.yaml")
    learner.train(X, y, checkpoint="diabetesRandomForest1.ckp")
    assert learner.trained == True
Пример #9
0
def test_learn_train_no_y():
    inputer = Inputers(description_filepath=
                       "../../descriptions/pre/inputers/pima-diabetes.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    o = Learners(
        description_filepath="../../descriptions/learners/RFC.sm.yaml")
    with pytest.raises(IndexError):
        o.train(X) == o
Пример #10
0
def test_evaluate_otto_group():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/otto_group.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/XGBC.yaml")
    learner.train(X, y, checkpoint="pima_LGBMC.ckp")
    assert len(learner.evaluate(X, y).keys()) == 7
Пример #11
0
def test_predict_Prob_error():
    inputer = Inputers(description_filepath=
                       "../../descriptions/pre/inputers/pima-diabetes.yaml")
    diabetes = inputer.transform()
    learner = Learners(
        description_filepath="../../descriptions/learners/LGBC.yaml")
    # learner.train(
    #     diabetes, target=inputer.target, checkpoint="diabetesLGBMC.ckp"
    # )
    X = diabetes
    X_train = X[X.columns.difference([inputer.target])]
    with pytest.raises(PasoError):
        assert learner.predict_proba(X_train).shape == (768, 2)
Пример #12
0
def test_learner_cross_validate_RFC_iris_milticlass_evaluate_test_accuracy():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/iris.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/RFC.yaml")
    learner.train(X, y, checkpoint="pima_LGBMC.ckp")
    score = learner.cross_validate(
        X,
        y,
        cv_description_filepath=
        "../../descriptions/learners/Cross_validation_classification.yaml",
    )

    assert score["mean"]["test_accuracy"] >= 0.95
Пример #13
0
def test_learn_train_kw_target_iris(flower):
    inputer = Inputers(description_filepath=
                       "../../descriptions/pre/inputers/pima-diabetes.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    o = Learners(
        description_filepath="../../descriptions/learners/RFC.sm.yaml")
    assert inputer.target == "Outcome"
Пример #14
0
def test_learner_cross_validate_LGBC():
    inputer = Inputers(description_filepath=
                       "../../descriptions/pre/inputers/pima-diabetes.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/LGBC.yaml")
    learner.train(X, y, checkpoint="pima_LGBMC.ckp")
    learner.cross_validate(
        X,
        y,
        cv_description_filepath=
        "../../descriptions/learners/Cross_validation_classification.yaml",
    )
    assert len(learner.evaluate(X, y).keys()) == 9
Пример #15
0
def test_learner_cross_validate_RFC_iris_multiclass_evaluate_AO():
    inputer = Inputers(
        description_filepath="../../descriptions/pre/inputers/iris.yaml")
    dataset = inputer.transform()
    y = dataset[inputer.target].values
    X = dataset[dataset.columns.difference([inputer.target])]
    learner = Learners(
        description_filepath="../../descriptions/learners/RFC.yaml")
    learner.train(X, y, checkpoint="iris)RC.ckp")
    learner.cross_validate(
        X,
        y,
        cv_description_filepath=
        "../../descriptions/learners/Cross_validation_classification.yaml",
    )

    assert learner.evaluate(X, y)["accuracy"] == 1.0
Пример #16
0
def test_cross_validaters():
    learner = Learners(
        description_filepath="../../descriptions/learners/LGBC.yaml")
    assert len(learner.cross_validaters()) == 3
Пример #17
0
def test_learners():
    learner = Learners(
        description_filepath="../../descriptions/learners/LGBC.yaml")
    assert len(learner.learners()) == 16
Пример #18
0
def test_learn_train_description_file_not_exist(flower):
    o = Learners(
        description_filepath="../../descriptions/learners/RandomForest.yaml")
    with pytest.raises(PasoError):
        o.train(flower) == o