Package org.apache.mahout.math

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


    }

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


  }

  @Test
  public void testCanopyAsFormatStringSparse() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new Canopy(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertEquals("C-123{n=0 c=[0:1.100, 2:3.300] r=[]}", formatString);
  }
View Full Code Here

  }

  @Test
  public void testCanopyAsFormatStringSparseWithBindings() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new Canopy(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertEquals("C-123{n=0 c=[0:1.100, 2:3.300] r=[]}", formatString);
  }
View Full Code Here

  }

  @Test
  public void testClusterAsFormatStringSparse() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new org.apache.mahout.clustering.kmeans.Cluster(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertEquals("CL-123{n=0 c=[0:1.100, 2:3.300] r=[]}", formatString);
  }
View Full Code Here

  }

  @Test
  public void testClusterAsFormatStringSparseWithBindings() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new org.apache.mahout.clustering.kmeans.Cluster(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertEquals("CL-123{n=0 c=[0:1.100, 2:3.300] r=[]}", formatString);
  }
View Full Code Here

  }

  @Test
  public void testMSCanopyAsFormatStringSparse() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new MeanShiftCanopy(m, 123, measure);
    String formatString = cluster.asFormatString(null);
    assertEquals("MSC-123{n=0 c=[0:1.100, 2:3.300] r=[]}", formatString);
  }
View Full Code Here

  }

  @Test
  public void testMSCanopyAsFormatStringSparseWithBindings() {
    double[] d = { 1.1, 0.0, 3.3 };
    Vector m = new SequentialAccessSparseVector(3);
    m.assign(d);
    Cluster cluster = new MeanShiftCanopy(m, 123, measure);
    String[] bindings = { "fee", null, "foo" };
    String formatString = cluster.asFormatString(bindings);
    assertEquals("MSC-123{n=0 c=[fee:1.100, foo:3.300] r=[]}", formatString);
  }
View Full Code Here

    }

    @Override
    protected void map(IntWritable userOrItemID, VectorWritable ratingsWritable, Context ctx)
        throws IOException, InterruptedException {
      Vector ratings = new SequentialAccessSparseVector(ratingsWritable.get());
      List<Vector> featureVectors = Lists.newArrayList();
      Iterator<Vector.Element> interactions = ratings.iterateNonZero();
      while (interactions.hasNext()) {
        int index = interactions.next().index();
        featureVectors.add(UorM.get(index));
      }
View Full Code Here

    }

    @Override
    protected void map(IntWritable userOrItemID, VectorWritable ratingsWritable, Context ctx)
        throws IOException, InterruptedException {
      Vector ratings = new SequentialAccessSparseVector(ratingsWritable.get());

      Vector uiOrmj = solver.solve(ratings);

      ctx.write(userOrItemID, new VectorWritable(uiOrmj));
    }
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);
    initializeThreadPool();
  }
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.