Package org.apache.mahout.math

Examples of org.apache.mahout.math.Vector.plus()


      Context context) throws IOException, InterruptedException {

    Vector recommendationVector = null;
    for (VectorWritable vectorWritable : values) {
      recommendationVector = recommendationVector == null ? vectorWritable
          .get() : recommendationVector.plus(vectorWritable.get());
    }

    Queue<RecommendedItem> topItems = new PriorityQueue<RecommendedItem>(
        recommendationsPerUser + 1,
        Collections.reverseOrder(ByValueRecommendedItemComparator
View Full Code Here


  public void reduce(VarLongWritable key, Iterable<VectorWritable> values,
      Context context) throws IOException, InterruptedException {
    Vector partial = null;
    for (VectorWritable vectorWritable : values) {
      partial = partial == null ? vectorWritable.get() : partial
          .plus(vectorWritable.get());
    }
    context.write(key, new VectorWritable(partial));
  }
}
View Full Code Here

        assertEquals("too many values", 1, values.size());
        // String value = values.get(0).toString();
        KMeansInfo info = values.get(0);
       
        count += info.getPoints();
        total = total.plus(info.getPointTotal());
      }
      assertEquals("total points", 9, count);
      assertEquals("point total[0]", 27, (int) total.get(0));
      assertEquals("point total[1]", 27, (int) total.get(1));
    }
View Full Code Here

        List<ClusterObservations> values = combinerWriter.getValue(key);
        assertEquals("too many values", 1, values.size());
        ClusterObservations info = values.get(0);

        count += (int) info.getS0();
        total = total.plus(info.getS1());
      }
      assertEquals("total points", 9, count);
      assertEquals("point total[0]", 27, (int) total.get(0));
      assertEquals("point total[1]", 27, (int) total.get(1));
    }
View Full Code Here

     * so the computation is much simpler */
    Vector predictionVector = null;
    for (PrefAndSimilarityColumnWritable prefAndSimilarityColumn : values) {
      predictionVector = predictionVector == null
          ? prefAndSimilarityColumn.getSimilarityColumn()
          : predictionVector.plus(prefAndSimilarityColumn.getSimilarityColumn());
    }

    Iterator<Vector.Element> predictions = predictionVector.iterateNonZero();
    List<RecommendedItem> recommendations = new ArrayList<RecommendedItem>();
    while (predictions.hasNext() && recommendations.size() < recommendationsPerUser) {
View Full Code Here

        List<ClusterObservations> values = combinerWriter.getValue(key);
        assertEquals("too many values", 1, values.size());
        ClusterObservations info = values.get(0);

        count += info.getS0();
        total = total.plus(info.getS1());
      }
      assertEquals("total points", 9, count);
      assertEquals("point total[0]", 27, (int) total.get(0));
      assertEquals("point total[1]", 27, (int) total.get(1));
    }
View Full Code Here

    );
    if (mean != null) {
      if (scale != null) {
        return scale.times(v).plus(mean);
      } else {
        return v.plus(mean);
      }
    } else {
      if (scale != null) {
        return scale.times(v);
      } else {
View Full Code Here

     * so we use the sum of similarities for that. */
    Vector predictionVector = null;
    for (PrefAndSimilarityColumnWritable prefAndSimilarityColumn : values) {
      predictionVector = predictionVector == null
          ? prefAndSimilarityColumn.getSimilarityColumn()
          : predictionVector.plus(prefAndSimilarityColumn.getSimilarityColumn());
    }
    writeRecommendedItems(userID, predictionVector, context);
  }

  private void reduceNonBooleanData(VarLongWritable userID,
View Full Code Here

        List<ClusterObservations> values = combinerWriter.getValue(key);
        assertEquals("too many values", 1, values.size());
        ClusterObservations info = values.get(0);

        count += info.getS0();
        total = total.plus(info.getS1());
      }
      assertEquals("total points", 9, count);
      assertEquals("point total[0]", 27, (int) total.get(0));
      assertEquals("point total[1]", 27, (int) total.get(1));
    }
View Full Code Here

     * so we use the sum of similarities for that. */
    Vector predictionVector = null;
    for (PrefAndSimilarityColumnWritable prefAndSimilarityColumn : values) {
      predictionVector = predictionVector == null
          ? prefAndSimilarityColumn.getSimilarityColumn()
          : predictionVector.plus(prefAndSimilarityColumn.getSimilarityColumn());
    }
    writeRecommendedItems(userID, predictionVector, context);
  }

  private void reduceNonBooleanData(VarLongWritable userID,
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.