compute_dist¶
-
hyppo.tools.compute_dist(*args, metric='euclidean', workers=1, **kwargs)¶ Distance matrices for the input matrices.
- Parameters
*args (
ndarrayoffloat) -- Variable length input data matrices. The shapes must be(n, p),(n, q), etc., where n is the number of samples and p and q are the number of dimensions.metric (
str,callable, orNone, default"euclidean") -- A function that computes the distance among the samples within each data matrix. Valid strings formetricare, as defined insklearn.metrics.pairwise_distances,From scikit-learn: [
"euclidean","cityblock","cosine","l1","l2","manhattan"] See the documentation forscipy.spatial.distancefor details on these metrics.From scipy.spatial.distance: [
"braycurtis","canberra","chebyshev","correlation","dice","hamming","jaccard","kulsinski","mahalanobis","minkowski","rogerstanimoto","russellrao","seuclidean","sokalmichener","sokalsneath","sqeuclidean","yule"] See the documentation forscipy.spatial.distancefor details on these metrics.
Set to
Noneor"precomputed"if matrices are already distance matrices. To call a custom function, either create the distance matrix before-hand or create a function of the formmetric(x, **kwargs)wherexis the data matrix for which pairwise distances are calculated and**kwargsare extra arguements to send to your custom function.workers (
int, default1) -- The number of cores to parallelize the p-value computation over. Supply-1to use all cores available to the Process.**kwargs -- Arbitrary keyword arguments provided to
sklearn.metrics.pairwise_distancesor a custom distance function.
- Returns
dist_matrices (
tupleofndarrayoffloat) -- Distance matrices based on the metric provided by the user. One matrix is returned for each input matrix, in the same order.