You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
" If you wish to use k-nearest neighbors data calculated by another package then provide a tuple of the form (knn_indices, knn_dists). The contents of the tuple should be two numpy arrays of shape (N, n_neighbors) where N is the number of items in the input data. The first array should be the integer indices of the nearest neighbors, and the second array should be the corresponding distances. The nearest neighbor of each item should be itself, e.g. the nearest neighbor of item 0 should be 0, the nearest neighbor of item 1 is 1 and so on. Please note that you will not be able to transform new data in this case. "
If you provide such an input to umap api it raises this error during fit :
File /opt/conda/lib/python3.10/site-packages/umap/umap_.py:1930, in UMAP._validate_parameters(self)
1925 raise ValueError(
1926 "precomputed_knn[0] and precomputed_knn[1]"
1927 " must be numpy arrays of the same size."
1928 )
1929 if not isinstance(self.knn_search_index, NNDescent):
-> 1930 raise ValueError(
1931 "precomputed_knn[2] (knn_search_index)"
1932 " must be an NNDescent object."
1933 )
1934 if self.knn_dists.shape[1] < self.n_neighbors:
1935 warn(
1936 "precomputed_knn has a lower number of neighbors than "
1937 "n_neighbors parameter. precomputed_knn will be ignored"
1938 " and the k-nn will be computed normally."
1939 )
ValueError: precomputed_knn[2] (knn_search_index) must be an NNDescent object.
Is the documentation right ? Can we really provide precomputed_knn from other packages ?
The text was updated successfully, but these errors were encountered:
This feature is available, but only if installing directly from this repo. Otherwise, it will become available when there is a new release of this package.
api documentation here https://umap-learn.readthedocs.io/en/latest/api.html tells :
" If you wish to use k-nearest neighbors data calculated by another package then provide a tuple of the form (knn_indices, knn_dists). The contents of the tuple should be two numpy arrays of shape (N, n_neighbors) where N is the number of items in the input data. The first array should be the integer indices of the nearest neighbors, and the second array should be the corresponding distances. The nearest neighbor of each item should be itself, e.g. the nearest neighbor of item 0 should be 0, the nearest neighbor of item 1 is 1 and so on. Please note that you will not be able to transform new data in this case. "
If you provide such an input to umap api it raises this error during fit :
File /opt/conda/lib/python3.10/site-packages/umap/umap_.py:2288, in UMAP.fit(self, X, y)
2286 self.knn_indices = self.precomputed_knn[0]
2287 self.knn_dists = self.precomputed_knn[1]
-> 2288 self.knn_search_index = self.precomputed_knn[2]
2290 self._validate_parameters()
2292 if self.verbose:
IndexError: tuple index out of range
if this input is provided (knn_indices, knn_dists,None) it raises :
File /opt/conda/lib/python3.10/site-packages/umap/umap_.py:2290, in UMAP.fit(self, X, y)
2287 self.knn_dists = self.precomputed_knn[1]
2288 self.knn_search_index = self.precomputed_knn[2]
-> 2290 self._validate_parameters()
2292 if self.verbose:
2293 print(str(self))
File /opt/conda/lib/python3.10/site-packages/umap/umap_.py:1930, in UMAP._validate_parameters(self)
1925 raise ValueError(
1926 "precomputed_knn[0] and precomputed_knn[1]"
1927 " must be numpy arrays of the same size."
1928 )
1929 if not isinstance(self.knn_search_index, NNDescent):
-> 1930 raise ValueError(
1931 "precomputed_knn[2] (knn_search_index)"
1932 " must be an NNDescent object."
1933 )
1934 if self.knn_dists.shape[1] < self.n_neighbors:
1935 warn(
1936 "precomputed_knn has a lower number of neighbors than "
1937 "n_neighbors parameter. precomputed_knn will be ignored"
1938 " and the k-nn will be computed normally."
1939 )
ValueError: precomputed_knn[2] (knn_search_index) must be an NNDescent object.
Is the documentation right ? Can we really provide precomputed_knn from other packages ?
The text was updated successfully, but these errors were encountered: