mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From First Qaxy <>
Subject Loading and run classification/regression on a model.
Date Tue, 28 Sep 2010 04:10:24 GMT
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);      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);"Loading model from: {}", modelPaths);
    Model model;    Classifier classifier;
    String classifierType = (String) cmdLine.getValue(typeOpt);
    if (classifierType.equalsIgnoreCase("bayes")) {"Testing Bayes Classifier");  
   model = new BayesModel();      classifier = new BayesClassifier();    } else if
(classifierType.equalsIgnoreCase("cbayes")) {"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.

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