Exemple #1
0
def test_predict():
    X = X_dsel_ex1
    y = y_dsel_ex1
    pool_classifiers = create_pool_classifiers()
    single_best_test = SingleBest(pool_classifiers)
    single_best_test.fit(X, y)

    predicted_labels = single_best_test.predict(X)
    assert np.equal(predicted_labels, 0).all()
Exemple #2
0
def test_predict(create_X_y, create_pool_classifiers):
    X, y = create_X_y

    pool_classifiers = create_pool_classifiers
    single_best_test = SingleBest(pool_classifiers=pool_classifiers)
    single_best_test.fit(X, y)

    predicted_labels = single_best_test.predict(X)
    assert np.equal(predicted_labels, 0).all()
Exemple #3
0
def test_label_encoder_base_ensemble():
    from sklearn.ensemble import RandomForestClassifier
    X, y = make_classification()
    y[y == 1] = 2
    y = y.astype(np.float)
    pool = RandomForestClassifier().fit(X, y)
    sb = SingleBest(pool)
    sb.fit(X, y)
    pred = sb.predict(X)
    assert np.isin(sb.classes_, pred).all()
Exemple #4
0
def test_not_fitted():
    single_best_test = SingleBest(create_pool_classifiers())
    with pytest.raises(NotFittedError):
        single_best_test.predict(np.array([1, -1]))
Exemple #5
0
def test_not_fitted():
    single_best_test = SingleBest()
    with pytest.raises(NotFittedError):
        single_best_test.predict(np.array([[1, -1]]))
Exemple #6
0
def test_label_encoder(create_label_encoder_test):
    X, y, pool = create_label_encoder_test
    sb = SingleBest(pool).fit(X, y)
    pred = sb.predict(X)
    assert np.array_equal(pred, y)