From 4b972ebad99bdf3da0560799d1048a2752d3237b Mon Sep 17 00:00:00 2001 From: Te Thamrong Date: Wed, 17 Jun 2015 13:59:35 +0200 Subject: [PATCH] Also compute the most-frequent-tag accuracy baseline when printing out --- src/cc/mallet/classify/evaluate/ConfusionMatrix.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cc/mallet/classify/evaluate/ConfusionMatrix.java b/src/cc/mallet/classify/evaluate/ConfusionMatrix.java index 7d3aaef89..9b83d3637 100644 --- a/src/cc/mallet/classify/evaluate/ConfusionMatrix.java +++ b/src/cc/mallet/classify/evaluate/ConfusionMatrix.java @@ -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);