예제 #1
0
def test_DFP_is_used():
    query = np.atleast_2d([1, 0])
    ds_test = DS(create_pool_classifiers(), DFP=True, safe_k=3)
    ds_test.fit(X_dsel_ex1, y_dsel_ex1)
    ds_test.processed_dsel = dsel_processed_ex1
    ds_test.DSEL_target = y_dsel_ex1
    ds_test.DSEL_data = X_dsel_ex1
    ds_test.neighbors = neighbors_ex1[0, :]
    ds_test.distances = distances_ex1[0, :]
    ds_test.classify_instance = MagicMock(return_value=0)
    ds_test.predict(query)
    assert np.array_equal(ds_test.DFP_mask, np.array([1, 1, 0]))
예제 #2
0
파일: test_base.py 프로젝트: qhduan/DESlib
def test_label_encoder_only_dsel():
    X_dsel_ex1 = np.array([[-1, 1], [-0.75, 0.5], [-1.5, 1.5]])
    y_dsel_ex1 = np.array(['cat', 'dog', 'plane'])

    query = np.atleast_2d([[1, 0], [-1, -1]])
    ds_test = DS(create_pool_classifiers_dog_cat_plane(), k=2)
    ds_test.fit(X_dsel_ex1, y_dsel_ex1)
    ds_test.neighbors = neighbors_ex1[0, :]
    ds_test.distances = distances_ex1[0, :]
    ds_test.classify_instance = Mock()
    ds_test.classify_instance.side_effect = [1, 0]
    predictions = ds_test.predict(query)
    assert np.array_equal(predictions, ['dog', 'cat'])