Package org.apache.mahout.cf.taste.impl.common

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


   * Standard deviation of normalized producer accuracy
   * Not a standard score
   * @return double
   */
  public RunningAverageAndStdDev getNormalizedStats() {
    RunningAverageAndStdDev summer = new FullRunningAverageAndStdDev();
    for (int d = 0; d < confusionMatrix.length; d++) {
      double total = 0;
      for (int j = 0; j < confusionMatrix.length; j++) {
        total += confusionMatrix[d][j];
      }
      summer.addDatum(confusionMatrix[d][d] / (total + 0.000001));
    }
   
    return summer;
  }
View Full Code Here


    }
    return averageCount;
  }
 
  private RunningAverage buildRunningAverage() {
    return stdDevWeighted ? new FullRunningAverageAndStdDev() : new FullRunningAverage();
  }
View Full Code Here

  private static Collection<Callable<Void>> wrapWithStatsCallables(Collection<Callable<Void>> callables) {
    int size = callables.size();
    Collection<Callable<Void>> wrapped = Lists.newArrayListWithExpectedSize(size);
    int count = 1;
    RunningAverageAndStdDev timing = new FullRunningAverageAndStdDev();
    for (Callable<Void> callable : callables) {
      boolean logStats = count++ % 1000 == 0;
      wrapped.add(new StatsCallable(callable, logStats, timing));
    }
    return wrapped;
View Full Code Here

 
  private class MeanStdevRetriever implements Retriever<Long,RunningAverageAndStdDev> {
   
    @Override
    public RunningAverageAndStdDev get(Long userID) throws TasteException {
      RunningAverageAndStdDev running = new FullRunningAverageAndStdDev();
      PreferenceArray prefs = dataModel.getPreferencesFromUser(userID);
      int size = prefs.length();
      for (int i = 0; i < size; i++) {
        running.addDatum(prefs.getValue(i));
      }
      return running;
    }
View Full Code Here

  private static double computeThreshold(PreferenceArray prefs) {
    if (prefs.length() < 2) {
      // Not enough data points -- return a threshold that allows everything
      return Double.NEGATIVE_INFINITY;
    }
    RunningAverageAndStdDev stdDev = new FullRunningAverageAndStdDev();
    int size = prefs.length();
    for (int i = 0; i < size; i++) {
      stdDev.addDatum(prefs.getValue(i));
    }
    return stdDev.getAverage() + stdDev.getStandardDeviation();
  }
View Full Code Here

  public void readFields(DataInput dataInput) throws IOException {
    int count = Varint.readUnsignedVarInt(dataInput);
    double diff = dataInput.readDouble();
    double mk = dataInput.readDouble();
    double sk = dataInput.readDouble();
    average = new FullRunningAverageAndStdDev(count, diff, mk, sk);
  }
View Full Code Here

 
  @Override
  protected void reduce(EntityEntityWritable key,
                        Iterable<FloatWritable> values,
                        Context context) throws IOException, InterruptedException {
    FullRunningAverageAndStdDev average = new FullRunningAverageAndStdDev();
    for (FloatWritable value : values) {
      average.addDatum(value.get());
    }
    context.write(key, new FullRunningAverageAndStdDevWritable(average));
  }
View Full Code Here

    for (Map.Entry<Long,PreferenceArray> entry : testPrefs.entrySet()) {
      estimateCallables.add(
          new PreferenceEstimateCallable(recommender, entry.getKey(), entry.getValue(), noEstimateCounter));
    }
    log.info("Beginning evaluation of {} users", estimateCallables.size());
    RunningAverageAndStdDev timing = new FullRunningAverageAndStdDev();
    execute(estimateCallables, noEstimateCounter, timing);
    return computeFinalEvaluation();
  }
View Full Code Here

    Collection<Callable<Void>> callables = Lists.newArrayList();
    while (userSampler.hasNext()) {
      callables.add(new LoadCallable(recommender, userSampler.next()));
    }
    AtomicInteger noEstimateCounter = new AtomicInteger();
    RunningAverageAndStdDev timing = new FullRunningAverageAndStdDev();
    AbstractDifferenceRecommenderEvaluator.execute(callables, noEstimateCounter, timing);
    return new LoadStatistics(timing);
  }
View Full Code Here

    }
    if (averageCount < maxEntries) {
      if (hasMkSk) {
        double mk = Double.parseDouble(tokens[4]);
        double sk = Double.parseDouble(tokens[5]);
        average = new FullRunningAverageAndStdDev(count, diff, mk, sk);
      } else {
        average = new FullRunningAverage(count, diff);
      }
      level1Map.put(itemID2, average);
      averageCount++;
View Full Code Here

TOP

Related Classes of org.apache.mahout.cf.taste.impl.common.FullRunningAverageAndStdDev

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.