scikit-learn-contrib/hdbscan
'wminkowski' metric not working - weight array not passing through properly to the distance function
Open
#112 opened on May 30, 2017
bughelp wanted
Repository metrics
- Stars
- (3,137 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
Hi - I'm trying to use the weighted minkowski metric:
clusterer = hdbscan.HDBSCAN(algorithm='best', alpha=1.0, approx_min_span_tree=True,
gen_min_span_tree=False, leaf_size=40,
metric='wminkowski', min_cluster_size=20, min_samples=5,
core_dist_n_jobs=1, p=2, w=[2, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.1, 0.1])
hdb_clusters = clusterer.fit(data)
Here is the error I get - it looks like the p and w arguments are not passing through all the way:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-174-0c6dd011773f> in <module>()
----> 1 hdb_clusters = clusterer.fit(data)
/usr/local/anaconda/lib/python3.5/site-packages/hdbscan/hdbscan_.py in fit(self, X, y)
862 self._condensed_tree,
863 self._single_linkage_tree,
--> 864 self._min_spanning_tree) = hdbscan(X, **kwargs)
865
866 if self.prediction_data:
/usr/local/anaconda/lib/python3.5/site-packages/hdbscan/hdbscan_.py in hdbscan(X, min_cluster_size, min_samples, alpha, metric, p, leaf_size, algorithm, memory, approx_min_span_tree, gen_min_span_tree, core_dist_n_jobs, cluster_selection_method, allow_single_cluster, match_reference_implementation, **kwargs)
604 approx_min_span_tree,
605 gen_min_span_tree,
--> 606 core_dist_n_jobs, **kwargs)
607
608 return _tree_to_labels(X,
/usr/local/anaconda/lib/python3.5/site-packages/sklearn/externals/joblib/memory.py in __call__(self, *args, **kwargs)
281
282 def __call__(self, *args, **kwargs):
--> 283 return self.func(*args, **kwargs)
284
285 def call_and_shelve(self, *args, **kwargs):
/usr/local/anaconda/lib/python3.5/site-packages/hdbscan/hdbscan_.py in _hdbscan_boruvka_balltree(X, min_samples, alpha, metric, p, leaf_size, approx_min_span_tree, gen_min_span_tree, core_dist_n_jobs, **kwargs)
313 X = X.astype(np.float64)
314
--> 315 tree = BallTree(X, metric=metric, leaf_size=leaf_size, **kwargs)
316 alg = BallTreeBoruvkaAlgorithm(tree, min_samples, metric=metric,
317 leaf_size=leaf_size // 3,
sklearn/neighbors/binary_tree.pxi in sklearn.neighbors.ball_tree.BinaryTree.__init__ (sklearn/neighbors/ball_tree.c:9223)()
sklearn/neighbors/dist_metrics.pyx in sklearn.neighbors.dist_metrics.DistanceMetric.get_metric (sklearn/neighbors/dist_metrics.c:4824)()
sklearn/neighbors/dist_metrics.pyx in sklearn.neighbors.dist_metrics.WMinkowskiDistance.__init__ (sklearn/neighbors/dist_metrics.c:7811)()
TypeError: __init__() takes exactly 2 positional arguments (0 given)