Examples of iterateNonZero()


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

    long userID = key.get();
    if (usersToRecommendFor != null && !usersToRecommendFor.contains(userID)) {
      return;
    }
    Vector userVector = maybePruneUserVector(value.get());
    Iterator<Vector.Element> it = userVector.iterateNonZero();
    VarIntWritable itemIndexWritable = new VarIntWritable();
    VectorOrPrefWritable vectorOrPref = new VectorOrPrefWritable();
    while (it.hasNext()) {
      Vector.Element e = it.next();
      itemIndexWritable.set(e.index());
View Full Code Here

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

                    Reporter reporter) throws IOException {
      boolean firstIsOutFrag =  ((VectorWritable)v.get(0)).get().size() == outCardinality;
      Vector outFrag = firstIsOutFrag ? ((VectorWritable)v.get(0)).get() : ((VectorWritable)v.get(1)).get();
      Vector multiplier = firstIsOutFrag ? ((VectorWritable)v.get(1)).get() : ((VectorWritable)v.get(0)).get();

      Iterator<Vector.Element> it = multiplier.iterateNonZero();
      while (it.hasNext()) {
        Vector.Element e = it.next();
        row.set(e.index());
        VectorWritable outVector = new VectorWritable(outFrag.times(e.get()));
        out.collect(row, outVector);
View Full Code Here

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

    Iterator<VectorWritable> it = values.iterator();
    if (!it.hasNext()) {
      return;
    }
    Vector value = it.next().get();
    Iterator<Vector.Element> it1 = value.iterateNonZero();
    Vector vector = new RandomAccessSparseVector((int) featureCount, value.getNumNondefaultElements());
    while (it1.hasNext()) {
      Vector.Element e = it1.next();
      if (!dictionary.containsKey(e.index())) {
        continue;
View Full Code Here

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

  @Override
  protected void map(WritableComparable<?> key, VectorWritable value, Context context)
    throws IOException, InterruptedException {
    Vector vector = value.get();
    Iterator<Vector.Element> it = vector.iterateNonZero();

    while (it.hasNext()) {
      Vector.Element e = it.next();
      context.write(new IntWritable(e.index()), ONE);
    }
View Full Code Here

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

      boolean firstIsOutFrag =  ((VectorWritable)v.get(0)).get().size() == outCardinality;
      Vector outFrag = firstIsOutFrag ? ((VectorWritable)v.get(0)).get() : ((VectorWritable)v.get(1)).get();
      Vector multiplier = firstIsOutFrag ? ((VectorWritable)v.get(1)).get() : ((VectorWritable)v.get(0)).get();

      VectorWritable outVector = new VectorWritable();
      Iterator<Vector.Element> it = multiplier.iterateNonZero();
      while (it.hasNext()) {
        Vector.Element e = it.next();
        row.set(e.index());
        outVector.set(outFrag.times(e.get()));
        out.collect(row, outVector);
View Full Code Here

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

    Iterator<VectorWritable> it = values.iterator();
    if (!it.hasNext()) {
      return;
    }
    Vector value = it.next().get();
    Iterator<Vector.Element> it1 = value.iterateNonZero();
    Vector vector = new RandomAccessSparseVector((int) featureCount, value.getNumNondefaultElements());
    while (it1.hasNext()) {
      Vector.Element e = it1.next();
      if (!dictionary.containsKey(e.index())) {
        continue;
View Full Code Here

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

  @Override
  protected void map(WritableComparable<?> key, VectorWritable value,
      Context context) throws IOException, InterruptedException {
    Vector probabilities = classifier.classify(value.get());
    Vector selections = policy.select(probabilities);
    for (Iterator<Element> it = selections.iterateNonZero(); it.hasNext();) {
      Element el = it.next();
      classifier.train(el.index(), value.get(), el.get());
    }
  }
 
View Full Code Here

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

      row = row.normalize(1);
      if (stayingProbability != 1.0) {
        row.assign(Functions.MULT, stayingProbability);
      }

      Iterator<Vector.Element> it = row.iterateNonZero();
      while (it.hasNext()) {
        Vector.Element e = it.next();
        RandomAccessSparseVector tmp = new RandomAccessSparseVector(numVertices, 1);
        tmp.setQuick(rowIndex, e.get());
        r.set(e.index());
View Full Code Here

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

        for (int i = 0; i < vecSize; i++) {
          extendAColIfNeeded(i, aRowCount + 1);
          aCols[i].setQuick(aRowCount, vec.getQuick(i));
        }
      } else if (vec.size() > 0) {
        for (Iterator<Vector.Element> vecIter = vec.iterateNonZero(); vecIter.hasNext();) {
          Vector.Element vecEl = vecIter.next();
          int i = vecEl.index();
          extendAColIfNeeded(i, aRowCount + 1);
          aCols[i].setQuick(aRowCount, vecEl.get());
        }
View Full Code Here

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

              /* 100% zero A column in the block, skip it as sparse */
              continue;
            }
            int j = -1;
            for (Iterator<Vector.Element> aColIter = aCol.iterateNonZero(); aColIter.hasNext();) {
              Vector.Element aEl = aColIter.next();
              j = aEl.index();

              /*
               * now we compute only swathes between aRowBegin..aRowBegin+bh
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.