Examples of classify()


Examples of org.apache.mahout.clustering.classify.ClusterClassifier.classify()

    models.add(new Canopy(new DenseVector(2), 1, measure));
    models.add(new Canopy(new DenseVector(2).assign(-1), 2, measure));
    ClusterClassifier classifier = new ClusterClassifier(models, new CanopyClusteringPolicy());
    Vector pdf = classifier.classify(new DenseVector(2));
    assertEquals("[0,0]", "[0.200, 0.600, 0.200]", AbstractCluster.formatVector(pdf, null));
    pdf = classifier.classify(new DenseVector(2).assign(2));
    assertEquals("[2,2]", "[0.493, 0.296, 0.211]", AbstractCluster.formatVector(pdf, null));
  }
 
  @Test
  public void testClusterClassification() {
View Full Code Here

Examples of org.apache.mahout.clustering.classify.ClusterClassifier.classify()

  }
 
  @Test
  public void testClusterClassification() {
    ClusterClassifier classifier = newKlusterClassifier();
    Vector pdf = classifier.classify(new DenseVector(2));
    assertEquals("[0,0]", "[0.200, 0.600, 0.200]", AbstractCluster.formatVector(pdf, null));
    pdf = classifier.classify(new DenseVector(2).assign(2));
    assertEquals("[2,2]", "[0.493, 0.296, 0.211]", AbstractCluster.formatVector(pdf, null));
  }
 
View Full Code Here

Examples of org.apache.mahout.clustering.classify.ClusterClassifier.classify()

  @Test
  public void testClusterClassification() {
    ClusterClassifier classifier = newKlusterClassifier();
    Vector pdf = classifier.classify(new DenseVector(2));
    assertEquals("[0,0]", "[0.200, 0.600, 0.200]", AbstractCluster.formatVector(pdf, null));
    pdf = classifier.classify(new DenseVector(2).assign(2));
    assertEquals("[2,2]", "[0.493, 0.296, 0.211]", AbstractCluster.formatVector(pdf, null));
  }
 
  @Test(expected = UnsupportedOperationException.class)
  public void testMSCanopyClassification() {
View Full Code Here

Examples of org.apache.mahout.clustering.classify.ClusterClassifier.classify()

    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));
  }
 
  @Test
  public void testSoftClusterClassification() {
    ClusterClassifier classifier = newSoftClusterClassifier();
View Full Code Here

Examples of org.apache.mahout.common.Classifier.classify()

          while ((line = fileReader.readLine()) != null) {
 
            Map<String, List<String>> document = Model.generateNGrams(line, gramSize);
            for (Map.Entry<String, List<String>> stringListEntry : document.entrySet()) {
              List<String> strings = stringListEntry.getValue();
              ClassifierResult classifiedLabel = classifier.classify(model,
                  strings.toArray(new String[strings.size()]),
                  defaultCat);
              resultAnalyzer.addInstance(correctLabel, classifiedLabel);
            }
          }
View Full Code Here

Examples of org.apache.mahout.common.Classifier.classify()

      line.append(token).append(' ');
    }
    List<String> doc = Model.generateNGramsWithoutLabel(line.toString(), gramSize) ;
    log.info("Done converting");
    log.info("Classifying document: {}", docPath);
    ClassifierResult category = classifier.classify(model, doc.toArray(new String[doc.size()]), defaultCat);
    log.info("Category for {} is {}", docPath, category);

  }
}
View Full Code Here

Examples of org.apache.mahout.df.node.Node.classify()

    // predict the label for the out-of-bag elements
    if (callback != null) {
      log.debug("Oob error estimation");
      for (int index = 0; index < data.size(); index++) {
        if (sampled[index] == false) {
          int prediction = tree.classify(data.get(index));
          callback.prediction(treeId, index, prediction);
        }
      }
    }
   
View Full Code Here

Examples of org.apache.mahout.df.node.Node.classify()

   
    for (int treeId = 0; treeId < trees.size(); treeId++) {
      Node tree = trees.get(treeId);
     
      for (int index = 0; index < data.size(); index++) {
        int prediction = tree.classify(data.get(index));
        callback.prediction(treeId, index, prediction);
      }
    }
  }
 
View Full Code Here

Examples of org.apache.mahout.df.node.Node.classify()

    // predict the label for the out-of-bag elements
    if (callback != null) {
      log.debug("Oob error estimation");
      for (int index = 0; index < data.size(); index++) {
        if (!sampled[index]) {
          int prediction = tree.classify(data.get(index));
          callback.prediction(treeId, index, prediction);
        }
      }
    }
   
View Full Code Here

Examples of org.apache.mahout.df.node.Node.classify()

    for (int treeId = 0; treeId < trees.size(); treeId++) {
      Node tree = trees.get(treeId);

      for (int index = 0; index < data.size(); index++) {
        int prediction = tree.classify(data.get(index));
        callback.prediction(treeId, index, prediction);
      }
    }
  }
 
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.