0

I'm running HDBSCAN for weeks now on gene expression datasets and everything went perfectly well, but lately it refuses to run :


    clusterer = hdbscan.HDBSCAN(min_cluster_size=10, min_samples=1).fit(df)
    
    TypeError: 'float' object cannot be interpreted as an integer

It doesn't make sense since the dataset i'm providing to HDBSCAN is only comprised of float values since the beginning, and it worked perfectly. Plus, it's complete non sense to convert my datas into integers, it would lost all their meaning.

Any idea on what's happening here ?

Here's the full error message :

    TypeError                                 Traceback (most recent call last)
Cell In[18], line 1
----> 1 clusterer = hdbscan.HDBSCAN(min_cluster_size=10, min_samples=1).fit(df.select_dtypes(include='number'))
      2 df_cluster = pd.DataFrame({'samples':df['SAMPLES'],'labels': df['labels'], 'clusters': clusterer.labels_,'probabilities': clusterer.probabilities_})
      3 df_cluster

File ~/opt/anaconda3/envs/env_test/lib/python3.8/site-packages/hdbscan/hdbscan_.py:1205, in HDBSCAN.fit(self, X, y)
   1195 kwargs.pop("prediction_data", None)
   1196 kwargs.update(self._metric_kwargs)
   1198 (
   1199     self.labels_,
   1200     self.probabilities_,
   1201     self.cluster_persistence_,
   1202     self._condensed_tree,
   1203     self._single_linkage_tree,
   1204     self._min_spanning_tree,
-> 1205 ) = hdbscan(clean_data, **kwargs)
   1207 if self.metric != "precomputed" and not self._all_finite:
   1208     # remap indices to align with original data in the case of non-finite entries.
   1209     self._condensed_tree = remap_condensed_tree(
   1210         self._condensed_tree, internal_to_raw, outliers
   1211     )

File ~/opt/anaconda3/envs/env_test/lib/python3.8/site-packages/hdbscan/hdbscan_.py:824, in hdbscan(X, min_cluster_size, min_samples, alpha, cluster_selection_epsilon, max_cluster_size, 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)
    820 elif metric in KDTREE_VALID_METRICS:
    821     # TO DO: Need heuristic to decide when to go to boruvka;
    822     # still debugging for now
    823     if X.shape[1] > 60:
--> 824         (single_linkage_tree, result_min_span_tree) = memory.cache(
    825             _hdbscan_prims_kdtree
    826         )(
    827             X,
    828             min_samples,
    829             alpha,
    830             metric,
    831             p,
    832             leaf_size,
    833             gen_min_span_tree,
    834             **kwargs
    835         )
    836     else:
    837         (single_linkage_tree, result_min_span_tree) = memory.cache(
    838             _hdbscan_boruvka_kdtree
    839         )(
   (...)
    849             **kwargs
    850         )

File ~/opt/anaconda3/envs/env_test/lib/python3.8/site-packages/joblib/memory.py:349, in NotMemorizedFunc.__call__(self, *args, **kwargs)
    348 def __call__(self, *args, **kwargs):
--> 349     return self.func(*args, **kwargs)

File ~/opt/anaconda3/envs/env_test/lib/python3.8/site-packages/hdbscan/hdbscan_.py:265, in _hdbscan_prims_kdtree(X, min_samples, alpha, metric, p, leaf_size, gen_min_span_tree, **kwargs)
    260 core_distances = tree.query(
    261     X, k=min_samples + 1, dualtree=True, breadth_first=True
    262 )[0][:, -1].copy(order="C")
    264 # Mutual reachability distance is implicit in mst_linkage_core_vector
--> 265 min_spanning_tree = mst_linkage_core_vector(X, core_distances, dist_metric, alpha)
    267 # Sort edges of the min_spanning_tree by weight
    268 min_spanning_tree = min_spanning_tree[np.argsort(min_spanning_tree.T[2]), :]

File hdbscan/_hdbscan_linkage.pyx:55, in hdbscan._hdbscan_linkage.mst_linkage_core_vector()

File hdbscan/_hdbscan_linkage.pyx:144, in hdbscan._hdbscan_linkage.mst_linkage_core_vector()

TypeError: 'float' object cannot be interpreted as an integer
Nozelar
  • 1
  • 1

1 Answers1

0

I had the same problem, so I tried to install the library directly from GitHub, and it worked for me. So here is what you can try:

  1. Uninstall it using pip uninstall hdbscan
  2. Use the following command in your cmd to install the library from GitHub: pip install --upgrade git+https://github.com/scikit-learn-contrib/hdbscan.git#egg=hdbscan
yzereh
  • 1