}
@Override
public void configure(JobConf job) {
try {
BayesParameters params = new BayesParameters(job.get("bayes.parameters", ""));
log.info("Bayes Parameter {}", params.print());
log.info("{}", params.print());
Algorithm algorithm;
Datastore datastore;
if ("hdfs".equals(params.get("dataSource"))) {
if ("bayes".equalsIgnoreCase(params.get("classifierType"))) {
log.info("Testing Bayes Classifier");
algorithm = new BayesAlgorithm();
datastore = new InMemoryBayesDatastore(params);
} else if ("cbayes".equalsIgnoreCase(params.get("classifierType"))) {
log.info("Testing Complementary Bayes Classifier");
algorithm = new CBayesAlgorithm();
datastore = new InMemoryBayesDatastore(params);
} else {
throw new IllegalArgumentException("Unrecognized classifier type: " + params.get("classifierType"));
}
} else {
throw new IllegalArgumentException("Unrecognized dataSource type: " + params.get("dataSource"));
}
classifier = new ClassifierContext(algorithm, datastore);
classifier.initialize();
defaultCategory = params.get("defaultCat");
gramSize = params.getGramSize();
} catch (IOException ex) {
log.warn(ex.toString(), ex);
} catch (InvalidDatastoreException e) {
log.error(e.toString(), e);
}