|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javatools.datatypes.FrequencyVector<T,V>
public class FrequencyVector<T,V extends java.lang.Number & java.lang.Comparable<V>>
This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga). Fabian M. Suchanek, Milan Vojnovic, Dinan Gunawardena "Social Tags: Meaning and Suggestions" (pdf, bib) ACM Conference on Information and Knowledge Management (CIKM 2008) The class represents a vector of terms with their frequencies. See the paper for explanations. Also provides Wilson interval computation.
Constructor Summary | |
---|---|
FrequencyVector(java.util.Map<T,V> applications)
Constructs a frequency vector. |
Method Summary | |
---|---|
double |
averagePrecision(java.util.Collection<T> groundTruth)
Computes the average precision (MAP) |
double |
cosine(FrequencyVector<T,?> other)
Computes the cosine to another vector |
double |
cosine(FrequencyVector<T,?> other,
java.util.Collection<T> intersection)
Computes the cosine to another vector, if the intersection is already available |
double |
doubleValueFor(T term)
Returns the frequency for a term as double (or 0) |
boolean |
equals(java.lang.Object obj)
|
int |
firstTiePos()
Returns the first position in sortedTerms that has equal number of applications to its successor |
double |
fuzzyPrecisionWithRespectTo(FrequencyVector<T,V> trueFrequencies)
Computes the fuzzy Precision |
double |
fuzzyRecallWithRespectTo(FrequencyVector<T,V> trueFrequencies)
Computes the fuzzy recall |
int |
hashCode()
|
java.util.Set<T> |
intersection(FrequencyVector<T,?> other)
Computes the common supports |
static void |
main(java.lang.String[] args)
Test |
double |
max()
Returns the maximum of elements |
FrequencyVector<T,java.lang.Double> |
maxNormalized()
Max-Normalizes this vector |
double |
maxNormalizedValueFor(T term)
Returns the frequency for a term, divided by the maximum (or 0) |
double |
ndcg2WithRespectToGain(FrequencyVector<T,?> trueFrequencies)
Computes the NDCG with respect to a gain, with weighting 2^x |
double |
ndcgWithRespectToGain(FrequencyVector<T,?> trueFrequencies)
Computes the NDCG with respect to a gain |
double |
norm()
Returns the L2 norm of elements |
FrequencyVector<T,java.lang.Double> |
normalized()
Normalizes this vector |
FrequencyVector<T,java.lang.Double> |
normalizedMeanWith(FrequencyVector<T,V> other)
Computes the mean vector of this vector and the other one |
double |
normalizedValueFor(T term)
Returns the frequency for a term, divided by the sum (or 0) |
int |
numTerms()
Returns the number of terms in the support |
double |
optimalAveragePrecision(FrequencyVector<T,?> trueFrequencies)
Computes the average precision, shuffling subsets to get an optimal value |
double |
precisionAtKWithRespectTo(java.util.Collection<T> groundTruth,
int k)
Computes the standard precision at k |
double |
precisionAtKWithRespectTo(FrequencyVector<T,?> groundTruth,
int k)
Computes the standard precision at k |
double |
precisionWithRespectTo(java.util.Collection<T> groundTruth)
Computes standard precision |
double |
precisionWithRespectTo(FrequencyVector<T,?> trueFrequencies)
Computes the standard precision |
double |
precisionWithRespectToIntersection(java.util.Collection<T> intersection)
Computes the standard precision if the intersection is known |
double |
recallAtKWithRespectTo(java.util.Collection<T> groundTruth,
int k)
Computes the standard recall at k |
double |
recallAtKWithRespectTo(FrequencyVector<T,V> trueFrequencies,
int k)
Computes the standard recall at k |
double |
recallWithRespectTo(java.util.Collection<T> groundTruth)
Computes the standard recall |
double |
recallWithRespectTo(java.util.Collection<T> trueSet,
java.util.Collection<T> intersection)
Computes standard recall, if the intersection is already available |
double |
recallWithRespectTo(FrequencyVector<T,?> trueFrequencies)
Computes standard recall |
double |
recallWithRespectTo(FrequencyVector<T,?> trueFrequencies,
java.util.Collection<T> intersection)
Computes standard recall, if the intersection is already available |
double |
smoothedValueFor(T term)
Returns the frequency for a term, divided by the sum and smoothed |
java.util.List<T> |
sortedTerms()
Returns the terms sorted by decreasing frequency |
double |
sum()
Returns the sum of elements |
T |
termAtRank(int i)
Returns the term at rank i |
java.util.Collection<T> |
terms()
Returns the terms. |
java.util.Set<T> |
topKIntersection(FrequencyVector<T,V> trueFrequencies,
int k)
Computes the intersection of the top k elements |
java.lang.String |
toString()
|
V |
valueFor(T term)
Returns the frequency for a term (or null) |
double |
weightedPrecisionAtKWithRespectTo(java.util.Collection<T> groundTruth,
int k)
Computes the precision at k to a set, weighted with this vector's frequencies |
double |
weightedPrecisionAtKWithRespectTo(FrequencyVector<T,?> groundTruth,
int k)
Computes the weighted precision at k |
double |
weightedPrecisionWithRespectTo(java.util.Collection<T> groundTruth)
Computes the standard precision to a set, weighted with this vector's frequencies |
double |
weightedPrecisionWithRespectTo(FrequencyVector<T,?> trueFrequencies)
Computes the standard precision to a set, weighted with this vector's frequencies |
double |
weightedRecallAtKWithRespectTo(FrequencyVector<T,V> trueFrequencies,
int k)
Computes the standard recall at k, weighted with the true frequencies |
double |
weightedRecallWithRespectTo(FrequencyVector<T,V> trueFrequencies)
Computes the standard recall, weighted with the true frequencies |
static double[] |
wilson(int total,
int correct)
Computes the Wilson Interval (see http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval#Wilson_score_interval) Given the total number of events and the number of "correct" events, returns in a double-array in the first component the center of the Wilson interval and in the second component the width of the interval. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FrequencyVector(java.util.Map<T,V> applications)
Method Detail |
---|
public int firstTiePos()
public double sum()
public double norm()
public double max()
public T termAtRank(int i)
public int numTerms()
public V valueFor(T term)
public double doubleValueFor(T term)
public double normalizedValueFor(T term)
public double maxNormalizedValueFor(T term)
public double smoothedValueFor(T term)
public java.util.List<T> sortedTerms()
public java.util.Collection<T> terms()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public FrequencyVector<T,java.lang.Double> normalized()
public FrequencyVector<T,java.lang.Double> maxNormalized()
public java.util.Set<T> intersection(FrequencyVector<T,?> other)
public java.util.Set<T> topKIntersection(FrequencyVector<T,V> trueFrequencies, int k)
public double cosine(FrequencyVector<T,?> other, java.util.Collection<T> intersection)
public double cosine(FrequencyVector<T,?> other)
public double precisionAtKWithRespectTo(java.util.Collection<T> groundTruth, int k)
public double weightedPrecisionAtKWithRespectTo(java.util.Collection<T> groundTruth, int k)
public double precisionWithRespectTo(java.util.Collection<T> groundTruth)
public double precisionWithRespectTo(FrequencyVector<T,?> trueFrequencies)
public double precisionWithRespectToIntersection(java.util.Collection<T> intersection)
public double weightedPrecisionWithRespectTo(java.util.Collection<T> groundTruth)
public double weightedPrecisionWithRespectTo(FrequencyVector<T,?> trueFrequencies)
public double precisionAtKWithRespectTo(FrequencyVector<T,?> groundTruth, int k)
public double weightedPrecisionAtKWithRespectTo(FrequencyVector<T,?> groundTruth, int k)
public double averagePrecision(java.util.Collection<T> groundTruth)
public double optimalAveragePrecision(FrequencyVector<T,?> trueFrequencies)
public double recallAtKWithRespectTo(java.util.Collection<T> groundTruth, int k)
public double recallWithRespectTo(java.util.Collection<T> groundTruth)
public double weightedRecallWithRespectTo(FrequencyVector<T,V> trueFrequencies)
public double weightedRecallAtKWithRespectTo(FrequencyVector<T,V> trueFrequencies, int k)
public double recallWithRespectTo(FrequencyVector<T,?> trueFrequencies)
public double recallWithRespectTo(java.util.Collection<T> trueSet, java.util.Collection<T> intersection)
public double recallWithRespectTo(FrequencyVector<T,?> trueFrequencies, java.util.Collection<T> intersection)
public double recallAtKWithRespectTo(FrequencyVector<T,V> trueFrequencies, int k)
public double ndcgWithRespectToGain(FrequencyVector<T,?> trueFrequencies)
public double ndcg2WithRespectToGain(FrequencyVector<T,?> trueFrequencies)
public FrequencyVector<T,java.lang.Double> normalizedMeanWith(FrequencyVector<T,V> other)
public double fuzzyRecallWithRespectTo(FrequencyVector<T,V> trueFrequencies)
public double fuzzyPrecisionWithRespectTo(FrequencyVector<T,V> trueFrequencies)
public static double[] wilson(int total, int correct)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |