@@ -338,6 +338,10 @@ class RobustSingleLinkage(BaseEstimator, ClusterMixin):
338
338
metric parameter.
339
339
If metric is "precomputed", X is assumed to be a distance matrix and
340
340
must be square.
341
+
342
+ metric_params : dict, option (default={})
343
+ Keyword parameter arguments for calling the metric (for example
344
+ the p values if using the minkowski metric).
341
345
342
346
algorithm : string, optional (default='best')
343
347
Exactly which algorithm to use; hdbscan has variants specialised
@@ -380,7 +384,7 @@ class RobustSingleLinkage(BaseEstimator, ClusterMixin):
380
384
381
385
def __init__ (self , cut = 0.4 , k = 5 , alpha = 1.4142135623730951 , gamma = 5 ,
382
386
metric = 'euclidean' , algorithm = 'best' , core_dist_n_jobs = 4 ,
383
- ** kwargs ):
387
+ metric_params = {} ):
384
388
385
389
self .cut = cut
386
390
self .k = k
@@ -389,10 +393,7 @@ def __init__(self, cut=0.4, k=5, alpha=1.4142135623730951, gamma=5,
389
393
self .metric = metric
390
394
self .algorithm = algorithm
391
395
self .core_dist_n_jobs = core_dist_n_jobs
392
-
393
- self ._metric_kwargs = kwargs
394
-
395
- self ._cluster_hierarchy = None
396
+ self .metric_params = metric_params
396
397
397
398
def fit (self , X , y = None ):
398
399
"""Perform robust single linkage clustering from features or
@@ -413,7 +414,7 @@ def fit(self, X, y=None):
413
414
X = check_array (X , accept_sparse = 'csr' )
414
415
415
416
kwargs = self .get_params ()
416
- kwargs .update (self ._metric_kwargs )
417
+ kwargs .update (self .metric_params )
417
418
418
419
self .labels_ , self ._cluster_hierarchy = robust_single_linkage (
419
420
X , ** kwargs )
@@ -441,7 +442,7 @@ def fit_predict(self, X, y=None):
441
442
442
443
@property
443
444
def cluster_hierarchy_ (self ):
444
- if self . _cluster_hierarchy is not None :
445
+ if hasattr ( self , '_cluster_hierarchy' ) :
445
446
return SingleLinkageTree (self ._cluster_hierarchy )
446
447
else :
447
448
raise AttributeError ('No single linkage tree was generated; try running fit'
0 commit comments