public class FrequencyVector<T,V extends Number & Comparable<V>> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<T,V> |
data
Holds the vector itself
|
protected double |
max
Holds the maximum value of all elements
|
protected double |
norm
Holds the L2 norm of this vector
|
protected List<T> |
sortedTerms
Holds the terms of the vector sorted by decreasing frequency
|
protected double |
sum
Holds the sum of all elements
|
| Constructor and Description |
|---|
FrequencyVector(Map<T,V> applications)
Constructs a frequency vector.
|
| Modifier and Type | Method and Description |
|---|---|
double |
averagePrecision(Collection<T> groundTruth)
Computes the average precision (MAP)
|
double |
cosine(FrequencyVector<T,?> other)
Computes the cosine to another vector
|
double |
cosine(FrequencyVector<T,?> other,
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(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() |
Set<T> |
intersection(FrequencyVector<T,?> other)
Computes the common supports
|
static void |
main(String[] args)
Test
|
double |
max()
Returns the maximum of elements
|
FrequencyVector<T,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,Double> |
normalized()
Normalizes this vector
|
FrequencyVector<T,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(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(Collection<T> groundTruth)
Computes standard precision
|
double |
precisionWithRespectTo(FrequencyVector<T,?> trueFrequencies)
Computes the standard precision
|
double |
precisionWithRespectToIntersection(Collection<T> intersection)
Computes the standard precision if the intersection is known
|
double |
recallAtKWithRespectTo(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(Collection<T> groundTruth)
Computes the standard recall
|
double |
recallWithRespectTo(Collection<T> trueSet,
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,
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
|
List<T> |
sortedTerms()
Returns the terms sorted by decreasing frequency
|
protected static <C,V extends Comparable<V>> |
sortedTerms(Map<C,V> applications)
Returns the terms of the application data sorted by their number of applications
|
double |
sum()
Returns the sum of elements
|
T |
termAtRank(int i)
Returns the term at rank i
|
Collection<T> |
terms()
Returns the terms.
|
Set<T> |
topKIntersection(FrequencyVector<T,V> trueFrequencies,
int k)
Computes the intersection of the top k elements
|
String |
toString() |
V |
valueFor(T term)
Returns the frequency for a term (or null)
|
double |
weightedPrecisionAtKWithRespectTo(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(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.
|
protected double norm
protected double sum
protected double max
public int firstTiePos()
public double sum()
public double norm()
public double max()
public T termAtRank(int i)
public int numTerms()
public double doubleValueFor(T term)
public double normalizedValueFor(T term)
public double maxNormalizedValueFor(T term)
public double smoothedValueFor(T term)
public Collection<T> terms()
protected static <C,V extends Comparable<V>> List<C> sortedTerms(Map<C,V> applications)
public FrequencyVector<T,Double> normalized()
public FrequencyVector<T,Double> maxNormalized()
public Set<T> intersection(FrequencyVector<T,?> other)
public Set<T> topKIntersection(FrequencyVector<T,V> trueFrequencies, int k)
public double cosine(FrequencyVector<T,?> other, Collection<T> intersection)
public double cosine(FrequencyVector<T,?> other)
public double precisionAtKWithRespectTo(Collection<T> groundTruth, int k)
public double weightedPrecisionAtKWithRespectTo(Collection<T> groundTruth, int k)
public double precisionWithRespectTo(Collection<T> groundTruth)
public double precisionWithRespectTo(FrequencyVector<T,?> trueFrequencies)
public double precisionWithRespectToIntersection(Collection<T> intersection)
public double weightedPrecisionWithRespectTo(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(Collection<T> groundTruth)
public double optimalAveragePrecision(FrequencyVector<T,?> trueFrequencies)
public double recallAtKWithRespectTo(Collection<T> groundTruth, int k)
public double recallWithRespectTo(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(Collection<T> trueSet, Collection<T> intersection)
public double recallWithRespectTo(FrequencyVector<T,?> trueFrequencies, 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,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(String[] args)
Copyright © 2018. All rights reserved.