Package be.bagofwords.counts

Examples of be.bagofwords.counts.BinComputer


public class ApproximateCountsUtils {

    public static ApproximateCountsFilter createFilterFromDataInterface(DataInterface<Long> dataInterface, double fpp) {
        int numOfValuesForBins = 10000;
        BinComputer bc = new BinComputer(numOfValuesForBins);
        CloseableIterator<KeyValue<Long>> it = dataInterface.iterator();
        while (it.hasNext() && bc.getAllValues().size() < numOfValuesForBins) {
            KeyValue<Long> next = it.next();
            if (next.getValue() > 1) {
                bc.addCount(next.getValue());
            }
        }
        it.close();
        double[] binBorders = bc.getEquiDenseBins(256 - 2);
        List<Long>[] binnedValues = new List[binBorders.length + 1];
        for (int i = 0; i < binnedValues.length; i++) {
            binnedValues[i] = new ArrayList<>();
        }
        for (double value : bc.getAllValues()) {
            int bin = NumUtils.getBin(binBorders, value);
            binnedValues[bin].add(Math.round(value));
        }
        long[] averageValues = new long[binnedValues.length];
        for (int i = 0; i < binnedValues.length; i++) {
View Full Code Here

TOP

Related Classes of be.bagofwords.counts.BinComputer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.