Examples of MeanShiftCanopy


Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

    for (VectorWritable v : SAMPLE_DATA) {
      DisplayClustering.plotRectangle(g2, v.get(), dv);
    }
    int i = 0;
    for (Cluster cluster : CLUSTERS.get(CLUSTERS.size() - 1)) {
      MeanShiftCanopy canopy = (MeanShiftCanopy) cluster;
      if (canopy.getBoundPoints().toList().size() >= significance * DisplayClustering.SAMPLE_DATA.size()) {
        g2.setColor(COLORS[Math.min(i++, DisplayClustering.COLORS.length - 1)]);
        int count = 0;
        Vector center = new DenseVector(2);
        for (int vix : canopy.getBoundPoints().toList()) {
          Vector v = SAMPLE_DATA.get(vix).get();
          count++;
          v.addTo(center);
          DisplayClustering.plotRectangle(g2, v, dv);
        }
View Full Code Here

Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

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

Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

  @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

Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

  @Test
  public void testMSCanopyAsFormatStringWithBindings() {
    double[] d = { 1.1, 2.2, 3.3 };
    Vector m = new DenseVector(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, 1:2.200, foo:3.300] r=[]}", formatString);
  }
View Full Code Here

Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

  @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

Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

 
  @Test
  public void testMSCanopyClassification() {
    List<Cluster> models = new ArrayList<Cluster>();
    DistanceMeasure measure = new ManhattanDistanceMeasure();
    models.add(new MeanShiftCanopy(new DenseVector(2).assign(1), 0, measure));
    models.add(new MeanShiftCanopy(new DenseVector(2), 1, measure));
    models.add(new MeanShiftCanopy(new DenseVector(2).assign(-1), 2, measure));
    ClusterClassifier classifier = new ClusterClassifier(models);
    try {
      classifier.classify(new DenseVector(2));
      fail("Expected NotImplementedException");
    } catch (NotImplementedException e) {}
View Full Code Here

Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

    for (VectorWritable v : SAMPLE_DATA) {
      DisplayClustering.plotRectangle(g2, v.get(), dv);
    }
    int i = 0;
    for (Cluster cluster : CLUSTERS.get(CLUSTERS.size() - 1)) {
      MeanShiftCanopy canopy = (MeanShiftCanopy) cluster;
      if (canopy.getMass() >= significance
          * DisplayClustering.SAMPLE_DATA.size()) {
        g2.setColor(COLORS[Math.min(i++, DisplayClustering.COLORS.length - 1)]);
        int count = 0;
        Vector center = new DenseVector(2);
        for (int vix : canopy.getBoundPoints().toList()) {
          Vector v = SAMPLE_DATA.get(vix).get();
          count++;
          center.assign(v, Functions.PLUS);
          DisplayClustering.plotRectangle(g2, v, dv);
        }
View Full Code Here

Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

 
  @Test(expected = UnsupportedOperationException.class)
  public void testMSCanopyClassification() {
    List<Cluster> models = Lists.newArrayList();
    DistanceMeasure measure = new ManhattanDistanceMeasure();
    models.add(new MeanShiftCanopy(new DenseVector(2).assign(1), 0, measure));
    models.add(new MeanShiftCanopy(new DenseVector(2), 1, measure));
    models.add(new MeanShiftCanopy(new DenseVector(2).assign(-1), 2, measure));
    ClusterClassifier classifier = new ClusterClassifier(models, new MeanShiftClusteringPolicy());
    classifier.classify(new DenseVector(2));
  }
View Full Code Here

Examples of org.apache.mahout.clustering.meanshift.MeanShiftCanopy

      Vector point = new DenseVector(doubles.size());
      int index = 0;
      for (Double d : doubles) {
        point.set(index++, d);
      }
      cw.setValue(new MeanShiftCanopy(point, nextCanopyId++, new EuclideanDistanceMeasure()));
      context.write(new Text(), cw);
    }
  }
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.