Closed matchy233 closed 1 year ago
sklearn.neighbors.DistanceMetric
was removed in sklearn 1.3.0 (released 2023-06-30; here it is in 1.2.2, gone in 1.3.0, removal commit).
Seems like you're supposed to use sklearn.metrics.DistanceMetric
, which is present since sklearn 1.0.2.
A fix here could be to update the import, and constrain the sklearn
requirement to >=1.0.2
.
For easier searching, the error that led me here was:
from sklearn.neighbors import DistanceMetric
# ImportError: cannot import name 'DistanceMetric' from 'sklearn.neighbors' (…/lib/python3.9/site-packages/sklearn/neighbors/__init__.py)
You either have to pin scikit-learn<1.3
, or change the import:
-from sklearn.neighbors import DistanceMetric
+from sklearn.metrics import DistanceMetric
Thank you both for bringing this to my attention. I've merged Ryan's pull request (sklearn 1.0.2 is over a year old at this point so it feels okay to require it), but will credit you both in the change log.
Hi, thanks for the timely fix! please note that this is still an issue if installing bbknn from conda or pip.
I think I pretty much just have docstring updates left in terms of tying up loose ends.
Alright, 1.6.0 is now live on pip!
it seems something is not right cause trying to run it after installation from pip results in segmentation fault. no other error messages are issued and I'm working on a subset of ~2000 cells so i don't really think it's a memory issue. any idea what to check? thanks @ktpolanski !!
It's probably annoy acting up. Try to run with computation="cKDTree"
and/or install a different annoy version
yes i somehow was breaking some dependencies, i installed all in a new conda env and it works.
WARNING: consider updating your call to make use of
computation` is indeed sorted with "cKDTree" (but not if calling bbknn from
scanpy.external` so that might need updating) thank you!
We are currently trying to import
DistanceMetrics
fromsklearn.neighbors
inbbknn/matrix.py
(link to code) but this is only possible forscikit_learn<1.0.0
.DistanceMetrics
is moved tosklearn.metric
in the later versions ofsklearn
.I will raise a PR for fixing this via handling the
ImportError
-- but would like to hear opinions from the maintainers for sure!