def test_source_competence_kl(): entropy_test = DESKL([create_base_classifier(return_value=1, return_prob=1.0)]) entropy_test.dsel_scores = np.array([[0.33, 0.33, 0.33], [1.0, 0.0, 0.0], [1.0, 0.0, 0.0]]) entropy_test.processed_dsel = np.array([[False], [True], [False]]) entropy_test.n_classes = 3 entropy_test.n_samples = 3 C_src = entropy_test.source_competence() expected = np.array([[0.0], [1.0], [-1.0]]) assert np.allclose(C_src, expected, atol=0.01)
def test_source_competence_kl(): entropy_test = DESKL() entropy_test.n_classifiers_ = 1 entropy_test.dsel_scores_ = np.array([[[0.33, 0.33, 0.33], [1.0, 0.0, 0.0], [1.0, 0.0, 0.0]]]).reshape(3, 1, 3) entropy_test.DSEL_processed_ = np.array([[False], [True], [False]]) entropy_test.n_classes_ = 3 entropy_test.n_samples_ = 3 C_src = entropy_test.source_competence() expected = np.array([[0.0], [1.0], [-1.0]]) assert np.allclose(C_src, expected, atol=0.01)
def test_source_competence_kl(): pool_classifiers = [ create_base_classifier(return_value=1, return_prob=1.0) ] entropy_test = DESKL(pool_classifiers=pool_classifiers) entropy_test.n_classifiers_ = len(pool_classifiers) # 3 Samples, 1 classifier, 3 classes entropy_test.dsel_scores_ = np.array([[[0.33, 0.33, 0.33], [1.0, 0.0, 0.0], [1.0, 0.0, 0.0]]]).reshape(3, 1, 3) entropy_test.DSEL_processed_ = np.array([[False], [True], [False]]) entropy_test.n_classes_ = 3 entropy_test.n_samples_ = 3 C_src = entropy_test.source_competence() expected = np.array([[0.0], [1.0], [-1.0]]) assert np.allclose(C_src, expected, atol=0.01)
def test_check_estimator_DESKL(): check_estimator(DESKL())
def test_deskl(): pool_classifiers, X_dsel, y_dsel, X_test, y_test = setup_classifiers() deskl = DESKL(pool_classifiers, DFP=True) deskl.fit(X_dsel, y_dsel) assert np.isclose(deskl.score(X_test, y_test), 0.90303030303030307)
def test_deskl(knn_methods): pool_classifiers, X_dsel, y_dsel, X_test, y_test = setup_classifiers() deskl = DESKL(pool_classifiers, knn_classifier=knn_methods) deskl.fit(X_dsel, y_dsel) assert np.isclose(deskl.score(X_test, y_test), 0.97340425531914898)