majid bhatti
majid bhatti

Reputation: 103

Error in importing module of python library scipy

I am working on clustering in python. The package I want to import is

from scipy.spatial.distance import dist

but this is showing the following error.

ImportError: cannot import name 'dist' from 'scipy.spatial.distance' (C:\Users\majid\Anaconda3\lib\site-packages\scipy\spatial\distance.py)

Upvotes: 1

Views: 408

Answers (1)

Dwij Sheth
Dwij Sheth

Reputation: 300

Instead of importing dist you need to import pdist or cdist based on your requirement as per the SciPy documentation:

pdist(X[, metric])

Pairwise distances between observations in n-dimensional space.

cdist(XA, XB[, metric])

Compute distance between each pair of the two collections of inputs.

Upvotes: 1

Related Questions