def test_kne_proba(knn_methods): pool_classifiers, X_dsel, y_dsel, X_test, y_test = setup_classifiers() kne = KNORAE(pool_classifiers, knn_classifier=knn_methods, voting='soft') kne.fit(X_dsel, y_dsel) probas = kne.predict_proba(X_test) expected = np.load( 'deslib/tests/expected_values/kne_proba_integration.npy') assert np.allclose(probas, expected)
def test_knorae_subspaces(): rng = np.random.RandomState(123456) X_dsel, X_test, X_train, y_dsel, y_test, y_train = load_dataset(None, rng) pool = BaggingClassifier(LogisticRegression(), max_features=0.5, random_state=rng).fit(X_train, y_train) knorae = KNORAE(pool) knorae.fit(X_dsel, y_dsel) y_pred = knorae.predict_proba(X_test).argmax(axis=1) assert np.isclose(accuracy_score(y_pred, y_test), 0.9787234042553191)