public double recallMicro() { if (goldCount.totalCount() == 0) { return 0.0; } return correctCount.totalCount() / goldCount.totalCount(); }
public double precisionMicro() { if (predictedCount.totalCount() == 0) { return 1.0; } return correctCount.totalCount() / predictedCount.totalCount(); }
public double totalCount() { return counter.totalCount() + reservedMass; }
public double totalCount() { return counter.totalCount(); }
/** * Uses the initialized values */ public double score(Object hidden, Object seen) { return model.get(hidden).getCount(seen) / model.get(hidden).totalCount(); }
public double getPosteriorPredictiveProbability(Counter<E> counts, E object) { double numerator = parameters.getCount(object) + counts.getCount(object); double denominator = parameters.totalCount() + counts.totalCount(); return numerator / denominator; }
/** * Returns the mean of all the counts (totalCount/size). * * @param c The Counter to find the mean of. * @return The mean of all the counts (totalCount/size). */ public static <E> double mean(Counter<E> c) { return c.totalCount() / c.size(); }
/** * L1 normalize a counter. Return a counter that is a probability distribution, * so the sum of the resulting value equals 1. * * @param c The {@link Counter} to be L1 normalized. This counter is not * modified. * @return A new L1-normalized Counter based on c. */ public static <E, C extends Counter<E>> C asNormalizedCounter(C c) { return scale(c, 1.0 / c.totalCount()); }
/** * Normalizes the target counter in-place, so the sum of the resulting values * equals 1. * * @param <E> Type of elements in Counter */ public static <E> void normalize(Counter<E> target) { divideInPlace(target, target.totalCount()); }
@Override public double totalCount() { return this.counter.totalCount() + prior.totalCount() * priorMultiplier; }
private void checkParameters(Counter<E> parameters) { for (E o : parameters.keySet()) { if (parameters.getCount(o) < 0.0) { throw new RuntimeException("Parameters must be non-negative!"); } } if (parameters.totalCount() <= 0.0) { throw new RuntimeException("Parameters must have positive mass!"); } }
public static <E> double standardDeviation(Counter<E> c) { double std = 0; double mean = c.totalCount() / c.size(); for (Map.Entry<E, Double> en : c.entrySet()) { std += (en.getValue() - mean) * (en.getValue() - mean); } return Math.sqrt(std / c.size()); }
public static void setRatioGoogleNgramFreqWithDataFreq() { ratioGoogleNgramFreqWithDataFreq = GoogleNGramsSQLBacked.getTotalCount(1)/ Data.rawFreq.totalCount(); Redwood.log(ConstantsAndVariables.minimaldebug, "Data", "ratioGoogleNgramFreqWithDataFreq is " + ratioGoogleNgramFreqWithDataFreq); //return ratioGoogleNgramFreqWithDataFreq; }
public void addAll(K1 key, Counter<K2> c) { ClassicCounter<K2> myInner = getCounter(key); Counters.addInPlace(myInner, c); total += c.totalCount(); }
public void subtractAll(K1 key, Counter<K2> c) { ClassicCounter<K2> myInner = getCounter(key); Counters.subtractInPlace(myInner, c); total -= c.totalCount(); }
/** * replace the counter for K1-index o by new counter c */ public ClassicCounter<K2> setCounter(K1 o, Counter<K2> c) { ClassicCounter<K2> old = getCounter(o); total -= old.totalCount(); if (c instanceof ClassicCounter) { map.put(o, (ClassicCounter<K2>) c); } else { map.put(o, new ClassicCounter<>(c)); } total += c.totalCount(); return old; }
public Multinomial(Counter<E> parameters) { double totalMass = parameters.totalCount(); if (totalMass <= 0.0) { throw new RuntimeException("total mass must be positive!"); } this.parameters = new ClassicCounter<>(); for (E object : parameters.keySet()) { double oldCount = parameters.getCount(object); if (oldCount < 0.0) { throw new RuntimeException("no negative parameters allowed!"); } this.parameters.setCount(object, oldCount/totalMass); } }
/** * Returns a counter where each element corresponds to the normalized count of * the corresponding element in c raised to the given power. */ public static <E> Counter<E> powNormalized(Counter<E> c, double temp) { Counter<E> d = c.getFactory().create(); double total = c.totalCount(); for (E e : c.keySet()) { d.setCount(e, Math.pow(c.getCount(e) / total, temp)); } return d; }
public void addAll(TwoDimensionalCounterInterface<K1, K2> c) { for (K1 key : c.firstKeySet()) { Counter<K2> inner = c.getCounter(key); ClassicCounter<K2> myInner = getCounter(key); Counters.addInPlace(myInner, inner); total += inner.totalCount(); } }
public void subtractAll(TwoDimensionalCounterInterface<K1, K2> c, boolean removeKeys) { for (K1 key : c.firstKeySet()) { Counter<K2> inner = c.getCounter(key); ClassicCounter<K2> myInner = getCounter(key); Counters.subtractInPlace(myInner, inner); if (removeKeys) Counters.retainNonZeros(myInner); total -= inner.totalCount(); } }