Examples of BayesFeatureMapper


Examples of org.apache.mahout.classifier.bayes.common.BayesFeatureMapper

import java.util.Map;

public class BayesFeatureMapperTest extends TestCase {

  public void test() throws Exception {
    BayesFeatureMapper mapper = new BayesFeatureMapper();
    JobConf conf = new JobConf();
    conf.set("io.serializations",
            "org.apache.hadoop.io.serializer.JavaSerialization,org.apache.hadoop.io.serializer.WritableSerialization");
    DefaultStringifier<Integer> intStringifier = new DefaultStringifier<Integer>(conf, Integer.class);
    conf.set("bayes.gramSize", intStringifier.toString(3));
    mapper.configure(conf);

    DummyOutputCollector<Text, DoubleWritable> output = new DummyOutputCollector<Text, DoubleWritable>();
    mapper.map(new Text("foo"), new Text("big brown shoe"), output, null);
    Map<String, List<DoubleWritable>> outMap = output.getData();
    System.out.println("Map: " + outMap);
    assertNotNull("outMap is null and it shouldn't be", outMap);
    //TODO: How about not such a lame test here?
    for (Map.Entry<String, List<DoubleWritable>> entry : outMap.entrySet()) {
View Full Code Here

Examples of org.apache.mahout.classifier.bayes.mapreduce.common.BayesFeatureMapper

import org.apache.mahout.common.StringTuple;

public class BayesFeatureMapperTest extends MahoutTestCase {
 
  public void test() throws Exception {
    BayesFeatureMapper mapper = new BayesFeatureMapper();
    JobConf conf = new JobConf();
    conf.set("io.serializations",
      "org.apache.hadoop.io.serializer.JavaSerialization,"
          + "org.apache.hadoop.io.serializer.WritableSerialization");
    conf.set("bayes.parameters", new BayesParameters(3).toString());
    mapper.configure(conf);
   
    DummyOutputCollector<StringTuple,DoubleWritable> output = new DummyOutputCollector<StringTuple,DoubleWritable>();
    mapper.map(new Text("foo"), new Text("big brown shoe"), output,
      Reporter.NULL);
    Map<String,List<DoubleWritable>> outMap = output.getData();
    System.out.println("Map: " + outMap);
    assertNotNull("outMap is null and it shouldn't be", outMap);
    // TODO: How about not such a lame test here?
View Full Code Here

Examples of org.apache.mahout.classifier.bayes.mapreduce.common.BayesFeatureMapper

public final class BayesFeatureMapperTest extends MahoutTestCase {

  @Test
  public void test() throws Exception {
    BayesFeatureMapper mapper = new BayesFeatureMapper();
    JobConf conf = new JobConf();
    conf.set("io.serializations",
      "org.apache.hadoop.io.serializer.JavaSerialization,"
          + "org.apache.hadoop.io.serializer.WritableSerialization");
    BayesParameters bayesParams = new BayesParameters();
    bayesParams.setGramSize(3);
    conf.set("bayes.parameters", bayesParams.toString());
    mapper.configure(conf);
   
    DummyOutputCollector<StringTuple,DoubleWritable> output = new DummyOutputCollector<StringTuple,DoubleWritable>();
    mapper.map(new Text("foo"), new Text("big brown shoe"), output,
      Reporter.NULL);
    Map<StringTuple, List<DoubleWritable>> outMap = output.getData();
    assertNotNull("outMap is null and it shouldn't be", outMap);
    // TODO: How about not such a lame test here?
    for (Entry<StringTuple, List<DoubleWritable>> entry : outMap.entrySet()) {
View Full Code Here

Examples of org.apache.mahout.classifier.bayes.mapreduce.common.BayesFeatureMapper

public final class BayesFeatureMapReduceTest extends MahoutTestCase {

  private static DummyOutputCollector<StringTuple,DoubleWritable> runMapReduce(BayesParameters bp) throws IOException {
   
    BayesFeatureMapper mapper = new BayesFeatureMapper();
    JobConf conf = new JobConf();
    conf.set("io.serializations",
      "org.apache.hadoop.io.serializer.JavaSerialization,"
          + "org.apache.hadoop.io.serializer.WritableSerialization");
   
    conf.set("bayes.parameters", bp.toString());
    mapper.configure(conf);
   
    DummyOutputCollector<StringTuple,DoubleWritable> mapperOutput = new DummyOutputCollector<StringTuple,DoubleWritable>();
   
    mapper.map(new Text("foo"), new Text("big brown shoe"), mapperOutput, Reporter.NULL);
    mapper.map(new Text("foo"), new Text("cool chuck taylors"), mapperOutput, Reporter.NULL);
   
    mapper.map(new Text("bar"), new Text("big big dog"), mapperOutput, Reporter.NULL);
    mapper.map(new Text("bar"), new Text("cool rain"), mapperOutput, Reporter.NULL);
  
    mapper.map(new Text("baz"), new Text("red giant"), mapperOutput, Reporter.NULL);
    mapper.map(new Text("baz"), new Text("white dwarf"), mapperOutput, Reporter.NULL);
    mapper.map(new Text("baz"), new Text("cool black hole"), mapperOutput, Reporter.NULL);
   
    BayesFeatureReducer reducer = new BayesFeatureReducer();
    reducer.configure(conf);
   
    DummyOutputCollector<StringTuple,DoubleWritable> reducerOutput = new DummyOutputCollector<StringTuple,DoubleWritable>();
View Full Code Here

Examples of org.apache.mahout.classifier.bayes.mapreduce.common.BayesFeatureMapper

public final class BayesFeatureMapReduceTest extends MahoutTestCase {

  private static DummyOutputCollector<StringTuple,DoubleWritable> runMapReduce(BayesParameters bp) throws IOException {
   
    BayesFeatureMapper mapper = new BayesFeatureMapper();
    JobConf conf = new JobConf();
    conf.set("io.serializations",
      "org.apache.hadoop.io.serializer.JavaSerialization,"
          + "org.apache.hadoop.io.serializer.WritableSerialization");
   
    conf.set("bayes.parameters", bp.toString());
    mapper.configure(conf);
   
    DummyOutputCollector<StringTuple,DoubleWritable> mapperOutput = new DummyOutputCollector<StringTuple,DoubleWritable>();
   
    mapper.map(new Text("foo"), new Text("big brown shoe"), mapperOutput, Reporter.NULL);
    mapper.map(new Text("foo"), new Text("cool chuck taylors"), mapperOutput, Reporter.NULL);
   
    mapper.map(new Text("bar"), new Text("big big dog"), mapperOutput, Reporter.NULL);
    mapper.map(new Text("bar"), new Text("cool rain"), mapperOutput, Reporter.NULL);
  
    mapper.map(new Text("baz"), new Text("red giant"), mapperOutput, Reporter.NULL);
    mapper.map(new Text("baz"), new Text("white dwarf"), mapperOutput, Reporter.NULL);
    mapper.map(new Text("baz"), new Text("cool black hole"), mapperOutput, Reporter.NULL);
   
    BayesFeatureReducer reducer = new BayesFeatureReducer();
    reducer.configure(conf);
   
    DummyOutputCollector<StringTuple,DoubleWritable> reducerOutput = new DummyOutputCollector<StringTuple,DoubleWritable>();
View Full Code Here

Examples of org.apache.mahout.classifier.bayes.mapreduce.common.BayesFeatureMapper

public final class BayesFeatureMapperTest extends MahoutTestCase {

  @Test
  public void test() throws Exception {
    BayesFeatureMapper mapper = new BayesFeatureMapper();
    JobConf conf = new JobConf();
    conf.set("io.serializations",
      "org.apache.hadoop.io.serializer.JavaSerialization,"
          + "org.apache.hadoop.io.serializer.WritableSerialization");
    conf.set("bayes.parameters", new BayesParameters(3).toString());
    mapper.configure(conf);
   
    DummyOutputCollector<StringTuple,DoubleWritable> output = new DummyOutputCollector<StringTuple,DoubleWritable>();
    mapper.map(new Text("foo"), new Text("big brown shoe"), output,
      Reporter.NULL);
    Map<StringTuple, List<DoubleWritable>> outMap = output.getData();
    assertNotNull("outMap is null and it shouldn't be", outMap);
    // TODO: How about not such a lame test here?
    for (Entry<StringTuple, List<DoubleWritable>> entry : outMap.entrySet()) {
View Full Code Here

Examples of org.apache.mahout.classifier.bayes.mapreduce.common.BayesFeatureMapper

import java.util.Map;

public class BayesFeatureMapperTest extends TestCase {

  public void test() throws Exception {
    BayesFeatureMapper mapper = new BayesFeatureMapper();
    JobConf conf = new JobConf();
    conf.set("io.serializations",
        "org.apache.hadoop.io.serializer.JavaSerialization,org.apache.hadoop.io.serializer.WritableSerialization");
    conf.set("bayes.parameters", new BayesParameters(3).toString());
    mapper.configure(conf);

    DummyOutputCollector<StringTuple, DoubleWritable> output = new DummyOutputCollector<StringTuple, DoubleWritable>();
    mapper.map(new Text("foo"), new Text("big brown shoe"), output, Reporter.NULL);
    Map<String, List<DoubleWritable>> outMap = output.getData();
    System.out.println("Map: " + outMap);
    assertNotNull("outMap is null and it shouldn't be", outMap);
    //TODO: How about not such a lame test here?
    for (Map.Entry<String, List<DoubleWritable>> entry : outMap.entrySet()) {
View Full Code Here

Examples of org.apache.mahout.classifier.bayes.mapreduce.common.BayesFeatureMapper

public final class BayesFeatureMapperTest extends MahoutTestCase {

  @Test
  public void test() throws Exception {
    BayesFeatureMapper mapper = new BayesFeatureMapper();
    JobConf conf = new JobConf();
    conf.set("io.serializations",
      "org.apache.hadoop.io.serializer.JavaSerialization,"
          + "org.apache.hadoop.io.serializer.WritableSerialization");
    BayesParameters bayesParams = new BayesParameters();
    bayesParams.setGramSize(3);
    conf.set("bayes.parameters", bayesParams.toString());
    mapper.configure(conf);
   
    DummyOutputCollector<StringTuple,DoubleWritable> output = new DummyOutputCollector<StringTuple,DoubleWritable>();
    mapper.map(new Text("foo"), new Text("big brown shoe"), output,
      Reporter.NULL);
    Map<StringTuple, List<DoubleWritable>> outMap = output.getData();
    assertNotNull("outMap is null and it shouldn't be", outMap);
    // TODO: How about not such a lame test here?
    for (Entry<StringTuple, List<DoubleWritable>> entry : outMap.entrySet()) {
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.