Package org.apache.mahout.math

Examples of org.apache.mahout.math.VectorWritable


    generateSamples(100, 0, 0, 1);
    generateSamples(100, 2, 0, 1);
    generateSamples(100, 0, 2, 1);
    generateSamples(100, 2, 2, 1);
    DirichletState<VectorWritable> state = new DirichletState<VectorWritable>(new SampledNormalDistribution(
        new VectorWritable(new DenseVector(2))), 20, 1.0);
   
    List<Model<VectorWritable>[]> models = new ArrayList<Model<VectorWritable>[]>();
   
    for (int iteration = 0; iteration < 10; iteration++) {
      DirichletMapper mapper = new DirichletMapper();
View Full Code Here


   */
  public void testMapper() throws Exception {
    LDAState state = generateRandomState(100,NUM_TOPICS);
    LDAMapper mapper = new LDAMapper();
    mapper.configure(state);
    VectorWritable vw = new VectorWritable();
    for(int i = 0; i < NUM_TESTS; ++i) {
      RandomAccessSparseVector v = generateRandomDoc(100,0.3);
      int myNumWords = numNonZero(v);
      LDAMapper.Context mock = createMock(LDAMapper.Context.class);

      mock.write(isA(IntPairWritable.class),isA(DoubleWritable.class));
      expectLastCall().times(myNumWords * NUM_TOPICS + NUM_TOPICS + 1);
      replay(mock);
      vw.set(v);
      mapper.map(new Text("tstMapper"), vw, mock);
      verify(mock);
    }
  }
View Full Code Here

  }
 
  @Override
  public void readFields(DataInput in) throws IOException {
    this.probability = in.readDouble();
    VectorWritable temp = new VectorWritable();
    temp.readFields(in);
    this.pointTotal = temp.get();
  }
View Full Code Here

    return buf.toString();
  }
 
  @Override
  public void readFields(DataInput in) throws IOException {
    VectorWritable temp = new VectorWritable();
    temp.readFields(in);
    this.mean = temp.get();
    this.stdDev = in.readDouble();
    this.s0 = in.readInt();
    temp.readFields(in);
    this.s1 = temp.get();
    temp.readFields(in);
    this.s2 = temp.get();
  }
View Full Code Here

    return buf.toString();
  }
 
  @Override
  public void readFields(DataInput in) throws IOException {
    VectorWritable temp = new VectorWritable();
    temp.readFields(in);
    this.mean = temp.get();
    temp.readFields(in);
    this.stdDev = temp.get();
    this.s0 = in.readInt();
    temp.readFields(in);
    this.s1 = temp.get();
    temp.readFields(in);
    this.s2 = temp.get();
  }
View Full Code Here

    return Math.exp(-L1Model.measure.distance(x.get(), coefficients));
  }
 
  @Override
  public void readFields(DataInput in) throws IOException {
    VectorWritable temp = new VectorWritable();
    temp.readFields(in);
    coefficients = temp.get();
  }
View Full Code Here

 
  @Override
  public void readFields(DataInput in) throws IOException {
    this.setId(in.readInt());
    converged = in.readBoolean();
    VectorWritable temp = new VectorWritable();
    temp.readFields(in);
    this.setCenter(new RandomAccessSparseVector(temp.get()));
    this.pointProbSum = 0;
    this.weightedPointTotal = getCenter().like();
  }
View Full Code Here

public class VectorDumper extends MeanShiftOutDumper {

  @Override
  protected void dump(SequenceFile.Reader reader, PrintWriter writer) throws IOException{
    VectorWritable value = new VectorWritable();
    Text key = new Text();
    while(reader.next(key, value)){
      if(key != null && value != null){
        writer.println(key.toString());
      }
View Full Code Here

        if(vectorPath.getName().startsWith("part-")){
          conf.setClass("mapred.output.compression.codec", GzipCodec.class,
              CompressionCodec.class);
          FileSystem fs = vectorPath.getFileSystem(conf);
          SequenceFile.Reader reader = new SequenceFile.Reader( fs, vectorPath, conf);
          VectorWritable v2 = new VectorWritable();
          Text vkey = new Text();
          while(reader.next(vkey, v2)){
            if(v2 != null){
              if(measure.distance(v1, v2.get()) < t){
                output.collect(key, new Text(v2.get().getName()));
              }
            }
          }
        }
      }
View Full Code Here

      }
      return new FuzzyKMeansClusterer().computePi(clusters, distances);
    } else {
      int i = 0;
      for (Model<VectorWritable> model : models) {
        pdfs.set(i++, model.pdf(new VectorWritable(instance)));
      }
      return pdfs.assign(new TimesFunction(), 1.0 / pdfs.zSum());
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.math.VectorWritable

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.