public class Similarity extends Object
SemanticSpace
.Modifier and Type | Class and Description |
---|---|
static class |
Similarity.SimType
A type of similarity function to use when generating a
Method |
Modifier and Type | Method and Description |
---|---|
static double |
averageCommonFeatureRank(double[] a,
double[] b)
Computes the Average Common Feature Rank between the two feature arrays.
|
static double |
averageCommonFeatureRank(int[] a,
int[] b)
Computes the Average Common Feature Rank between the two feature arrays.
|
static double |
averageCommonFeatureRank(Vector a,
Vector b)
Computes the Average Common Feature Rank between the two feature arrays.
|
static double |
correlation(double[] arr1,
double[] arr2)
Returns the Pearson product-moment correlation coefficient of the two
arrays.
|
static double |
correlation(DoubleVector arr1,
DoubleVector arr2)
Returns the Pearson product-moment correlation coefficient of the two
Vector s. |
static double |
correlation(int[] arr1,
int[] arr2)
Returns the Pearson product-moment correlation coefficient of the two
arrays.
|
static double |
correlation(IntegerVector arr1,
DoubleVector arr2)
Returns the Pearson product-moment correlation coefficient of the two
Vector s. |
static double |
correlation(Vector a,
Vector b)
Returns the Pearson product-moment correlation coefficient of the two
Vector s. |
static double |
cosineSimilarity(double[] a,
double[] b)
Returns the cosine similarity of the two arrays.
|
static double |
cosineSimilarity(DoubleVector a,
DoubleVector b)
Returns the cosine similarity of the two
DoubleVector . |
static double |
cosineSimilarity(int[] a,
int[] b)
Returns the cosine similarity of the two arrays.
|
static double |
cosineSimilarity(IntegerVector a,
IntegerVector b)
Returns the cosine similarity of the two
DoubleVector . |
static double |
cosineSimilarity(Vector a,
Vector b)
Returns the cosine similarity of the two
DoubleVector . |
static double |
euclideanDistance(double[] a,
double[] b)
Returns the euclidian distance between two arrays of {code double}s.
|
static double |
euclideanDistance(DoubleVector a,
DoubleVector b)
Returns the euclidian distance between two
DoubleVector s. |
static double |
euclideanDistance(int[] a,
int[] b)
Returns the euclidian distance between two arrays of {code double}s.
|
static double |
euclideanDistance(IntegerVector a,
IntegerVector b)
Returns the euclidian distance between two
DoubleVector s. |
static double |
euclideanDistance(Vector a,
Vector b)
Returns the euclidian distance between two
Vector s. |
static double |
euclideanSimilarity(double[] a,
double[] b)
Returns the euclidian similiarty between two arrays of values.
|
static double |
euclideanSimilarity(int[] a,
int[] b)
Returns the euclidian similiarty between two arrays of values.
|
static double |
euclideanSimilarity(Vector a,
Vector b)
Returns the euclidian similiarty between two arrays of values.
|
static Method |
getMethod(Similarity.SimType similarityType)
Deprecated.
The
getSimilarity(SimType,double[],double[]) method
should be used instead.
Returns the Method for getting the similarity of two double[] based on the specified similarity type. |
static double |
getSimilarity(Similarity.SimType similarityType,
double[] a,
double[] b)
Calculates the similarity of the two vectors using the provided
similarity measure.
|
static <T extends Vector> |
getSimilarity(Similarity.SimType similarityType,
T a,
T b)
Calculates the similarity of the two vectors using the provided
similarity measure.
|
static SimilarityFunction |
getSimilarityFunction(Similarity.SimType similarityType) |
static double |
goodmanKruskalGamma(DoubleVector a,
DoubleVector b)
Computes the Goodman-Kruskal
Gamma coefficient, which is preferrable to Kendall's τ and
Spearman's ρ when there are many ties in the data.
|
static double |
jaccardIndex(double[] a,
double[] b)
Computes the Jaccard
index comparing the similarity both arrays when viewed as sets of
samples.
|
static double |
jaccardIndex(DoubleVector a,
DoubleVector b)
Computes the Jaccard
index comparing the similarity both
DoubleVector s when viewed
as sets of samples. |
static double |
jaccardIndex(int[] a,
int[] b)
Computes the Jaccard
index comparing the similarity both arrays when viewed as sets of
samples.
|
static double |
jaccardIndex(IntegerVector a,
IntegerVector b)
Computes the Jaccard
index comparing the similarity both
IntegerVector s when viewed
as sets of samples. |
static double |
jaccardIndex(Set<?> a,
Set<?> b)
Computes the Jaccard
index of the two sets of elements.
|
static double |
jaccardIndex(Vector a,
Vector b)
Computes the Jaccard
index comparing the similarity both
Vector s when viewed as
sets of samples. |
static double |
kendallsTau(double[] a,
double[] b)
Computes Kendall's
tau of the values in the two arrays.
|
static double |
kendallsTau(DoubleVector a,
DoubleVector b)
Computes Kendall's
tau of the values in the two vectors.
|
static double |
kendallsTau(int[] a,
int[] b)
Computes Kendall's
tau of the values in the two arrays.
|
static double |
kendallsTau(IntegerVector a,
IntegerVector b)
Computes Kendall's
tau of the values in the two vectors.
|
static double |
kendallsTau(Vector a,
Vector b)
Computes Kendall's
tau of the values in the two vectors.
|
static double |
klDivergence(double[] a,
double[] b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
klDivergence(DoubleVector a,
DoubleVector b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
klDivergence(int[] a,
int[] b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
klDivergence(IntegerVector a,
IntegerVector b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
klDivergence(Vector a,
Vector b)
Computes the K-L Divergence of two probability distributions
A
and B where the vectors a and b correspond to
n samples from each respective distribution. |
static double |
linSimilarity(double[] a,
double[] b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
linSimilarity(DoubleVector a,
DoubleVector b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
linSimilarity(int[] a,
int[] b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
linSimilarity(IntegerVector a,
IntegerVector b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
linSimilarity(Vector a,
Vector b)
Computes the lin similarity measure, which is motivated by information
theory priniciples.
|
static double |
spearmanRankCorrelationCoefficient(double[] a,
double[] b)
Computes the Spearman rank correlation coefficient for the two arrays.
|
static double |
spearmanRankCorrelationCoefficient(DoubleVector a,
DoubleVector b)
Computes the Spearman rank correlation coefficient for the two
DoubleVector s. |
static double |
spearmanRankCorrelationCoefficient(int[] a,
int[] b)
Computes the Spearman rank correlation coefficient for the two arrays.
|
static double |
spearmanRankCorrelationCoefficient(IntegerVector a,
IntegerVector b)
Computes the Spearman rank correlation coefficient for the two
DoubleVector s. |
static double |
spearmanRankCorrelationCoefficient(Vector a,
Vector b)
Computes the Spearman rank correlation coefficient for the two
Vector s. |
static double |
tanimotoCoefficient(double[] a,
double[] b)
Returns the Tanimoto coefficient of the two
double array instances. |
static double |
tanimotoCoefficient(DoubleVector a,
DoubleVector b)
Returns the Tanimoto coefficient of the two
DoubleVector instances. |
static double |
tanimotoCoefficient(int[] a,
int[] b)
Returns the Tanimoto coefficient of the two
int array instances. |
static double |
tanimotoCoefficient(IntegerVector a,
IntegerVector b)
Returns the Tanimoto Coefficient of the two
IntegerVector
instances |
static double |
tanimotoCoefficient(Vector a,
Vector b)
Returns the Tanimoto coefficient of the two
Vector instances. |
@Deprecated public static Method getMethod(Similarity.SimType similarityType)
getSimilarity(SimType,double[],double[])
method
should be used instead.
Returns the Method
for getting the similarity of two double[]
based on the specified similarity type.Error
- if a NoSuchMethodException
is thrownpublic static SimilarityFunction getSimilarityFunction(Similarity.SimType similarityType)
public static double getSimilarity(Similarity.SimType similarityType, double[] a, double[] b)
similarityType
- the similarity evaluation to use when comparing
a
and b
a
- a vectorb
- a vectorpublic static <T extends Vector> double getSimilarity(Similarity.SimType similarityType, T a, T b)
similarityType
- the similarity evaluation to use when comparing
a
and b
a
- a Vector
b
- a Vector
public static double cosineSimilarity(double[] a, double[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double cosineSimilarity(int[] a, int[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double cosineSimilarity(DoubleVector a, DoubleVector b)
DoubleVector
.public static double cosineSimilarity(IntegerVector a, IntegerVector b)
DoubleVector
.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double cosineSimilarity(Vector a, Vector b)
DoubleVector
.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double correlation(double[] arr1, double[] arr2)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double correlation(int[] arr1, int[] arr2)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double correlation(DoubleVector arr1, DoubleVector arr2)
Vector
s.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double correlation(IntegerVector arr1, DoubleVector arr2)
Vector
s.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double correlation(Vector a, Vector b)
Vector
s.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double euclideanDistance(double[] a, double[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double euclideanDistance(int[] a, int[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double euclideanDistance(DoubleVector a, DoubleVector b)
DoubleVector
s.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double euclideanDistance(IntegerVector a, IntegerVector b)
DoubleVector
s.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double euclideanDistance(Vector a, Vector b)
Vector
s.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double euclideanSimilarity(int[] a, int[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double euclideanSimilarity(double[] a, double[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double euclideanSimilarity(Vector a, Vector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double jaccardIndex(Set<?> a, Set<?> b)
public static double jaccardIndex(double[] a, double[] b)
public static double jaccardIndex(int[] a, int[] b)
public static double jaccardIndex(DoubleVector a, DoubleVector b)
DoubleVector
s when viewed
as sets of samples.public static double jaccardIndex(IntegerVector a, IntegerVector b)
IntegerVector
s when viewed
as sets of samples.public static double jaccardIndex(Vector a, Vector b)
Vector
s when viewed as
sets of samples.public static double spearmanRankCorrelationCoefficient(double[] a, double[] b)
a
, then Pearson's
product-moment coefficient is returned instead.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double spearmanRankCorrelationCoefficient(int[] a, int[] b)
a
, then Pearson's
product-moment coefficient is returned instead.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double spearmanRankCorrelationCoefficient(DoubleVector a, DoubleVector b)
DoubleVector
s. If there is a tie in the ranking of a
, then
Pearson's product-moment coefficient is returned instead.IllegalArgumentException
- when the length of the two vectors are
not the same.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double spearmanRankCorrelationCoefficient(IntegerVector a, IntegerVector b)
DoubleVector
s. If there is a tie in the ranking of a
, then
Pearson's product-moment coefficient is returned instead.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double spearmanRankCorrelationCoefficient(Vector a, Vector b)
Vector
s. If there is a tie in the ranking of a
, then Pearson's
product-moment coefficient is returned instead.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double averageCommonFeatureRank(double[] a, double[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double averageCommonFeatureRank(Vector a, Vector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double averageCommonFeatureRank(int[] a, int[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double linSimilarity(DoubleVector a, DoubleVector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double linSimilarity(IntegerVector a, IntegerVector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double linSimilarity(Vector a, Vector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double linSimilarity(double[] a, double[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double linSimilarity(int[] a, int[] b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double klDivergence(DoubleVector a, DoubleVector b)
A
and B
where the vectors a
and b
correspond to
n
samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double klDivergence(IntegerVector a, IntegerVector b)
A
and B
where the vectors a
and b
correspond to
n
samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double klDivergence(Vector a, Vector b)
A
and B
where the vectors a
and b
correspond to
n
samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double klDivergence(double[] a, double[] b)
A
and B
where the vectors a
and b
correspond to
n
samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double klDivergence(int[] a, int[] b)
A
and B
where the vectors a
and b
correspond to
n
samples from each respective distribution. The divergence
between two samples is non-symmetric and is frequently used as a distance
metric between vectors from a semantic space. This metric is described
in more detail in the following paper:
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double kendallsTau(double[] a, double[] b)
IllegalArgumentException
- when the length of the two arrays are
not the same.public static double kendallsTau(int[] a, int[] b)
IllegalArgumentException
- when the length of the two arrays are
not the same.public static double kendallsTau(Vector a, Vector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double kendallsTau(DoubleVector a, DoubleVector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double kendallsTau(IntegerVector a, IntegerVector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double goodmanKruskalGamma(DoubleVector a, DoubleVector b)
IllegalArgumentException
- when the length of the two vectors are
not the same.public static double tanimotoCoefficient(double[] a, double[] b)
double
array instances.IllegalArgumentException
- when the length of the two arrays are
not the same.public static double tanimotoCoefficient(int[] a, int[] b)
int
array instances.IllegalArgumentException
- when the length of the two arrays are
not the same.public static double tanimotoCoefficient(Vector a, Vector b)
Vector
instances.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double tanimotoCoefficient(DoubleVector a, DoubleVector b)
DoubleVector
instances.IllegalArgumentException
- when the length of the two vectors are
not the same.public static double tanimotoCoefficient(IntegerVector a, IntegerVector b)
IntegerVector
instancesIllegalArgumentException
- when the length of the two vectors are
not the same.Copyright © 2012. All Rights Reserved.