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(); }
/** * Add the error for a training round. * @param err The error for the training round. * @return The builder (for chaining). */ public Builder addTrainingRound(double err) { trainingError.add(err); return this; } }
/** * Shuffles the specified list using the specified pseudorandom number * generator. * * @param l * the list to be shuffled. * @param random * a pseudorandom number generator. * @return {@code l}. */ public static DoubleList shuffle(final DoubleList l, final Random random) { for (int i = l.size(); i-- != 0;) { final int p = random.nextInt(i + 1); final double t = l.getDouble(i); l.set(i, l.getDouble(p)); l.set(p, t); } return l; } /**
@Override public double getDouble(final int i) { synchronized (sync) { return list.getDouble(i); } } @Override
/** * Creates a new array list and fills it with a given type-specific list. * * @param l * a type-specific list that will be used to fill the array list. */ public DoubleArrayList(final DoubleList l) { this(l.size()); l.getElements(0, a, 0, size = l.size()); } /**
@Override protected double[] createOutputStatistics() { DoubleList values = new DoubleArrayList(); values.addAll(DoubleArrayList.wrap(stats.createOutputStatistics(orderStats))); auc = aucLossCalculator.evaluateStatistic(); confidenceInterval95 = aucLossCalculator.confidenceInterval95(); values.add(auc); values.add(confidenceInterval95[0]); values.add(confidenceInterval95[1]); return values.toDoubleArray(); }
@Override public double getScore() { return scores.get(index); }
/** * A method that can evaluate several metrics in one pass over a validation set. Metric values are * returned in the order of the metrics names provided as arguments. * Note that the default implementation is not optimal because it performs several * passes over the validation set. A custom implementation can often improve on this. * * @param graph model. * @param dataSetIterator iterator over validation set. * @param scoreN number of examples to score. * @param metrics name of metrics to estimate. * @return an array of metric values. */ public double[] estimateMetric(ComputationGraph graph, MultiDataSetIterator dataSetIterator, long scoreN, String... metrics) { DoubleList results = new DoubleArrayList(); for (String metricName : metrics) { results.add(estimateMetric(graph, metricName, dataSetIterator, scoreN)); } return results.toDoubleArray(); }
static DoubleList replace(DoubleList list, IntList indices, DoubleList elements) { checkIndices(indices, elements); final DoubleList newL = new DoubleArrayList(list); for (int i = 0; i < indices.size(); i++) { newL.set(indices.getInt(i), elements.getDouble(i)); } return DoubleLists.unmodifiable(newL); }
@Override public double set(final int i, final double k) { synchronized (sync) { return list.set(i, k); } } @Override
@Override public double[] toDoubleArray() { return list.toDoubleArray(); } @Override
@Override public long size64() { return list.size(); } @Override
@Override public boolean add(double key) { return list.add(key); } @Override
@Override public double getDouble(final int i) { return list.getDouble(i); } @Override