selector.measures.converter
#
Module for converting similarity measures to distance/dissimilarity measures.
- selector.measures.converter.co_occurrence(x: ndarray) ndarray #
Calculate distance array from frequency using the co-occurrence method.
\[\delta_{ij} = \left(1 + \frac{f_{ij}\sum_{i,j}{f_{ij}}}{\sum_{i}{f_{ij}}\sum_{j}{f_{ij}}} \right)^{-1}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), and \(f_{ij}\) is their frequency.
Parameters#
- xndarray
Frequency array.
Returns#
- distndarray
Co-occurrence array.
- selector.measures.converter.correlation(x: ndarray) ndarray #
Calculate distance array from correlation array.
\[\delta_{ij} = \sqrt{1 - r_{ij}}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), and \(r_{ij}\) is their correlation.
Parameters#
- xndarray
Correlation array.
Returns#
- distndarray
Distance array.
- selector.measures.converter.covariance(x: ndarray) ndarray #
Calculate distance array from similarity using the covariance method.
\[\delta_{ij} = \sqrt{s_{ii}+s_{jj}-2s_{ij}}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), \(s_{ii}\) and \(s_{jj}\) are the variances of feature \(i\) and feature \(j\), and \(s_{ij}\) is the covariance between the two features.
Parameters#
- xndarray
Covariance array.
Returns#
- distndarray
Distance array.
- selector.measures.converter.exponential(x: ndarray) ndarray #
Calculate distance matrix from similarity using the exponential method.
\[\delta_{ij} = -\ln{\frac{s_{ij}}{max(s_{ij})}}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), and \(s_{ij}\) is their similarity coefficient.
Parameters#
- xndarray
Similarity array.
Returns#
- distndarray
Distance array.
- selector.measures.converter.gaussian(x: ndarray) ndarray #
Calculate distance matrix from similarity using the Gaussian method.
\[\delta_{ij} = \sqrt{-\ln{\frac{s_{ij}}{max(s_{ij})}}}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), and \(s_{ij}\) is their similarity coefficient.
Parameters#
- xndarray
Similarity array.
Returns#
- distndarray
Distance array.
- selector.measures.converter.gravity(x: ndarray) ndarray #
Calculate distance array from frequency using the gravity method.
\[\delta_{ij} = \sqrt{\frac{\sum_{i}{f_{ij}}\sum_{j}{f_{ij}}} {f_{ij}\sum_{i,j}{f_{ij}}}}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), and \(f_{ij}\) is their frequency.
Parameters#
- xndarray
Symmetric frequency array.
Returns#
- distndarray
Symmetric gravity array.
- selector.measures.converter.probability(x: ndarray) ndarray #
Calculate distance array from probability array.
\[\delta_{ij} = \sqrt{-\ln{\frac{s_{ij}}{max(s_{ij})}}}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), and \(p_{ij}\) is their probablity.
Parameters#
- xndarray
Symmetric probability array.
Returns#
- distndarray
Distance array.
- selector.measures.converter.reciprocal(x: ndarray) ndarray #
Calculate distance array from similarity using the reciprocal method.
\[\delta_{ij} = \frac{1}{s_{ij}}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), and \(s_{ij}\) is their similarity coefficient.
Parameters#
- xndarray
Similarity array.
Returns#
- distndarray
Distance array.
- selector.measures.converter.reverse(x: ndarray) ndarray #
Calculate distance array from similarity using the reverse method.
\[\delta_{ij} = min(s_{ij}) + max(s_{ij}) - s_{ij}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), \(s_{ij}\) is their similarity coefficient, and \(max\) and \(min\) are the maximum and minimum values across the entire similarity array.
Parameters#
- xndarray
Similarity array.
Returns#
- distndarray
Distance array.
- selector.measures.converter.sim_to_dist(x: Union[int, float, ndarray], metric: str, scaling_factor: float = 1.0) Union[float, ndarray] #
Convert similarity coefficients to distance array.
Parameters#
- xfloat or ndarray
A similarity value as float, or a 1D or 2D array of similarity values. If 2D, the array is assumed to be symmetric.
- metricstr
String or integer specifying which conversion metric to use. Supported metrics are “reverse”, “reciprocal”, “exponential”, “gaussian”, “membership”, “correlation”, “transition”, “co-occurrence”, “gravity”, “confusion”, “probability”, and “covariance”.
- scaling_factorfloat, optional
Scaling factor for the distance array. Default is 1.0.
Returns#
- distfloat or ndarray
Distance value or array.
- selector.measures.converter.transition(x: ndarray) ndarray #
Calculate distance array from frequency using the transition method.
\[\delta_{ij} = \frac{1}{\sqrt{f_{ij}}}\]where \(\delta_{ij}\) is the distance between points \(i\) and \(j\), and \(f_{ij}\) is their frequency.
Parameters#
- xndarray
Symmetric frequency array.
Returns#
- distndarray
Distance array.