@Override public int size() { return map.size(); } }
@Override public ObjectCollection<V> values() { if (values == null) return ObjectCollections.unmodifiable(map.values()); return values; } @Override
/** * Sort records inside each chromosome by start position. */ public void sort() { for (String chromosome: store.keySet()){ List<BEDRecord> recordList = store.get(chromosome); recordList.sort(Comparator.comparingInt(value -> value.startPosition)); } } Comparator<BEDRecord> COMPARATOR = (r1, r2) -> Integer.compare(r1.startPosition,r2.startPosition);
@Override public int get(K k, K cond) { if (!distributions.containsKey(cond)) { return 0; } return distributions.get(cond).get(k); }
@Override protected double[] rawScore(int n, NGram key) { final float[] f = map.get(key); if (f == null) { return null; } else { double[] d = new double[f.length]; for (int i = 0; i < d.length; i++) { d[i] = f[i]; } return d; } }
Object2ObjectMap<long[], List<ArrayModifiableDBIDs>> newClustersMap = new Object2ObjectOpenCustomHashMap<>(BitsUtil.FASTUTIL_HASH_STRATEGY); Pair<long[], ArrayModifiableDBIDs> noise = new Pair<>(BitsUtil.zero(dimensionality), DBIDUtil.newArray()); for(long[] pv : clustersMap.keySet()) { List<ArrayModifiableDBIDs> parallelClusters = clustersMap.get(pv); for(ArrayModifiableDBIDs c : parallelClusters) { noise.second.addDBIDs(c); List<ArrayModifiableDBIDs> parallelClusters = clustersMap.get(pv); List<ArrayModifiableDBIDs> newParallelClusters = new ArrayList<>(parallelClusters.size()); for(ArrayModifiableDBIDs c : parallelClusters) { newClustersMap.put(pv, newParallelClusters); clustersMap.clear(); clustersMap.putAll(newClustersMap); clustersMap.put(noise.first, noiseList);
@Override public float update(@Nonnull final Object feature, final float weight, final float gradient) { IWeightValue auxWeight = auxWeights.get(feature); if (auxWeight == null) { auxWeight = new WeightValue.WeightValueParamsF2(weight, 0.f, 0.f); auxWeights.put(feature, auxWeight); } else { auxWeight.set(weight); } final float newWeight = update(auxWeight, gradient); if (newWeight == 0.f) { auxWeights.remove(feature); } return newWeight; }
@Override public void set(K k, K cond, int v) { if (!distributions.containsKey(cond)) { Object2IntFrequencyDistributionFastutil<K> fd = new Object2IntFrequencyDistributionFastutil<K>(); fd.set(k, v); distributions.put(cond, fd); marginals.increment(k, v); sumOfAllCounts += v; } else { Object2IntFrequencyDistribution<K> fd = distributions.get(cond); int rv = fd.get(k); fd.set(k, v); distributions.put(cond, fd); marginals.increment(k, -rv + v); sumOfAllCounts = sumOfAllCounts - rv + v; } }
@Override protected void put(int[] ng, double[] scores) throws IOException { final float[] f = new float[scores.length]; for (int i = 0; i < scores.length; i++) { f[i] = (float) scores[i]; } map2.put(new NGram(ng), f); }
private static Object2ObjectLinkedOpenHashMap<String, String> invert( Object2ObjectMap<String, String> m ) { final Object2ObjectLinkedOpenHashMap<String, String> result = new Object2ObjectLinkedOpenHashMap<String, String>(); for( Map.Entry<String, String> e : m.entrySet() ) result.put( e.getValue(), e.getKey() ); if ( m.size() != result.size() ) throw new IllegalArgumentException( "Index remapping " + m + " is not a bijection" ); return result; }
/** * Log the performance of a model. The model is identified by a prefix. Use "best" if you are only * tracking the performance of the best model, by score. Use bestAUC if you are tracking the performance * of the model that got best AUC on the test set. Use final for the model created at the end of the * training process, irrespective of performance. * * @param prefix Identifies a specific model. * @param numExamplesUsed The number of training examples seen by the model. Note that examples used in training several times count several times. * @param epoch The number of epochs used to train the model. * @param score The score obtained at numExamplesUsed and epoch for the model. * @param auc The AUC on the test set, or NaN. */ public void log(String prefix, long numExamplesUsed, int epoch, double score, double auc) { ObjectArrayList<Performance> defaultValue = new ObjectArrayList<>(); bestScore = Math.min(bestScore, score); bestAUC = Math.max(bestAUC, auc); log.getOrDefault(prefix, defaultValue).add(new Performance(numExamplesUsed, epoch, score, auc)); if (defaultValue.size() > 0) { log.put(prefix, defaultValue); } }
/** * Get a collection (set) of all players online on this world * * @return collection of all players online on this world */ public Collection<EntityPlayer> getPlayers() { return Collections.unmodifiableSet(this.players.keySet()); }
@Override public boolean remove(final Object key, final Object value) { synchronized (sync) { return map.remove(key, value); } } @Override
/** * Utility method to check whether a given walker has been deprecated in a previous GATK release * * @param walkerName the walker class name (not the full package) to check */ public static boolean isDeprecatedWalker(final String walkerName) { return deprecatedGATKWalkers.containsKey(walkerName); }
public void clear() { log.clear(); }
/** * Utility method to pull up the version number at which a walker was deprecated and the suggested replacement, if any * * @param walkerName the walker class name (not the full package) to check */ public static String getWalkerDeprecationInfo(final String walkerName) { return deprecatedGATKWalkers.get(walkerName).toString(); }
@Override public Object2IntFrequencyDistribution<K> getConditionalDistribution(K cond) { if (distributions.containsKey(cond)) { return distributions.get(cond); } return new Object2IntFrequencyDistributionFastutil<K>(); }