Пример #1
0
def test_classify(index, expected):
    query = np.atleast_2d([1, 1])

    knop_test = KNOP(create_pool_classifiers())
    knop_test.fit(X_dsel_ex1, y_dsel_ex1)

    knop_test.DFP_mask = np.ones(knop_test.n_classifiers)
    knop_test.neighbors = neighbors_ex1[index, :]
    knop_test.distances = distances_ex1[index, :]
    prediction = knop_test.classify_instance(query)

    assert prediction == expected
Пример #2
0
def test_classify(index, expected):
    query = np.atleast_2d([1, 1])

    knop_test = KNOP(create_pool_classifiers())
    knop_test.fit(X_dsel_ex1, y_dsel_ex1)

    knop_test.DFP_mask = np.ones(knop_test.n_classifiers)
    knop_test.neighbors = neighbors_ex1[index, :]
    knop_test.distances = distances_ex1[index, :]

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

    predicted_label = knop_test.classify_instance(query, np.array(predictions))

    assert predicted_label == expected