Package org.apache.mahout.clustering

Examples of org.apache.mahout.clustering.ClusterObservations


      if (distance < nearestDistance || nearestCluster == null) {
        nearestCluster = cluster;
        nearestDistance = distance;
      }
    }
    context.write(new Text(nearestCluster.getIdentifier()), new ClusterObservations(1, point, point.times(point)));
  }
View Full Code Here


    }

    for (int i = 0; i < clusters.size(); i++) {
      SoftCluster cluster = clusters.get(i);
      Text key = new Text(cluster.getIdentifier());
      ClusterObservations value =
          new ClusterObservations(computeProbWeight(clusterDistanceList.get(i), clusterDistanceList),
                                  point,
                                  point.times(point));
      context.write(key, value);
    }
  }
View Full Code Here

  @Test
  public void testClusterObservationsSerialization() throws Exception {
    double[] data = { 1.1, 2.2, 3.3 };
    Vector vector = new DenseVector(data);
    ClusterObservations reference = new ClusterObservations(1, 2.0, vector, vector);
    DataOutputBuffer out = new DataOutputBuffer();
    reference.write(out);
    ClusterObservations info = new ClusterObservations();
    DataInputBuffer in = new DataInputBuffer();
    in.reset(out.getData(), out.getLength());
    info.readFields(in);
    assertEquals("probability", reference.getS0(), info.getS0(), EPSILON);
    assertEquals("point total", reference.getS1(), info.getS1());
    assertEquals("combiner", reference.getCombinerState(), info.getCombinerState());
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.clustering.ClusterObservations

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.