umap
umap copied to clipboard
inverse_transform doesn't work on 1D data
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
Not at present unfortunately. It is possible, but it would need a separate code path to do so, which doesn't exist at this time. Sorry.
I have exactly the same problem. So just adding my +1 for this feature.