pairwisedist.pairwisedist.sharpened_cosine_distance

pairwisedist.pairwisedist.sharpened_cosine_distance(data: ndarray, sharpen_exponent: float = 16, exp_noise_floor: float = 0.1, rowvar: bool = True, similarity: bool = False) ndarray

Calculates the pairwise sharpened cosine distance matrix for a given array of n samples by p features, as described in a since-deleted tweet by Brandon Rohrer. You can read more about sharpened cosine distance `here <https://github.com/brohrer/sharpened-cosine-similarity>_. The sharpened cosine distance ranges between 0 (highest similarity) and 1 (highest dissimilarity). :param data: an n-by-p numpy array of n samples by p features, to calculate pairwise distance on. :type data: np.ndarray :param sharpen_exponent: :type sharpen_exponent: float (default=16) :param exp_noise_floor: :type exp_noise_floor: float (default=0.1) :param rowvar: If True, calculates the pairwise distance between the rows of ‘data’. If False, calculate the pairwise distance between the columns of ‘data’. :type rowvar: bool (default=True) :param similarity: If False, returns a pairwise distance matrix (0 means closest, 1 means furthest). If True, returns a pairwise similarity matrix (1 means most similar, 0 means most different). :type similarity: bool (default=False) :return: an n-by-n numpy array of pairwise sharpened cosine distance scores. :rtype: np.ndarray