Package org.apache.mahout.classifier.bayes.common

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


  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();
    algorithm = new BayesAlgorithm();
    store = new InMemoryBayesDatastore(new BayesParameters(1));
    // String[] labels = new String[]{"a", "b", "c", "d", "e"};
    // long[] labelCounts = new long[]{6, 20, 60, 100, 200};
    // String[] features = new String[]{"aa", "bb", "cc", "dd", "ee"};
    store.setSigmaJSigmaK(100.0);
   
View Full Code Here


  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();
    algorithm = new CBayesAlgorithm();
    store = new InMemoryBayesDatastore(new BayesParameters(1));
    // String[] labels = new String[]{"a", "b", "c", "d", "e"};
    // long[] labelCounts = new long[]{6, 20, 60, 100, 200};
    // String[] features = new String[]{"aa", "bb", "cc", "dd", "ee"};
    store.setSigmaJSigmaK(500.0);
   
View Full Code Here

    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);
View Full Code Here

      }

      String input = cmdLine.getValue(inputOpt).toString();
      String output = cmdLine.getValue(outputOpt).toString();

      job.runJob(input, output, new BayesParameters(1));
    } catch (OptionException e) {
      log.error(e.getMessage());
      CommandLineUtil.printHelp(group);
    }
  }
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    algorithm = new BayesAlgorithm();
    store = new InMemoryBayesDatastore(new BayesParameters(1));
    // String[] labels = new String[]{"a", "b", "c", "d", "e"};
    // long[] labelCounts = new long[]{6, 20, 60, 100, 200};
    // String[] features = new String[]{"aa", "bb", "cc", "dd", "ee"};
    store.setSigma_jSigma_k(100.0);
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    algorithm = new CBayesAlgorithm();
    store = new InMemoryBayesDatastore(new BayesParameters(1));
    //String[] labels = new String[]{"a", "b", "c", "d", "e"};
    //long[] labelCounts = new long[]{6, 20, 60, 100, 200};
    //String[] features = new String[]{"aa", "bb", "cc", "dd", "ee"};
    store.setSigma_jSigma_k(500.0);
View Full Code Here

  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();
View Full Code Here

      }

      String classifierType = (String) cmdLine.getValue(typeOpt);
      String dataSourceType = (String) cmdLine.getValue(dataSourceOpt);

      BayesParameters params = new BayesParameters(Integer
          .parseInt((String) cmdLine.getValue(gramSizeOpt)));

      String alpha_i = "1.0";
      if (cmdLine.hasOption(alphaOpt)) {
        alpha_i = (String) cmdLine.getValue(alphaOpt);
      }

      params.set("alpha_i", alpha_i);

      if (dataSourceType.equals("hbase"))
        params.set("dataSource", "hbase");
      else
        params.set("dataSource", "hdfs");

      if (classifierType.equalsIgnoreCase("bayes")) {
        log.info("Training Bayes Classifier");
        trainNaiveBayes((String) cmdLine.getValue(inputDirOpt),
            (String) cmdLine.getValue(outputOpt), params);
View Full Code Here

      int gramSize = 1;
      if (cmdLine.hasOption(gramSizeOpt)) {
        gramSize = Integer.parseInt((String) cmdLine.getValue(gramSizeOpt));

      }
      BayesParameters params = new BayesParameters(gramSize);

      String modelBasePath = (String) cmdLine.getValue(pathOpt);

      String classifierType = (String) cmdLine.getValue(typeOpt);
      String dataSource = (String) cmdLine.getValue(dataSourceOpt);

      String defaultCat = "unknown";
      if (cmdLine.hasOption(defaultCatOpt)) {
        defaultCat = (String) cmdLine.getValue(defaultCatOpt);
      }

      String encoding = "UTF-8";
      if (cmdLine.hasOption(encodingOpt)) {
        encoding = (String) cmdLine.getValue(encodingOpt);
      }

      String alpha_i = "1.0";
      if (cmdLine.hasOption(alphaOpt)) {
        alpha_i = (String) cmdLine.getValue(alphaOpt);
      }

      boolean verbose = cmdLine.hasOption(verboseOutputOpt);

      String testDirPath = (String) cmdLine.getValue(dirOpt);

      String classificationMethod = (String) cmdLine.getValue(methodOpt);

      params.set("verbose", Boolean.toString(verbose));
      params.set("basePath", modelBasePath);
      params.set("classifierType", classifierType);
      params.set("dataSource", dataSource);
      params.set("defaultCat", defaultCat);
      params.set("encoding", encoding);
      params.set("alpha_i", alpha_i);
      params.set("testDirPath", testDirPath);

      if (classificationMethod.equalsIgnoreCase("sequential"))
        classifySequential(params);
      else if (classificationMethod.equalsIgnoreCase("mapreduce"))
        classifyParallel(params);
View Full Code Here

    if (cmdLine.hasOption(gramSizeOpt)) {
      gramSize = Integer.parseInt((String) cmdLine.getValue(gramSizeOpt));

    }

    BayesParameters params = new BayesParameters(gramSize);

    String modelBasePath = (String) cmdLine.getValue(pathOpt);

    log.info("Loading model from: {}", params.print());

    Algorithm algorithm;
    Datastore datastore;

    String classifierType = (String) cmdLine.getValue(typeOpt);
View Full Code Here

TOP

Related Classes of org.apache.mahout.classifier.bayes.common.BayesParameters

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.