Package org.apache.mahout.math

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


  private Path output;
 
  public static List<VectorWritable> getPointsWritable(double[][] raw) {
    List<VectorWritable> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new SequentialAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(new VectorWritable(vec));
    }
    return points;
  }
View Full Code Here


    }

    private void extendAColIfNeeded(int col, int rowCount) {
      if (aCols[col] == null) {
        aCols[col] =
          new SequentialAccessSparseVector(rowCount < 10000 ? 10000 : rowCount,
                                           1);
      } else if (aCols[col].size() < rowCount) {
        Vector newVec =
          new SequentialAccessSparseVector(rowCount << 1,
                                           aCols[col].getNumNondefaultElements() << 1);
        newVec.viewPart(0, aCols[col].size()).assign(aCols[col]);
        aCols[col] = newVec;
      }
    }
View Full Code Here

        // output empty rows if we never output partial products for them
        // this happens in sparse matrices when last rows are all zeros
        // and is subsequently causing shorter Q matrix row count which we
        // probably don't want to repair there but rather here.
        Vector yDummy = new SequentialAccessSparseVector(kp);
        // outValue.set(yDummy);
        for (lastRowIndex += 1; lastRowIndex < aRowCount; lastRowIndex++) {
          // outKey.setTaskItemOrdinal(lastRowIndex);
          // context.write(outKey, outValue);
View Full Code Here

  }

  public static List<Vector> getPoints(double[][] raw) {
    List<Vector> points = Lists.newArrayList();
    for (double[] fr : raw) {
      Vector vec = new SequentialAccessSparseVector(fr.length);
      vec.assign(fr);
      points.add(vec);
    }
    return points;
  }
View Full Code Here

      String[] tokens = SEPARATOR.split(line.toString());
      int rowIndex = vertexIDsToIndex.get(Integer.parseInt(tokens[0]));
      int columnIndex = vertexIDsToIndex.get(Integer.parseInt(tokens[1]));

      Vector partialTransitionMatrixRow = new SequentialAccessSparseVector(numVertices, 1);
      row.set(rowIndex);
      partialTransitionMatrixRow.setQuick(columnIndex, 1);
      ctx.write(row, new VectorWritable(partialTransitionMatrixRow));

      if (symmetric && rowIndex != columnIndex) {
        partialTransitionMatrixRow = new SequentialAccessSparseVector(numVertices, 1);
        row.set(columnIndex);
        partialTransitionMatrixRow.setQuick(rowIndex, 1);
        ctx.write(row, new VectorWritable(partialTransitionMatrixRow));
      }
    }
View Full Code Here

                                                          double entryMean) {
    Matrix m = new SparseRowMatrix(numRows, numCols);
    //double n = 0;
    Random r = RandomUtils.getRandom();
    for (int i = 0; i < nonNullRows; i++) {
      Vector v = new SequentialAccessSparseVector(numCols);
      for (int j = 0; j < entriesPerRow; j++) {
        int col = r.nextInt(numCols);
        double val = r.nextGaussian();
        v.set(col, val * entryMean);
      }
      int c = r.nextInt(numRows);
      if (r.nextBoolean() || numRows == nonNullRows) {
        m.assignRow(numRows == nonNullRows ? i : c, v);
      } else {
View Full Code Here

      if (showScores) {
        output.printf(Locale.ENGLISH, "\"%s\", \"%s\", \"%s\", \"%s\"\n",
            "target", "model-output", "log-likelihood", "average-likelihood");
      }
      while (line != null) {
        Vector v = new SequentialAccessSparseVector(lmp.getNumFeatures());
        //TODO: How to avoid extra target values not shown in the training process.
        int target = csv.processLine(line, v);
        double likelihood = learner.logLikelihood(target, v);
        double score = learner.classifyFull(v).maxValue();
       
View Full Code Here

      } else {
        vector = vector.normalize(normPower);
      }
    }
    if (sequentialAccess) {
      vector = new SequentialAccessSparseVector(vector);
    }
   
    if (namedVector) {
      vector = new NamedVector(vector, key.toString());
    }
View Full Code Here

    this.sparsity = sparsity;
    this.numVectors = numVectors;
    this.loop = loop;
    this.opsPerUnit = opsPerUnit;
    for (int i = 0; i < numVectors; i++) {
      Vector v = new SequentialAccessSparseVector(cardinality, sparsity); // sparsity!
      BitSet featureSpace = new BitSet(cardinality);
      int[] indexes = new int[sparsity];
      double[] values = new double[sparsity];
      int j = 0;
      while (j < sparsity) {
        double value = r.nextGaussian();
        int index = r.nextInt(cardinality);
        if (!featureSpace.get(index)) {
          featureSpace.set(index);
          indexes[j] = index;
          values[j++] = value;
          v.set(index, value);
        }
      }
      randomVectorIndices.add(indexes);
      randomVectorValues.add(values);
      randomVectors.add(v);
View Full Code Here

   
    stats = new TimingStatistics();
    for (int l = 0; l < loop; l++) {
      for (int i = 0; i < numVectors; i++) {
        TimingStatistics.Call call = stats.newCall();
        vectors[2][i] = new SequentialAccessSparseVector(randomVectors.get(i));
        call.end();
      }
    }
    printStats(stats, "Create (copy)", "SeqSparseVector");
   
View Full Code Here

TOP

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

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.