MaartenGr / MaartenGr/BERTopic

TypeError: 'numpy.float64' object cannot be interpreted as an integer

Open
#1,412 19 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.8k
Forks
920
Avg merge
22h 24m
Merged PRs (30d)
5

Description

Hey! I had the problem mentioned in this [thread](https://github.com/MaartenGr/BERTopic/issues/1411), but after the update the problem was solved. Another one appeared, I get this error:

```
TypeError Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/bertopic/_bertopic.py](https://localhost:8080/#) in _cluster_embeddings(self, umap_embeddings, documents, partial_fit, y)
3217 try:
-> 3218 self.hdbscan_model.fit(umap_embeddings, y=y)
3219 except TypeError:

9 frames
hdbscan/_hdbscan_tree.pyx in hdbscan._hdbscan_tree.condense_tree()

hdbscan/_hdbscan_tree.pyx in hdbscan._hdbscan_tree.condense_tree()

TypeError: 'numpy.float64' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/hdbscan/hdbscan_.py](https://localhost:8080/#) in _tree_to_labels(X, single_linkage_tree, min_cluster_size, cluster_selection_method, allow_single_cluster, match_reference_implementation, cluster_selection_epsilon, max_cluster_size)
76 set of labels and probabilities.
77 """
---> 78 condensed_tree = condense_tree(single_linkage_tree, min_cluster_size)
79 stability_dict = compute_stability(condensed_tree)
80 labels, probabilities, stabilities = get_clusters(

hdbscan/_hdbscan_tree.pyx in hdbscan._hdbscan_tree.condense_tree()

hdbscan/_hdbscan_tree.pyx in hdbscan._hdbscan_tree.condense_tree()

TypeError: 'numpy.float64' object cannot be interpreted as an integer
```
I checked the data that I put into the model and there is nothing there in this format. What's more, I checked it on the file I was working on yesterday, which was reprocessed successfully. Suddenly I am getting this error on it as well. Any ideas?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at bertopic/_bertopic.py in _cluster_embeddings and inspect the hdbscan_model.fit call shown in the traceback. Reproduce the failure and determine whether the issue is in BERTopic's clustering path or the hdbscan dependency; done means the cause is confirmed and clustering succeeds under a tested fix or documented compatible setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.