예제 #1
0
def test_predict():
    X = X_dsel_ex1
    y = y_dsel_ex1
    oracle_test = Oracle(create_pool_classifiers())
    predicted_labels = oracle_test.predict(X, y)
    assert np.equal(predicted_labels, y).all()

    assert oracle_test.score(X, y) == 1.0
예제 #2
0
def test_predict_all_same():
    X = X_dsel_ex1
    y = np.copy(y_dsel_ex1)
    expected = y
    oracle_test = Oracle(create_pool_all_agree(return_value=0, size=10))
    expected[expected == 1] = -1
    predicted_labels = oracle_test.predict(X, y)
    assert np.equal(predicted_labels, expected).all()
예제 #3
0
파일: test_oracle.py 프로젝트: postyear/DES
def test_predict(create_X_y, create_pool_classifiers):
    X, y = create_X_y

    oracle_test = Oracle(create_pool_classifiers)
    oracle_test.fit(X, y)
    predicted_labels = oracle_test.predict(X, y)
    assert np.equal(predicted_labels, y).all()

    assert oracle_test.score(X, y) == 1.0
예제 #4
0
파일: test_oracle.py 프로젝트: postyear/DES
def test_predict_all_same(create_X_y, create_pool_all_agree):
    X, y = create_X_y

    expected = y
    oracle_test = Oracle(create_pool_all_agree)
    oracle_test.fit(X, y)
    expected[expected == 1] = 0
    predicted_labels = oracle_test.predict(X, y)
    assert np.equal(predicted_labels, expected).all()
예제 #5
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)
    oracle = Oracle(pool)
    oracle.fit(X, y)
    pred = oracle.predict(X, y)
    assert np.isin(oracle.classes_, pred).all()
def test_predict_proba_right_class():
    n_test_samples = 200
    X, y = make_classification(n_samples=1000)
    X_test, y_test = make_classification(n_samples=n_test_samples)
    pool = RandomForestClassifier(max_depth=3).fit(X, y)
    oracle = Oracle(pool_classifiers=pool).fit(X, y)

    preds = oracle.predict(X_test, y_test)
    proba = oracle.predict_proba(X_test, y_test)
    probas_max = np.argmax(proba, axis=1)
    assert np.allclose(probas_max, preds)