Skip to content

Commit

Permalink
Merge pull request #30 from attapol/master
Browse files Browse the repository at this point in the history
Also compute the most-frequent-tag accuracy baseline when printing out
  • Loading branch information
mimno committed Jun 17, 2015
2 parents 3607d79 + 4b972eb commit 442de6b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cc/mallet/classify/evaluate/ConfusionMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ public String toString () {
maxLabelNameLength = len;
}

sb.append ("Confusion Matrix, row=true, column=predicted accuracy="+trial.getAccuracy()+"\n");
double[] distribution = new double[values.length];
for (int i = 0; i < distribution.length; i++)
distribution[i] = MatrixOps.sum(values[i]);
double baselineAccuracy = MatrixOps.max(distribution) / MatrixOps.sum(distribution);
sb.append ("Confusion Matrix, row=true, column=predicted accuracy="+trial.getAccuracy()+" most-frequent-tag baseline="+baselineAccuracy+"\n");
for (int i = 0; i < maxLabelNameLength-5+4; i++) sb.append (' ');
sb.append ("label");
for (int c2 = 0; c2 < Math.min(10,numClasses); c2++) sb.append (" "+c2);
Expand Down

0 comments on commit 442de6b

Please sign in to comment.