Mallet implements a set of classifiers in the cc.mallet.classify package, including decision trees, Naive Bayes, AdaBoost, bagging, boosting, and many others. We'll start with a basic classifier, that is, a Naive Bayes classifier. A classifier is initialized by the ClassifierTrainer class, which returns a classifier when we invoke its train(Instances) method:
ClassifierTrainer classifierTrainer = new NaiveBayesTrainer(); Classifier classifier = classifierTrainer.train(instances);
Now let's see how this classier works and evaluate its performance on a separate dataset.