umap: Intermittent ZeroDivisionError: division by zero

This is a fantastic library, thanks very much for your great work. Periodically though, I’m getting a ZeroDivisionError: division by zero while building a UMAP projection. My data doesn’t change, nor does the way I call the UMAP constructor:

model = umap.UMAP(n_neighbors=25, min_dist=0.00001, metric='correlation')
fit_model = model.fit_transform( np.array(image_vectors) )

Once in a while (maybe 5% of runs) this throws the following trace (umap version 0.1.5):

File "imageplot.py", line 278, in <module>
    Imageplot(image_dir=sys.argv[1], output_dir='output')
  File "imageplot.py", line 30, in __init__
    self.create_2d_projection()
  File "imageplot.py", line 148, in create_2d_projection
    model = self.build_model(image_vectors)
  File "imageplot.py", line 175, in build_model
    return model.fit_transform( np.array(image_vectors) )
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 1402, in fit_transform
    self.fit(X)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 1361, in fit
    self.verbose
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 385, in rptree_leaf_array
    angular=angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 310, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 315, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 315, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 310, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 315, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 315, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 310, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 310, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 310, in make_tree
    angular)
  File "/Users/yaledhlab/anaconda3/lib/python3.6/site-packages/umap/umap_.py", line 301, in make_tree
    rng_state)
ZeroDivisionError: division by zero

I took a quick look at the make_tree function but that didn’t show much–the real problem seems to be swallowed in the stacktrace by the recursion. Do you have an idea what might cause this? I’ll upgrade to the latest master and see if the problem continues.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I think the problem is that that should be sigmas[k] instead, but I’ll have to trace through the whole thing to be sure.