Example #1
0
def test_classify(index, expected):
    query = np.atleast_2d([1, 1])

    knora_u_test = KNORAU(create_pool_classifiers())
    knora_u_test.fit(X_dsel_ex1, y_dsel_ex1)
    knora_u_test.DFP_mask = np.ones(knora_u_test.n_classifiers)
    knora_u_test.neighbors = neighbors_ex1[index, :]
    knora_u_test.distances = distances_ex1[index, :]
    prediction = knora_u_test.classify_instance(query)

    assert prediction == expected
Example #2
0
def test_classify(index, expected):
    query = np.atleast_2d([1, 1])

    knora_u_test = KNORAU(create_pool_classifiers())
    knora_u_test.fit(X_dsel_ex1, y_dsel_ex1)
    knora_u_test.DFP_mask = np.ones(knora_u_test.n_classifiers)
    knora_u_test.neighbors = neighbors_ex1[index, :]
    knora_u_test.distances = distances_ex1[index, :]

    predictions = []
    for clf in knora_u_test.pool_classifiers:
        predictions.append(clf.predict(query)[0])

    prediction = knora_u_test.classify_instance(query, np.array(predictions))

    assert prediction == expected