Package org.apache.mahout.classifier.naivebayes

Examples of org.apache.mahout.classifier.naivebayes.NaiveBayesModel


    HadoopUtil.cacheFiles(getTempPath(THETAS), getConf());
   
    // Validate our model and then write it out to the official output
    getConf().setFloat(ThetaMapper.ALPHA_I, alphaI);
    getConf().setBoolean(NaiveBayesModel.COMPLEMENTARY_MODEL, trainComplementary);
    NaiveBayesModel naiveBayesModel = BayesUtils.readModelFromDir(getTempPath(), getConf());
    naiveBayesModel.validate();
    naiveBayesModel.serialize(getOutputPath(), getConf());

    return 0;
  }
View Full Code Here


  }

  private void runSequential() throws IOException {
    boolean complementary = hasOption("testComplementary");
    FileSystem fs = FileSystem.get(getConf());
    NaiveBayesModel model = NaiveBayesModel.materialize(new Path(getOption("model")), getConf());
   
    // Ensure that if we are testing in complementary mode, the model has been
    // trained complementary. a complementarty model will work for standard classification
    // a standard model will not work for complementary classification
    if (complementary){
        Preconditions.checkArgument((model.isComplemtary() == complementary),
            "Complementary mode in model is different from test mode");
    }
   
    AbstractNaiveBayesClassifier classifier;
    if (complementary) {
View Full Code Here

  @Override
  protected void setup(Context context) throws IOException, InterruptedException {
    super.setup(context);
    Configuration conf = context.getConfiguration();
    Path modelPath = HadoopUtil.getSingleCachedFile(conf);
    NaiveBayesModel model = NaiveBayesModel.materialize(modelPath, conf);
    boolean isComplementary = Boolean.parseBoolean(conf.get(TestNaiveBayesDriver.COMPLEMENTARY));
   
    // ensure that if we are testing in complementary mode, the model has been
    // trained complementary. a complementarty model will work for standard classification
    // a standard model will not work for complementary classification
    if (isComplementary) {
      Preconditions.checkArgument((model.isComplemtary() == isComplementary),
          "Complementary mode in model is different than test mode");
    }
   
    if (isComplementary) {
      classifier = new ComplementaryNaiveBayesClassifier(model);
View Full Code Here

TOP

Related Classes of org.apache.mahout.classifier.naivebayes.NaiveBayesModel

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.