Skip to content

Commit

Permalink
Test of approximate_predict
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcinnes committed Feb 18, 2017
1 parent d52fb8b commit 50a7ef9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion hdbscan/tests/test_hdbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
assert_not_in,
assert_no_warnings,
if_matplotlib)
from hdbscan import HDBSCAN, hdbscan, validity_index
from hdbscan import (HDBSCAN,
hdbscan,
validity_index,
approximate_predict,
membership_vector,
all_points_membership_vectors)
# from sklearn.cluster.tests.common import generate_clustered_data
from sklearn.datasets import make_blobs
from sklearn.utils import shuffle
Expand Down Expand Up @@ -438,6 +443,14 @@ def test_hdbscan_min_span_tree_availability():
tree = clusterer.minimum_spanning_tree_
assert tree is None

def test_hdbscan_approximate_predict():
clusterer = HDBSCAN(prediction_data=True).fit(X)
cluster, prob = approximate_predict(clusterer, np.array([[-1.5, -1.0]]))
assert_equal(cluster, 2)
cluster, prob = approximate_predict(clusterer, np.array([[1.5, -1.0]]))
assert_equal(cluster, 1)
cluster, prob = approximate_predict(clusterer, np.array([[0.0, 0.0]]))
assert_equal(cluster, -1)

def test_hdbscan_badargs():
assert_raises(ValueError,
Expand Down

0 comments on commit 50a7ef9

Please sign in to comment.