mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JAGANADH G <jagana...@gmail.com>
Subject Calling Mahout API from Java help
Date Mon, 07 Jun 2010 10:52:40 GMT
Dear All
I was trying to use Mahout with in my Java Application
The code which I prepared is

=================================
import org.apache.mahout.classifier.bayes.TrainClassifier;
import org.apache.mahout.classifier.bayes.common.BayesParameters;

public class ClassifierTrainer {

    public ClassifierTrainer() {
    // TODO Auto-generated constructor stub
    // trainEr = new trainerMahout(inpDir, outputDir);
    }

import org.apache.mahout.classifier.bayes.TrainClassifier;
import org.apache.mahout.classifier.bayes.common.BayesParameters;

public class ClassifierTrainer {

    public ClassifierTrainer() {
    // TODO Auto-generated constructor stub

    }
    public void trainerMahout(String inpDir, String outputDir) throws
Exception {
    int bayParam = 2;
    BayesParameters bp = new BayesParameters(bayParam);

    TrainClassifier.trainCNaiveBayes(inpDir, outputDir, bp);
       }

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String argv[]) throws Exception {
    // TODO Auto-generated method stub
    ClassifierTrainer clfTr = new ClassifierTrainer();
    String idir = argv[0];
    String outd = argv[1];

    clfTr.trainerMahout(idir, outd);

    }
}
========================================

When I was running the code I am getting the following error
INFO: {gramSize=2}
Exception in thread "main" java.lang.NullPointerException
    at
org.apache.mahout.classifier.bayes.mapreduce.common.BayesTfIdfDriver.runJob(BayesTfIdfDriver.java:113)
    at
org.apache.mahout.classifier.bayes.mapreduce.cbayes.CBayesDriver.runJob(CBayesDriver.java:66)
    at
org.apache.mahout.classifier.bayes.TrainClassifier.trainCNaiveBayes(TrainClassifier.java:56)
    at
com.tsf.nlp.classifier.ClassifierTrainer.trainerMahout(ClassifierTrainer.java:22)
    at
com.tsf.nlp.classifier.ClassifierTrainer.main(ClassifierTrainer.java:38)

I prepared the input documents as per the documentation found the Mahout API
(0.3)

Can any body help regarding the same.

Also if any body can give a link or extensive tutorial on using Mahout
inside a java class
-- 
**********************************
JAGANADH G
http://jaganadhg.freeflux.net/blog

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message