InstanceList testing = null;
if (testingFile.value() != null) {
testing = InstanceList.load(new File(testingFile.value()));
}
HierarchicalLDA hlda = new HierarchicalLDA();
// Set hyperparameters
hlda.setAlpha(alpha.value());
hlda.setGamma(gamma.value());
hlda.setEta(eta.value());
// Display preferences
hlda.setTopicDisplay(showTopicsInterval.value(), topWords.value());
hlda.setProgressDisplay(showProgress.value());
// Initialize random number generator
Randoms random = null;
if (randomSeed.value() == 0) {
random = new Randoms();
}
else {
random = new Randoms(randomSeed.value());
}
// Initialize and start the sampler
hlda.initialize(instances, testing, numLevels.value(), random);
hlda.estimate(numIterations.value());
// Output results
if (stateFile.value() != null) {
hlda.printState(new PrintWriter(stateFile.value()));
}
if (testing != null) {
double empiricalLikelihood = hlda.empiricalLikelihood(1000, testing);
System.out.println("Empirical likelihood: " + empiricalLikelihood);
}
}