inverse_transform doesn't work on 1D data
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 871
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 5
Description
Is it possible to do an inverse transform on a 1D embedding? This is what I see:
from umap import UMAP
import numpy as np
x = np.random.random(size = (100,1000))
umap_1D = UMAP(n_components=1)
transformed = umap_1D.fit_transform(x)
umap_1D_max = transformed.max()
umap_1D_min = transformed.min()
to_be_inverted = np.random.random(size=(1,10))
generated = umap_1D.inverse_transform(to_be_inverted)
generated
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-45-2c8de5c09c47> in <module>()
8 umap_1D_min = transformed.min()
9 to_be_inverted = np.random.random(size=(1,10))
---> 10 generated = umap_1D.inverse_transform(to_be_inverted)
11 generated
/usr/local/lib/python3.6/dist-packages/umap/umap_.py in inverse_transform(self, X)
2202 # build Delaunay complex (Does this not assume a roughly euclidean output metric)?
2203 deltri = scipy.spatial.Delaunay(
-> 2204 self.embedding_, incremental=True, qhull_options="QJ"
2205 )
2206 neighbors = deltri.simplices[deltri.find_simplex(X)]
qhull.pyx in scipy.spatial.qhull.Delaunay.__init__()
qhull.pyx in scipy.spatial.qhull._Qhull.__init__()
ValueError: Need at least 2-D data
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at umap/umap_.py in inverse_transform, especially the scipy.spatial.Delaunay call shown in the traceback. Reproduce the supplied 1D embedding example and trace how the one-dimensional embedding reaches that entry point. Done means inverse_transform handles n_components=1 without the reported ValueError.
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
- Mostly clear
- Newbie friendliness
- 32/100