Examples of FastIDSet


Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

    if (numUsers > 0) {
      List<FastIDSet> newClusters = new ArrayList<FastIDSet>(numUsers);
      // Begin with a cluster for each user:
      LongPrimitiveIterator it = model.getUserIDs();
      while (it.hasNext()) {
        FastIDSet newCluster = new FastIDSet();
        newCluster.add(it.nextLong());
        newClusters.add(newCluster);
      }
      if (numUsers > 1) {
        findClusters(newClusters);
      }
View Full Code Here

Examples of org.apache.mahout.cf.taste.impl.common.FastIDSet

 
  private void findClusters(List<FastIDSet> newClusters) throws TasteException {
    if (clusteringByThreshold) {
      Pair<FastIDSet,FastIDSet> nearestPair = findNearestClusters(newClusters);
      if (nearestPair != null) {
        FastIDSet cluster1 = nearestPair.getFirst();
        FastIDSet cluster2 = nearestPair.getSecond();
        while (clusterSimilarity.getSimilarity(cluster1, cluster2) >= clusteringThreshold) {
          newClusters.remove(cluster1);
          newClusters.remove(cluster2);
          FastIDSet merged = new FastIDSet(cluster1.size() + cluster2.size());
          merged.addAll(cluster1);
          merged.addAll(cluster2);
          newClusters.add(merged);
          nearestPair = findNearestClusters(newClusters);
          if (nearestPair == null) {
            break;
          }
          cluster1 = nearestPair.getFirst();
          cluster2 = nearestPair.getSecond();
        }
      }
    } else {
      while (newClusters.size() > numClusters) {
        Pair<FastIDSet,FastIDSet> nearestPair = findNearestClusters(newClusters);
        if (nearestPair == null) {
          break;
        }
        FastIDSet cluster1 = nearestPair.getFirst();
        FastIDSet cluster2 = nearestPair.getSecond();
        newClusters.remove(cluster1);
        newClusters.remove(cluster2);
        FastIDSet merged = new FastIDSet(cluster1.size() + cluster2.size());
        merged.addAll(cluster1);
        merged.addAll(cluster2);
        newClusters.add(merged);
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.