Skip to content

Commit 91f913d

Browse files
authored
Fix for issue #88 -- need to ensure we have the right tree type
1 parent 181a10d commit 91f913d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

hdbscan/hdbscan_.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,11 +883,19 @@ def generate_prediction_data(self):
883883
you are intending to use functions from ``hdbscan.prediction``.
884884
"""
885885

886-
if self.metric != 'precomputed':
886+
if self.metric not in FAST_METRICS:
887887
min_samples = self.min_samples or self.min_cluster_size
888+
if self.metric in KDTree.valid_metrics:
889+
tree_type = 'kdtree'
890+
elif self.metric in BallTree.valid_metrics:
891+
tree_type = 'balltree'
892+
else:
893+
warn('Metric {} not supported for prediction data!'.format(self.metric))
894+
return
895+
888896
self._prediction_data = PredictionData(
889897
self._raw_data, self.condensed_tree_, min_samples,
890-
tree_type='kdtree', metric=self.metric,
898+
tree_type=tree_type, metric=self.metric,
891899
**self._metric_kwargs
892900
)
893901
else:

0 commit comments

Comments
 (0)