Create a classifier

From NLPWiki

Jump to: navigation, search

There are dummy classes already created for you in the package edu.byu.cs.nlp.classify. These classifiers are setup with a default constructor that takes a list of labeled datums as training data. The constructors are called from edu.byu.cs.nlp.classify.ClassifierFactory.createClassifier. The method createClassifier also has access to the property map created from the command-line arguments and a set of class labels. You are welcome to make use of this information also. The current setup assumes that training is conducted inside the constructor of each classifier, but you are welcome to separate the constructor and training features, if you'd like. The important thing is that, when your classifier is returned from createClassifier, it should already be trained.

With this information in mind, the simplest procedure for creating a classifier is quite simple. For example, assume that you would like to implement the Multi-variate Bernoulli classifier first. You would simply open the file java/src/edu/byu/cs/nlp/classify/NaiveBayesClassifierMVBernoulli.java and fill in the bodies of the constructor and the getLabel methods. If you would like to have access to the command-line arguments also, you could simply add an argument to the constructor of type Properties and then edit createClassifier to pass the variable props to your constructor.

Personal tools