@Override public double getDouble(int id) { assert id < _idToValueMap.size(); return _idToValueMap.get(id); }
@Override public String getString(int id) { assert id < _idToValueMap.size(); return (Double.valueOf(_idToValueMap.getDouble(id)).toString()); } }
@Override public int put(double value) { int id = _valueToIdMap.get(value); if (id == INVALID_KEY) { id = _idToValueMap.size(); _valueToIdMap.put(value, id); _idToValueMap.add(value); } return id; }
private void assertTDigest(TDigest tDigest, DoubleList doubleList) { for (int percentile = 0; percentile <= 100; percentile++) { double expected; if (percentile == 100) { expected = doubleList.getDouble(doubleList.size() - 1); } else { expected = doubleList.getDouble(doubleList.size() * percentile / 100); } Assert .assertEquals(PercentileTDigestAggregationFunction.calculatePercentile(tDigest, percentile), expected, DELTA, ERROR_MESSAGE); } }
private static double[] filterDoubles(DoubleSet doubleSet, double[] source) { DoubleList doubleList = new DoubleArrayList(); for (double value : source) { if (doubleSet.contains(value)) { doubleList.add(value); } } if (doubleList.size() == source.length) { return source; } else { return doubleList.toDoubleArray(); } }
/** * Get the iteration count for the feature. * * @return The number of iterations used to train the feature. */ public int getIterCount() { return trainingErrors.size(); }
/** * Get the last training RMSE of the feature. * * @return The RMSE of the last iteration training this feature. */ public double getLastRMSE() { return trainingErrors.getDouble(trainingErrors.size() - 1); }
/** * Get the last delta RMSE of the feature. * * @return The RMSE improvement in the last training round of this feature. */ public double getLastDeltaRMSE() { int n = trainingErrors.size(); return trainingErrors.getDouble(n-2) - trainingErrors.getDouble(n-1); }
/** * Create a map from an array and index mapping. * * @param mapping The index mapping specifying the keys. * @param values The array of values. * @return A sparse vector mapping the IDs in {@code map} to the values in {@code values}. * @throws IllegalArgumentException if {@code values} not the same size as {@code idx}. */ public static Long2DoubleSortedArrayMap fromArray(KeyIndex mapping, DoubleList values) { Preconditions.checkArgument(values.size() == mapping.size(), "value array and index have different sizes: " + values.size() + " != " + mapping.size()); final int n = values.size(); double[] nvs = new double[n]; SortedKeyIndex index = SortedKeyIndex.fromCollection(mapping.getKeyList()); for (int i = 0; i < n; i++) { long item = index.getKey(i); int origIndex = mapping.getIndex(item); nvs[i] = values.getDouble(origIndex); } return wrap(index, nvs); }
@Override public long size64() { return list.size(); } @Override
@Override public void size(final int size) { synchronized (sync) { list.size(size); } } @Override
@Override public void size(final int size) { list.size(size); } @Override
@Override public void size(final long size) { list.size(intIndex(size)); } @Override
private Schedule(C s, ImmutableList<ImmutableList<T>> r, IntList si, DoubleList ovs, double ov, RouteEvaluator<C, T> eval) { checkArgument(r.size() == si.size()); checkArgument(r.size() == ovs.size()); context = s; routes = r; startIndices = si; objectiveValues = ovs; objectiveValue = ov; evaluator = eval; }
@Override protected double sd(int n) { return (n > 0 && n <= sis.size()) ? mus.get(n-1) : 0; }
PackedScoredIdList(LongList ids, DoubleList scores, Map<TypedSymbol<?>, List<?>> chans, Map<Symbol, DoubleList> unboxedChans) { assert ids.size() == scores.size(); this.ids = ids; this.scores = scores; unboxedChannels = unboxedChans; channels = chans; }
/** * Get the last training RMSE of the feature. * * @return The RMSE of the last iteration training this feature. */ public double getLastRMSE() { return trainingErrors.getDouble(trainingErrors.size() - 1); }
/** * Get the last delta RMSE of the feature. * * @return The RMSE improvement in the last training round of this feature. */ public double getLastDeltaRMSE() { int n = trainingErrors.size(); return trainingErrors.getDouble(n-2) - trainingErrors.getDouble(n-1); }