Package org.apache.mahout.math.list

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


  }
 
  public TransactionTree(int[] items, Long support) {
    representedAsList = true;
    transactionSet = Lists.newArrayList();
    transactionSet.add(new Pair<IntArrayList,Long>(new IntArrayList(items), support));
  }
View Full Code Here


    //int count = 0;
    while (it.hasNext()) {
      Pair<IntArrayList,Long> p = it.next();
      //items += p.getFirst().size();
      //count++;
      IntArrayList items= p.getFirst();
      for (int idx = 0; idx < items.size(); idx++) {
        if (!frequencyList.containsKey(items.get(idx))) {
          frequencyList.put(items.get(idx), new MutableLong(0));
        }
        frequencyList.get(items.get(idx)).add(p.getSecond());
      }
    }
    return frequencyList;
  }
View Full Code Here

        int[] items = new int[length];
        for (int j = 0; j < length; j++) {
          vInt.readFields(in);
          items[j] = vInt.get();
        }
        Pair<IntArrayList,Long> transaction = new Pair<IntArrayList,Long>(new IntArrayList(items), support);
        transactionSet.add(transaction);
      }
    } else {
      vInt.readFields(in);
      nodes = vInt.get();
View Full Code Here

        vLong.write(out);

        vInt.set(transaction.getFirst().size());
        vInt.write(out);

        IntArrayList items = transaction.getFirst();
        for (int idx = 0; idx < items.size(); idx++) {
          int item = items.get(idx);
          vInt.set(item);
          vInt.write(out);
        }
      }
    } else {
View Full Code Here

      if (fMap.containsKey(item) && !item.trim().isEmpty()) {
        itemSet.add(fMap.get(item));
      }
    }

    IntArrayList itemArr = new IntArrayList(itemSet.size());
    itemSet.keys(itemArr);
    itemArr.sort();

    OpenIntHashSet groups = new OpenIntHashSet();
    for (int j = itemArr.size() - 1; j >= 0; j--) {
      // generate group dependent shards
      int item = itemArr.get(j);
      int groupID = PFPGrowth.getGroup(item, maxPerGroup);
       
      if (!groups.contains(groupID)) {
        IntArrayList tempItems = new IntArrayList(j + 1);
        tempItems.addAllOfFromTo(itemArr, 0, j);
        context.setStatus("Parallel FPGrowth: Generating Group Dependent transactions for: " + item);
        wGroupID.set(groupID);
        context.write(wGroupID, new TransactionTree(tempItems, 1L));
      }
      groups.add(groupID);
View Full Code Here

    super.setUp();
    gen = RandomUtils.getRandom();
  }

  private IntArrayList generateRandomArray() {
    IntArrayList list = new IntArrayList();
    for (int i = 0; i < MAX_FEATURES; i++) {
      if (gen.nextInt() % SKIP_RATE == 0) {
        list.add(i);
      }
    }
    return list;
  }
View Full Code Here

   
    TransactionTree tree = new TransactionTree();
    int nodes = 0;
    int total = 0;
    for (int i = 0; i < MAX_TRANSACTIONS; i++) {
      IntArrayList array = generateRandomArray();
      total += array.size();
      nodes += tree.addPattern(array, 1 + gen.nextInt(MAX_DUPLICATION));
    }

    log.info("Input integers: {}", total);
    log.info("Input data Size: {}", total * SIZE_INT / (double) MEGABYTE);
View Full Code Here

      for (int i = transactionTree.childCount(childId) - 1; i >= 0; i--) {
        sum += transactionTree.count(transactionTree.childAtIndex(childId, i));
      }
    } while (sum == transactionTree.count(childId));

    IntArrayList data = new IntArrayList();
    Iterator<int[]> it = depth.iterator();
    it.next();
    while (it.hasNext()) {
      data.add(transactionTree.attribute(it.next()[0]));
    }

    Pair<IntArrayList,Long> returnable = new Pair<IntArrayList,Long>(data, transactionTree.count(childId) - sum);

    int[] top = depth.peek();
View Full Code Here

                                      +" != "+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();
      attrLst.clear();
      while (currNode != root) {
        if (currNode.count() < count)
          throw new IllegalStateException();
        attrLst.add(currNode.attribute());
        currNode = currNode.parent();
      }

      toRet.accumulate(attrLst, count);     
    }   
View Full Code Here

    int attribute = node.attribute();
    if (items == null) {
      // at root
      if (!(node == root))
        throw new IllegalStateException();
      items = new IntArrayList();
    } else {
      items.add(attribute);
    }
    for (FPNode child : node.children()) {
      added+= recursivelyAddPrefixPats(pTree, qTree, child, items);
View Full Code Here

TOP

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

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.