Package org.apache.mahout.math

Examples of org.apache.mahout.math.SequentialAccessSparseVector$IntDoublePairIterator


    public void reduce(WritableComparable<?> key,
                       Iterator<VectorWritable> vectors,
                       OutputCollector<WritableComparable<?>, VectorWritable> out,
                       Reporter reporter) throws IOException {
      Vector merged = VectorWritable.merge(vectors).get();
      out.collect(key, new VectorWritable(new SequentialAccessSparseVector(merged)));
    }
View Full Code Here


      if (log.isDebugEnabled()) {
        log.debug("(DEBUG - REDUCE) Row[{}], Column[{}], Value[{}]",
                  row.get(), element.getCol(), element.getVal());
      }
    }
    SequentialAccessSparseVector output = new SequentialAccessSparseVector(out);
    context.write(row, new VectorWritable(output));
  }
View Full Code Here

    return sampler.sample(topicTermCounts.viewRow(topic));
  }

  public void reset() {
    for (int x = 0; x < numTopics; x++) {
      topicTermCounts.assignRow(x, new SequentialAccessSparseVector(numTerms));
    }
    topicSums.assign(1.0);
    if (threadPool.isTerminated()) {
      initializeThreadPool();
    }
View Full Code Here

    boolean hasBindings = bindings != null;
    boolean isSparse = !v.isDense() && v.getNumNondefaultElements() != v.size();

    // we assume sequential access in the output
    Vector provider = v.isSequentialAccess() ? v : new SequentialAccessSparseVector(v);

    buffer.append('[');
    for (Element elem : provider.nonZeroes()) {

      if (hasBindings && bindings.length >= elem.index() + 1 && bindings[elem.index()] != null) {
View Full Code Here

  @Override
  public void reduce(WritableComparable<?> key, Iterable<VectorWritable> vectors, Context ctx)
    throws IOException, InterruptedException {
    Vector merged = VectorWritable.merge(vectors.iterator()).get();
    result.set(new SequentialAccessSparseVector(merged));
    ctx.write(key, result);
  }
View Full Code Here

          vector.setQuick(termId, vector.getQuick(termId) + 1);
        }
      }
    }
    if (sequentialAccess) {
      vector = new SequentialAccessSparseVector(vector);
    }

    if (namedVector) {
      vector = new NamedVector(vector, key.toString());
    }
View Full Code Here

  private double t2;

  @Override
  public Vector select(Vector probabilities) {
    int maxValueIndex = probabilities.maxValueIndex();
    Vector weights = new SequentialAccessSparseVector(probabilities.size());
    weights.set(maxValueIndex, 1.0);
    return weights;
  }
View Full Code Here

  @Override
  protected void map(Text key, Text value, Context context) throws IOException, InterruptedException {
    Vector vector;
    if (sequentialVectors) {
      vector = new SequentialAccessSparseVector(cardinality);
    } else {
      vector = new RandomAccessSparseVector(cardinality);
    }
    if (namedVectors) {
      vector = new NamedVector(vector, key.toString());
View Full Code Here

      int prevPercentDone = 1;

      for (Map.Entry<String, List<Integer>> itemFeature : itemFeaturesMap.entrySet()) {
        int numfeatures = itemFeature.getValue().size();
        itemWritable.set(itemFeature.getKey());
        Vector featureVector = new SequentialAccessSparseVector(numfeatures);
        int i = 0;
        for (Integer feature : itemFeature.getValue()) {
          featureVector.setQuick(i++, feature);
        }
        featuresWritable.set(featureVector);
        writer.append(itemWritable, featuresWritable);
        // Update the progress
        double percentDone = ++doneRecords * 100.0 / totalRecords;
View Full Code Here

        df = minDf;
      }
      vector.setQuick(e.index(), tfidf.calculate((int) e.get(), (int) df, (int) featureCount, (int) vectorCount));
    }
    if (sequentialAccess) {
      vector = new SequentialAccessSparseVector(vector);
    }
   
    if (namedVector) {
      vector = new NamedVector(vector, key.toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.SequentialAccessSparseVector$IntDoublePairIterator

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.