/** * Multiplies each value in target by the count of the key in mult, in place. Returns non zero entries * * @param target The counter * @param mult The counter you want to multiply with target */ public static <E> Counter<E> multiplyInPlace(Counter<E> target, Counter<E> mult) { for (Entry<E, Double> entry : target.entrySet()) { target.setCount(entry.getKey(), entry.getValue() * mult.getCount(entry.getKey())); } Counters.retainNonZeros(target); return target; }
public void removeZeroCounts() { Set<K1> firstKeySet = Generics.newHashSet(firstKeySet()); for (K1 k1 : firstKeySet) { ClassicCounter<K2> c = getCounter(k1); Counters.retainNonZeros(c); if (c.size() == 0) map.remove(k1); // it's empty, get rid of it! } }
public void removeZeroCounts() { Set<K1> firstKeySet = Generics.newHashSet(firstKeySet()); for (K1 k1 : firstKeySet) { IntCounter<K2> c = getCounter(k1); Counters.retainNonZeros(c); if (c.isEmpty()) { map.remove(k1); // it's empty, get rid of it! } } }
sensitivity.setCount(en.getKey(), common / (double) p0Set.size()); Counters.retainNonZeros(specificity); Counters.retainNonZeros(sensitivity); Counter<E> add = Counters.add(sensitivity, specificity); Counter<E> product = Counters.product(sensitivity, specificity); Counters.retainNonZeros(product); Counters.retainKeys(product, add.keySet()); Counter<E> finalPat = Counters.scale(
public void subtractAll(TwoDimensionalIntCounter<K1, K2> c, boolean removeKeys) { for (K1 key : c.firstKeySet()) { IntCounter<K2> inner = c.getCounter(key); IntCounter<K2> myInner = getCounter(key); Counters.subtractInPlace(myInner, inner); if (removeKeys) { Counters.retainNonZeros(myInner); } total -= inner.totalIntCount(); } }
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(); } }
public static <T> Counter<T> diff(Counter<T> goldFeatures, Counter<T> guessedFeatures) { Counter<T> result = goldFeatures.getFactory().create(); for (T key : Sets.union(goldFeatures.keySet(), guessedFeatures.keySet())) { result.setCount(key, goldFeatures.getCount(key) - guessedFeatures.getCount(key)); } retainNonZeros(result); return result; }
public static <E> Counter<E> add(Counter<E> c1, Counter<E> c2) { Counter<E> result = c1.getFactory().create(); for (E key : Sets.union(c1.keySet(), c2.keySet())) { result.setCount(key, c1.getCount(key) + c2.getCount(key)); } retainNonZeros(result); return result; }
Counter<E> finalPat = scorePatterns.score(); Counters.removeKeys(finalPat, alreadyIdentifiedPatterns); Counters.retainNonZeros(finalPat); Counters.retainTop(finalPat, constVars.numPatterns); if (Double.isNaN(Counters.max(finalPat)))
Counters.retainNonZeros(currentPatternWeights4Label); return currentPatternWeights4Label;
/** * Multiplies each value in target by the count of the key in mult, in place. Returns non zero entries * * @param target The counter * @param mult The counter you want to multiply with target */ public static <E> Counter<E> multiplyInPlace(Counter<E> target, Counter<E> mult) { for (Entry<E, Double> entry : target.entrySet()) { target.setCount(entry.getKey(), entry.getValue() * mult.getCount(entry.getKey())); } Counters.retainNonZeros(target); return target; }
/** * Multiplies each value in target by the count of the key in mult, in place. Returns non zero entries * * @param target The counter * @param mult The counter you want to multiply with target */ public static <E> Counter<E> multiplyInPlace(Counter<E> target, Counter<E> mult) { for (Entry<E, Double> entry : target.entrySet()) { target.setCount(entry.getKey(), entry.getValue() * mult.getCount(entry.getKey())); } Counters.retainNonZeros(target); return target; }
public void removeZeroCounts() { Set<K1> firstKeySet = new HashSet<K1>(firstKeySet()); for (K1 k1 : firstKeySet) { ClassicCounter<K2> c = getCounter(k1); Counters.retainNonZeros(c); if (c.size() == 0) map.remove(k1); // it's empty, get rid of it! } }
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(); } }
public void subtractAll(TwoDimensionalIntCounter<K1, K2> c, boolean removeKeys) { for (K1 key : c.firstKeySet()) { IntCounter<K2> inner = c.getCounter(key); IntCounter<K2> myInner = getCounter(key); Counters.subtractInPlace(myInner, inner); if (removeKeys) { Counters.retainNonZeros(myInner); } total -= inner.totalIntCount(); } }
public void subtractAll(TwoDimensionalIntCounter<K1, K2> c, boolean removeKeys) { for (K1 key : c.firstKeySet()) { IntCounter<K2> inner = c.getCounter(key); IntCounter<K2> myInner = getCounter(key); Counters.subtractInPlace(myInner, inner); if (removeKeys) { Counters.retainNonZeros(myInner); } total -= inner.totalIntCount(); } }
public static <E> Counter<E> add(Counter<E> c1, Counter<E> c2) { Counter<E> result = c1.getFactory().create(); for (E key : Sets.union(c1.keySet(), c2.keySet())) { result.setCount(key, c1.getCount(key) + c2.getCount(key)); } retainNonZeros(result); return result; }
public static <T> Counter<T> diff(Counter<T> goldFeatures, Counter<T> guessedFeatures) { Counter<T> result = goldFeatures.getFactory().create(); for (T key : Sets.union(goldFeatures.keySet(), guessedFeatures.keySet())) { result.setCount(key, goldFeatures.getCount(key) - guessedFeatures.getCount(key)); } retainNonZeros(result); return result; }
public static <T> Counter<T> diff(Counter<T> goldFeatures, Counter<T> guessedFeatures) { Counter<T> result = goldFeatures.getFactory().create(); for (T key : Sets.union(goldFeatures.keySet(), guessedFeatures.keySet())) { result.setCount(key, goldFeatures.getCount(key) - guessedFeatures.getCount(key)); } retainNonZeros(result); return result; }
public static <E> Counter<E> add(Counter<E> c1, Counter<E> c2) { Counter<E> result = c1.getFactory().create(); for (E key : Sets.union(c1.keySet(), c2.keySet())) { result.setCount(key, c1.getCount(key) + c2.getCount(key)); } retainNonZeros(result); return result; }