def test_ola_proba(knn_methods): pool_classifiers, X_dsel, y_dsel, X_test, y_test = setup_classifiers() ola = OLA(pool_classifiers, knn_classifier=knn_methods) ola.fit(X_dsel, y_dsel) probas = ola.predict_proba(X_test) expected = np.load( 'deslib/tests/expected_values/ola_proba_integration.npy') assert np.allclose(probas, expected)
def test_ola_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(), bootstrap_features=True, max_features=0.5, random_state=rng).fit(X_train, y_train) ola = OLA(pool) ola.fit(X_dsel, y_dsel) assert np.isclose(ola.score(X_test, y_test), 0.9680851063829787)
def test_ola(knn_methods): pool_classifiers, X_dsel, y_dsel, X_test, y_test = setup_classifiers() ola = OLA(pool_classifiers, knn_classifier=knn_methods) ola.fit(X_dsel, y_dsel) assert np.isclose(ola.score(X_test, y_test), 0.9787234042553191)
############################################################################## # Adding stacked classifier as baseline comparison. Stacked classifier can # be found in the static module. In this experiment we consider two types # of stacking: one using logistic regression as meta-classifier # (default configuration) and the other using a Decision Tree. stacked_lr = StackedClassifier(pool_classifiers, random_state=rng) stacked_dt = StackedClassifier(pool_classifiers, random_state=rng, meta_classifier=DecisionTreeClassifier()) # Fitting the DS techniques knorau.fit(X_dsel, y_dsel) kne.fit(X_dsel, y_dsel) desp.fit(X_dsel, y_dsel) metades.fit(X_dsel, y_dsel) ola.fit(X_dsel, y_dsel) mcb.fit(X_dsel, y_dsel) # Fitting the tacking models stacked_lr.fit(X_dsel, y_dsel) stacked_dt.fit(X_dsel, y_dsel) # Calculate classification accuracy of each technique print('Evaluating DS techniques:') print('Classification accuracy of Majority voting the pool: ', model_voting.score(X_test, y_test)) print('Classification accuracy of KNORA-U: ', knorau.score(X_test, y_test)) print('Classification accuracy of KNORA-E: ', kne.score(X_test, y_test)) print('Classification accuracy of DESP: ', desp.score(X_test, y_test)) print('Classification accuracy of META-DES: ', metades.score(X_test, y_test)) print('Classification accuracy of OLA: ', ola.score(X_test, y_test))