[BUG] Error out when using 'cosine' distance metrics (ufunc 'correct_alternative_cosine' did not contain a loop with signature matching types)
See original GitHub issueHi,
I am actually using umap
, but i know it is using pynndescent
under the hood. When I am running umap with > 10k rows, I get following errors:
numpy.core._exceptions.UFuncTypeError: ufunc 'correct_alternative_cosine' did not contain a loop with signature matching types <class 'numpy.dtype[float32]'> -> None
This is the minimal reproducible codes
import numpy as np
import umap
print(100, umap.UMAP(metric="cosine").fit(np.random.random([100,10])).embedding_.shape)
print(1000, umap.UMAP(metric="cosine").fit(np.random.random([1000,10])).embedding_.shape)
print(10000, umap.UMAP(metric="cosine").fit(np.random.random([10000,10])).embedding_.shape)
This is the environment:
python 3.8.2
colorama 0.4.4 Cross-platform colored terminal text.
joblib 1.1.0 Lightweight pipelining with Python functions
llvmlite 0.34.0 lightweight wrapper around basic LLVM functionality
numba 0.51.2 compiling Python code using LLVM
numpy 1.22.0 NumPy is the fundamental package for array computing with Python.
pynndescent 0.5.5 Nearest Neighbor Descent
scikit-learn 1.0.2 A set of python modules for machine learning and data mining
scipy 1.6.1 SciPy: Scientific Library for Python
threadpoolctl 3.0.0 threadpoolctl
tqdm 4.62.3 Fast, Extensible Progress Meter
umap-learn 0.5.2 Uniform Manifold Approximation and Projection
This did not happen in the prev version of my application. I suspect might be due to the new numpy
version. However, because i am also using hdbscan
, it does not work with any numpy version except 1.22.0
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
What does "ufunc did not contain a loop with signature ...
Though I guess I'm not sure of the argument name in the function either, The input should be an array, I think, not...
Read more >Pandas : Python: ufunc 'add' did not contain a loop ... - YouTube
Pandas : Python: ufunc 'add' did not contain a loop with signature matching types dtype('S21') dtype('S21') dtype('S21') [ Beautify Your ...
Read more >Different Types of Distances Used in Machine Learning
Distance functions are often used as error or cost functions to be minimized in an optimization problem.We have often heard the use of...
Read more >An end-to-end approach for the verification problem
In this contribution, we augment the metric learn- ing setting by introducing a parametric pseudo- distance, trained jointly with the encoder. Sev-.
Read more >cosine_similarity between 2 pandas df column to get cosine ...
However, even if we did convert it to list of lists, the next problem arises: ... So, let's limit to pairwise comparison, artificially...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another option (not having to mess around in an install env) is to do the following somewhere in your own code:
Hello,
I just took the same bullet.
Environment:
I used a higher version of Numpy as a fix to https://github.com/scikit-learn-contrib/hdbscan/issues/457.
Having that one fixed, I stumbled on this issue. So I tried the fix you suggested in:
This change works for me. However, small correction here: the distance definition is not in
umap/distances.py
but inpynndescent/distances.py
.So, if you are using
venv
, in.venv/lib/pythonX.X/site-packages/pynndescent/distances.py
apply the changes suggested.