Package org.apache.mahout.math.Vector

Examples of org.apache.mahout.math.Vector.Element.index()


      Vector updateVector = dataPoint.times(1 / this.promotionStep);
      log.info("Winnow update positive: {}", updateVector);
      Iterator<Element> iter = updateVector.iterateNonZero();
      while (iter.hasNext()) {
        Element element = iter.next();
        model.timesDelta(element.index(), element.get());
      }
    } else {
      // case two
      Vector updateVector = dataPoint.times(1 / this.promotionStep);
      log.info("Winnow update negative: {}", updateVector);
View Full Code Here


      Vector updateVector = dataPoint.times(1 / this.promotionStep);
      log.info("Winnow update negative: {}", updateVector);
      Iterator<Element> iter = updateVector.iterateNonZero();
      while (iter.hasNext()) {
        Element element = iter.next();
        model.timesDelta(element.index(), element.get());
      }
    }
    log.info(model.toString());
  }
}
View Full Code Here

  public SequentialAccessSparseVector(Vector other) {
    this(other.getName(), other.size(), other.getNumNondefaultElements());
    Iterator<Element> it = other.iterateNonZero();
    Element e;
    while(it.hasNext() && (e = it.next()) != null) {
      set(e.index(), e.get());
    }
  }

  public SequentialAccessSparseVector(SequentialAccessSparseVector other, boolean shallowCopy) {
    super(other.getName(), other.size());
View Full Code Here

      while (myIter.hasNext() && otherIter.hasNext()) {
        if (myCurrent == null) myCurrent = myIter.next();
        if (otherCurrent == null) otherCurrent = otherIter.next();
       
        int myIndex = myCurrent.index();
        int otherIndex = otherCurrent.index();
       
        if (myIndex < otherIndex) {
          // due to the sparseness skipping occurs more hence checked before equality
          myCurrent = null;
        } else if (myIndex > otherIndex){
View Full Code Here

      return result;
    } else { // seq.rand. seq.dense
      Iterator<Element> iter = iterateNonZero();
      while (iter.hasNext()) {
        Element element = iter.next();
        result += element.get() * x.getQuick(element.index());
      }
      return result;
    }
  }
 
View Full Code Here

    Vector vector = value.get();
    Iterator<Element> it = vector.iterateNonZero();
   
    while (it.hasNext()) {
      Element e = it.next();
      output.collect(new IntWritable(e.index()), ONE);
    }
    output.collect(TOTAL_COUNT, ONE);
  }
}
View Full Code Here

    Iterator<Element> it = value.iterateNonZero();
    Vector vector = new RandomAccessSparseVector(key.toString(), (int) featureCount, value
        .getNumNondefaultElements());
    while (it.hasNext()) {
      Element e = it.next();
      if (!dictionary.containsKey(e.index())) {
        continue;
      }
      long df = dictionary.get(e.index());
      if (df / vectorCount > maxDfPercent) {
        continue;
View Full Code Here

    while (it.hasNext()) {
      Element e = it.next();
      if (!dictionary.containsKey(e.index())) {
        continue;
      }
      long df = dictionary.get(e.index());
      if (df / vectorCount > maxDfPercent) {
        continue;
      }
      if (df < minDf) {
        df = minDf;
View Full Code Here

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

      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());
    }
  }
 
  /*
   * (non-Javadoc)
 
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.