Examples of VarIntWritable


Examples of org.apache.mahout.math.VarIntWritable

      for (FeatureVectorWithRatingWritable value : values) {
        ratingVector.setQuick(n++, value.getRating());
        UorMColumns.add(value.getFeatureVector());
      }
      Vector uiOrmj = solver.solve(UorMColumns, new SequentialAccessSparseVector(ratingVector), lambda, numFeatures);
      ctx.write(new VarIntWritable(key.getValue()), new FeatureVectorWithRatingWritable(key.getValue(), uiOrmj));
    }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

      columnOfM.setQuick(0, averageRating.getAverage());
      for (int n = 1; n < numFeatures; n++) {
        columnOfM.setQuick(n, random.nextDouble());
      }

      ctx.write(new VarIntWritable(itemIDIndex), new FeatureVectorWithRatingWritable(itemIDIndex, columnOfM));
    }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

  @Test
  public void prefsToRatingsMapper() throws Exception {
    Mapper<LongWritable,Text,VarIntWritable,FeatureVectorWithRatingWritable>.Context ctx =
      EasyMock.createMock(Mapper.Context.class);
    ctx.write(new VarIntWritable(TasteHadoopUtils.idToIndex(456L)),
        new FeatureVectorWithRatingWritable(TasteHadoopUtils.idToIndex(123L), 2.35f));
    EasyMock.replay(ctx);

    new ParallelALSFactorizationJob.PrefsToRatingsMapper().map(null, new Text("123,456,2.35"), ctx);
    EasyMock.verify(ctx);
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

  @Test
  public void prefsToRatingsMapperTranspose() throws Exception {
    Mapper<LongWritable,Text,VarIntWritable,FeatureVectorWithRatingWritable>.Context ctx =
      EasyMock.createMock(Mapper.Context.class);
    ctx.write(new VarIntWritable(TasteHadoopUtils.idToIndex(123L)),
        new FeatureVectorWithRatingWritable(TasteHadoopUtils.idToIndex(456L), 2.35f));
    EasyMock.replay(ctx);

    ParallelALSFactorizationJob.PrefsToRatingsMapper mapper = new ParallelALSFactorizationJob.PrefsToRatingsMapper();
    setField(mapper, "transpose", true);
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

  @Test
  public void initializeMReducer() throws Exception {
    Reducer<VarLongWritable,FloatWritable,VarIntWritable,FeatureVectorWithRatingWritable>.Context ctx =
        EasyMock.createMock(Reducer.Context.class);
    ctx.write(EasyMock.eq(new VarIntWritable(TasteHadoopUtils.idToIndex(123L))), matchInitializedFeatureVector(3.0, 3));
    EasyMock.replay(ctx);

    ParallelALSFactorizationJob.InitializeMReducer reducer = new ParallelALSFactorizationJob.InitializeMReducer();
    setField(reducer, "numFeatures", 3);
    reducer.reduce(new VarLongWritable(123L), Arrays.asList(new FloatWritable(4.0f), new FloatWritable(2.0f)), ctx);
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

    Vector vector = new DenseVector(new double[] { 4.5, 1.2 });
    Reducer<VarIntWritable,FeatureVectorWithRatingWritable,IndexedVarIntWritable,FeatureVectorWithRatingWritable>.Context ctx =
        EasyMock.createMock(Reducer.Context.class);
    ctx.write(new IndexedVarIntWritable(456, 123), new FeatureVectorWithRatingWritable(123, 2.35f, vector));
    EasyMock.replay(ctx);
    new ParallelALSFactorizationJob.JoinFeatureVectorAndRatingsReducer().reduce(new VarIntWritable(123),
        Arrays.asList(new FeatureVectorWithRatingWritable(456, vector),
        new FeatureVectorWithRatingWritable(456, 2.35f)), ctx);
    EasyMock.verify(ctx);
  }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

      elems[n] = result.getElement(n);
    }

    Reducer<IndexedVarIntWritable,FeatureVectorWithRatingWritable,VarIntWritable,FeatureVectorWithRatingWritable>.Context ctx =
        EasyMock.createMock(Reducer.Context.class);
    ctx.write(EasyMock.eq(new VarIntWritable(123)), matchFeatureVector(elems));
    EasyMock.replay(ctx);

    ParallelALSFactorizationJob.SolvingReducer reducer = new ParallelALSFactorizationJob.SolvingReducer();
    setField(reducer, "numFeatures", numFeatures);
    setField(reducer, "lambda", lambda);
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

  @Test
  public void testItemIDIndexMapper() throws Exception {
    Mapper<LongWritable,Text, VarIntWritable, VarLongWritable>.Context context =
      EasyMock.createMock(Mapper.Context.class);

    context.write(new VarIntWritable(TasteHadoopUtils.idToIndex(789L)), new VarLongWritable(789L));
    EasyMock.replay(context);

    new ItemIDIndexMapper().map(new LongWritable(123L), new Text("456,789,5.0"), context);

    EasyMock.verify(context);
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

  @Test
  public void testItemIDIndexReducer() throws Exception {
    Reducer<VarIntWritable, VarLongWritable, VarIntWritable,VarLongWritable>.Context context =
      EasyMock.createMock(Reducer.Context.class);

    context.write(new VarIntWritable(123), new VarLongWritable(45L));
    EasyMock.replay(context);

    new ItemIDIndexReducer().reduce(new VarIntWritable(123), Arrays.asList(new VarLongWritable(67L),
        new VarLongWritable(89L), new VarLongWritable(45L)), context);

    EasyMock.verify(context);
  }
View Full Code Here

Examples of org.apache.mahout.math.VarIntWritable

  @Test
  public void testSimilarityMatrixRowWrapperMapper() throws Exception {
    Mapper<IntWritable,VectorWritable,VarIntWritable,VectorOrPrefWritable>.Context context =
      EasyMock.createMock(Mapper.Context.class);

    context.write(EasyMock.eq(new VarIntWritable(12)), vectorOfVectorOrPrefWritableMatches(MathHelper.elem(34, 0.5),
        MathHelper.elem(56, 0.7)));

    EasyMock.replay(context);

    RandomAccessSparseVector vector = new RandomAccessSparseVector(Integer.MAX_VALUE, 100);
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.