The test that you are reading is testing an entire command line interface.
 If you look inside that code, you can probably see something simpler.

Also, you can take a look at the SGD models which are much easier to use on
a small scale.  There the pertinent classes are

     AdaptiveLogisticRegression or CrossFoldLearner

     FeatureValueEncoder and sub-classes

     ModelSerializer

There are programs in examples that demonstrate the API.

In general, while there are sequential versions of the Bayes classifiers,
they are oriented around command line use at large
scale and have not much been used for production classification yet.  The
SGD classifiers are oriented around API integration
and are currently being used at medium scale.


On Mon, Sep 27, 2010 at 9:10 PM, First Qaxy <[email protected]> wrote:

> 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