Python – Pairwise distances of n-dimensional space array
scipy.stats.pdist(array, axis=0) function calculates the Pairwise distances between observations in n-dimensional space.
array: Input array or object having the elements to calculate the Pairwise distances
axis: Axis along which to be computed. By default axis = 0
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Returns : Pairwise distances of the array elements based on the set parameters.
Code #1 : 2D Array
Value of pdist is : [19.33907961]
Code #2 : 3D Array
Value of pdist is : [21.11871208 24.91987159 19.33907961 5.38516481 2.82842712 6.40312424]