Java Code Examples for it.unimi.dsi.fastutil.ints.IntList#getInt()

The following examples show how to use it.unimi.dsi.fastutil.ints.IntList#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Statistics.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private void increaseMeasure(final IntList measureList, final int level) {
  if (measureList.size() > level - 1) {
    final int prev = measureList.getInt(level - 1);
    measureList.set(level - 1, prev + 1);
  } else {
    final int skippedLevels = level - measureList.size() - 1;
    // add 0 for no application of the pruning rule in the skipped levels
    for (int i = 0; i < skippedLevels; i++) {
      measureList.add(0);
    }
    // add 1 for one application of the pruning rule in the new level
    measureList.add(1);
  }
}
 
Example 2
Source File: AgreeSetGenerator.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(IntList l1, IntList l2) {

    if (l1.size() - l2.size() != 0)
        return l1.size() - l2.size();
    for (int i = 0; i < l1.size(); i++) {
        if (l1.getInt(i) == l2.getInt(i))
            continue;
        return l1.getInt(i) - l2.getInt(i);
    }
    return 0;
}
 
Example 3
Source File: AgreeSetGenerator.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(IntList l1, IntList l2) {

    if (l1.size() - l2.size() != 0)
        return l2.size() - l1.size();
    for (int i = 0; i < l1.size(); i++) {
        if (l1.getInt(i) == l2.getInt(i))
            continue;
        return l2.getInt(i) - l1.getInt(i);
    }
    return 0;
}
 
Example 4
Source File: AgreeSetGenerator.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(IntList l1, IntList l2) {

    if (l1.size() - l2.size() != 0)
        return l1.size() - l2.size();
    for (int i = 0; i < l1.size(); i++) {
        if (l1.getInt(i) == l2.getInt(i))
            continue;
        return l1.getInt(i) - l2.getInt(i);
    }
    return 0;
}
 
Example 5
Source File: AgreeSetGenerator.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(IntList l1, IntList l2) {

    if (l1.size() - l2.size() != 0)
        return l2.size() - l1.size();
    for (int i = 0; i < l1.size(); i++) {
        if (l1.getInt(i) == l2.getInt(i))
            continue;
        return l2.getInt(i) - l1.getInt(i);
    }
    return 0;
}
 
Example 6
Source File: GradientBoostingMachine.java    From samantha with MIT License 5 votes vote down vote up
public double evaluate(DoubleList preds, PredictiveModel boostModel,
                       LearningData validData, IntList subset) {
    double objVal = 0.0;
    int idx = 0;
    validData.startNewIteration();
    List<LearningInstance> instances;
    while ((instances = validData.getLearningInstance()).size() > 0) {
        List<StochasticOracle> oracles = new ArrayList<>(instances.size());
        for (LearningInstance ins : instances) {
            double modelOutput = 0.0;
            if (preds != null) {
                int subidx = idx;
                if (subset != null) {
                    subidx = subset.getInt(idx);
                }
                modelOutput += (preds.getDouble(subidx));
                idx++;
            }
            modelOutput += boostModel.predict(ins)[0];
            oracles.add(new StochasticOracle(modelOutput, ins.getLabel(), ins.getWeight()));
        }
        oracles = objectiveFunction.wrapOracle(oracles);
        for (StochasticOracle oracle : oracles) {
            objVal += oracle.getObjectiveValue();
        }
    }
    return objVal;
}
 
Example 7
Source File: FindCoversGenerator.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
private IntList generateNextOrdering(List<DifferenceSet> next, IntList currentOrdering, int attribute) {

        IntList result = new IntArrayList();

        Int2IntMap counting = new Int2IntArrayMap();
        boolean seen = false;
        for (int i = 0; i < currentOrdering.size(); i++) {

            if (!seen) {
                if (currentOrdering.getInt(i) == attribute) {
                    seen = true;
                }
            } else {

                counting.put(currentOrdering.getInt(i), 0);
                for (DifferenceSet ds : next) {

                    if (ds.getAttributes().get(currentOrdering.getInt(i))) {
                        counting.put(currentOrdering.getInt(i), counting.get(currentOrdering.getInt(i)) + 1);
                    }
                }
            }
        }

        // TODO: Comperator und TreeMap --> Tommy
        while (true) {

            if (counting.size() == 0) {
                break;
            }

            int biggestAttribute = -1;
            int numberOfOcc = 0;
            for (int attr : counting.keySet()) {

                if (biggestAttribute < 0) {
                    biggestAttribute = attr;
                    numberOfOcc = counting.get(attr);
                    continue;
                }

                int tempOcc = counting.get(attr);
                if (tempOcc > numberOfOcc) {
                    numberOfOcc = tempOcc;
                    biggestAttribute = attr;
                } else if (tempOcc == numberOfOcc) {
                    if (biggestAttribute > attr) {
                        biggestAttribute = attr;
                    }
                }
            }

            if (numberOfOcc == 0) {
                break;
            }

            result.add(biggestAttribute);
            counting.remove(biggestAttribute);
        }

        return result;
    }