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
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()
def test_predict(): X = X_dsel_ex1 y = y_dsel_ex1 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
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)) oracle_test.fit(X, y) expected[expected == 1] = 0 predicted_labels = oracle_test.predict(X, y) assert np.equal(predicted_labels, expected).all()
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_oracle(): pool_classifiers, X_dsel, y_dsel, X_test, y_test = setup_classifiers() oracle = Oracle(pool_classifiers) oracle.fit(X_dsel, y_dsel) assert np.isclose(oracle.score(X_test, y_test), 0.99468085106382975)