if (lmp.getTargetCategories().size() <=2 ) {
collector = new Auc();
}
OnlineSummarizer slh = new OnlineSummarizer();
ConfusionMatrix cm = new ConfusionMatrix(lmp.getTargetCategories(), defaultCategory);
State<Wrapper, CrossFoldLearner> best = lr.getBest();
if (best == null) {
output.printf("%s\n",
"AdaptiveLogisticRegression has not be trained probably.");
return;
}
CrossFoldLearner learner = best.getPayload().getLearner();
BufferedReader in = TrainLogistic.open(inputFile);
String line = in.readLine();
csv.firstLine(line);
line = in.readLine();
if (showScores) {
output.printf(Locale.ENGLISH, "\"%s\", \"%s\", \"%s\", \"%s\"\n",
"target", "model-output", "log-likelihood", "average-likelihood");
}
while (line != null) {
Vector v = new SequentialAccessSparseVector(lmp.getNumFeatures());
//TODO: How to avoid extra target values not shown in the training process.
int target = csv.processLine(line, v);
double likelihood = learner.logLikelihood(target, v);
double score = learner.classifyFull(v).maxValue();
slh.add(likelihood);
cm.addInstance(csv.getTargetString(line), csv.getTargetLabel(target));
if (showScores) {
output.printf(Locale.ENGLISH, "%8d, %.12f, %.13f, %.13f\n", target,
score, learner.logLikelihood(target, v), slh.getMean());
}
if (collector != null) {
collector.add(target, score);
}
line = in.readLine();
}
output.printf(Locale.ENGLISH,"\nLog-likelihood:");
output.printf(Locale.ENGLISH, "Min=%.2f, Max=%.2f, Mean=%.2f, Median=%.2f\n",
slh.getMin(), slh.getMax(), slh.getMean(), slh.getMedian());
if (collector != null) {
output.printf(Locale.ENGLISH, "\nAUC = %.2f\n", collector.auc());
}