Package org.apache.mahout.math.list

Examples of org.apache.mahout.math.list.LongArrayList


   */
  public Pair<FPTree, FPTree> splitSinglePrefix() {
    if (root.numChildren() != 1) {
      return new Pair<FPTree, FPTree>(null, this);
    }
    LongArrayList pAttrCountList = new LongArrayList();
    LongArrayList qAttrCountList = attrCountList.copy();

    FPNode currNode = root;
    while (currNode.numChildren() == 1) {
      currNode = currNode.children().iterator().next();
      if (pAttrCountList.size() <= currNode.attribute()) {
        pAttrCountList.setSize(currNode.attribute() + 1);
      }
      pAttrCountList.set(currNode.attribute(), currNode.count());
      qAttrCountList.set(currNode.attribute(), 0);
    }

    FPTree pTree = new FPTree(pAttrCountList, minSupport);
    FPTree qTree = new FPTree(qAttrCountList, minSupport);
    recursivelyAddPrefixPats(pTree, qTree, root, null);
View Full Code Here


   * Note that the counts in attrCounts are assumed to be complete;
   * they are not updated as the tree is modified.
   */
  public FPTree(long[] attrCounts, long minSupport) {
    this.root = new FPNode(null, -1, 0);
    this.attrCountList = new LongArrayList();
    for (int i = 0; i < attrCounts.length; i++)
      if (attrCounts[i] > 0) {
        if (attrCountList.size() < (i + 1)) {
          attrCountList.setSize(i + 1);
        }
View Full Code Here

  /**
   * Returns a conditional FP tree based on the targetAttr, containing
   * only items that are more frequent.
   */
  public FPTree createMoreFreqConditionalTree(int targetAttr) {
    LongArrayList counts = new LongArrayList();
    List<FPNode> nodeList = (List<FPNode>) attrNodeLists.get(targetAttr);

    for (FPNode currNode : nodeList) {
      long pathCount = currNode.count();
      while (currNode != root) {
        int currAttr = currNode.attribute();
        if (counts.size() <= currAttr) {
          counts.setSize(currAttr + 1);
        }
        long count = counts.get(currAttr);
        counts.set(currNode.attribute(), count + pathCount);
        currNode = currNode.parent();
      }
    }
    if (counts.get(targetAttr) != attrCountList.get(targetAttr))
      throw new IllegalStateException("mismatched counts for targetAttr="
                                      + targetAttr + ", (" + counts.get(targetAttr)
                                      + " != " + attrCountList.get(targetAttr) + "); "
                                      + "thisTree=" + this + "\n");
    counts.set(targetAttr, 0L);

    FPTree toRet = new FPTree(counts, minSupport);
    IntArrayList attrLst = new IntArrayList();
    for (FPNode currNode : (List<FPNode>) attrNodeLists.get(targetAttr)) {
      long count = currNode.count();
View Full Code Here

   */
  public Pair<FPTree, FPTree> splitSinglePrefix() {
    if (root.numChildren() != 1) {
      return new Pair<FPTree, FPTree>(null, this);
    }
    LongArrayList pAttrCountList = new LongArrayList();
    LongArrayList qAttrCountList = attrCountList.copy();

    FPNode currNode = root;
    while (currNode.numChildren() == 1) {
      currNode = currNode.children().iterator().next();
      if (pAttrCountList.size() <= currNode.attribute())
        pAttrCountList.setSize(currNode.attribute() + 1);
      pAttrCountList.set(currNode.attribute(), currNode.count());
      qAttrCountList.set(currNode.attribute(), 0);
    }

    FPTree pTree = new FPTree(pAttrCountList, minSupport);
    FPTree qTree = new FPTree(qAttrCountList, minSupport);
    recursivelyAddPrefixPats(pTree, qTree, root, null);
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.list.LongArrayList

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.