@Override public double[] toDoubleArray() { synchronized (sync) { return collection.toDoubleArray(); } } @Override
@Override public double[] toDoubleArray() { return collection.toDoubleArray(); } /*
/** * Creates a queue using the elements in a type-specific collection using a * given comparator. * * <p> * This constructor is more efficient than enqueing the elements of * {@code collection} one by one. * * @param collection * a collection; its elements will be used to initialize the queue. * @param c * the comparator used in this queue, or {@code null} for the natural * order. */ public DoubleHeapPriorityQueue(final DoubleCollection collection, final DoubleComparator c) { this(collection.toDoubleArray(), c); } /**
/** * Evaluates the metric for the recommendations added so far. * * @return result of the metric for the recommendations previously added */ @Override public double evaluate() { double gi = 0; double[] cs = itemCount.values().toDoubleArray(); sort(cs); for (int j = 0; j < cs.length; j++) { gi += (2 * (j + (numItems - cs.length) + 1) - numItems - 1) * (cs[j] / freeNorm); } gi /= (numItems - 1); gi = 1 - gi; return gi; }
private static void convertSparseDoubleLongKeyModel(Configuration conf, FSDataOutputStream output, String modelInputDir, ModelLineConvert lineConvert) throws IOException { Long2DoubleOpenHashMap[] data = ModelLoader.loadToDoubleLongKeyMaps(modelInputDir, conf); for (int i = 0; i < data.length; i++) { Long2DoubleOpenHashMap row = data[i]; data[i] = null; if (row == null) { continue; } lineConvert.convertRowIndex(output, i); long[] indexes = row.keySet().toLongArray(); double[] values = row.values().toDoubleArray(); row = null; Sort.quickSort(indexes, values, 0, indexes.length - 1); for (int j = 0; j < indexes.length; j++) { lineConvert.convertDoubleLongKey(output, indexes[j], values[j]); } } }
private static void convertSparseDoubleModel(Configuration conf, FSDataOutputStream output, String modelInputDir, ModelLineConvert lineConvert) throws IOException { Int2DoubleOpenHashMap[] data = ModelLoader.loadToDoubleMaps(modelInputDir, conf); for (int i = 0; i < data.length; i++) { Int2DoubleOpenHashMap row = data[i]; data[i] = null; if (row == null) { continue; } lineConvert.convertRowIndex(output, i); int[] indexes = row.keySet().toIntArray(); double[] values = row.values().toDoubleArray(); row = null; Sort.quickSort(indexes, values, 0, indexes.length - 1); for (int j = 0; j < indexes.length; j++) { lineConvert.convertDouble(output, indexes[j], values[j]); } } }