Hi all,
I'm trying to write code to load and classify new data based on the existing 
model.I've written some code in WEKA that does that and trying to port it to 
Mahout.

      Classifier cl = (Classifier) SerializationHelper.read(modelFileName);     
 for (int i = 0; i < unlabeled.numInstances(); i++) {

                   Instance curr = unlabeled.instance(i);
           // predict output
                   double pred = cl.classifyInstance(curr);     }
What would be the equivalent in Mahout? Is there a similar interface I can use?
Currently looking at a TestClassifier class that I believe tries to load a 
model:
Map<String, Path> modelPaths = new HashMap<String, Path>();    String 
modelBasePath = (String) cmdLine.getValue(pathOpt);    
modelPaths.put("sigma_j", new Path(modelBasePath + 
"/trainer-weights/Sigma_j/part-*"));    modelPaths.put("sigma_k", new 
Path(modelBasePath + "/trainer-weights/Sigma_k/part-*"));    
modelPaths.put("sigma_kSigma_j", new Path(modelBasePath + 
"/trainer-weights/Sigma_kSigma_j/part-*"));    
modelPaths.put("thetaNormalizer", new Path(modelBasePath + 
"/trainer-thetaNormalizer/part-*"));    modelPaths.put("weight", new 
Path(modelBasePath + "/trainer-tfIdf/trainer-tfIdf/part-*"));
    FileSystem fs = FileSystem.get(new Path(modelBasePath).toUri(), conf);
    log.info("Loading model from: {}", modelPaths);
    Model model;    Classifier classifier;
    String classifierType = (String) cmdLine.getValue(typeOpt);
    if (classifierType.equalsIgnoreCase("bayes")) {      log.info("Testing 
Bayes Classifier");      model = new BayesModel();      classifier = new 
BayesClassifier();    } else if (classifierType.equalsIgnoreCase("cbayes")) {   
   log.info("Testing Complementary Bayes Classifier");      model = new 
CBayesModel();      classifier = new CBayesClassifier();    } else {      throw 
new IllegalArgumentException("Unrecognized classifier type: " + 
classifierType);    }
    SequenceFileModelReader.loadModel(model, fs, modelPaths, conf);
A lot of the preparations are specific to these 2 models (what 
is modelPaths?!). Is there any abstraction available that would do that for me? 
Thanks.
/qf

Reply via email to