Exemplo n.º 1
0
def test_deterministic_predictions_tree():
    X, y = make_blobs(n_samples=300, centers=[(0, 0), (1, 1)], random_state=42)

    clf1 = SimilarityTreeClassifier(random_state=42)
    clf1.fit(X, y)
    clf2 = SimilarityTreeClassifier(random_state=42)
    clf2.fit(X, y)

    y_pred1 = clf1.predict(X)
    y_pred2 = clf2.predict(X)
    assert_array_equal(y_pred1, y_pred2)
Exemplo n.º 2
0
def test_setting_attributes_tree(data):
    X, y = data
    clf = SimilarityTreeClassifier(random_state=42, n_directions=2)
    clf.fit(X, y)
    y_pred = clf.predict(X)

    assert clf.random_state == 42
    assert clf.n_directions == 2
Exemplo n.º 3
0
def test_similarity_tree_classifier_prediction(data):
    X, y = data
    X_train, X_test, y_train, y_test = train_test_split(X,
                                                        y,
                                                        test_size=0.3,
                                                        random_state=42)

    clf = SimilarityTreeClassifier()
    clf.fit(X_train, y_train)

    y_pred = clf.predict(X_test)
    assert y_pred.shape == (X_test.shape[0], )
    assert accuracy_score(y_test, y_pred) > 0.9