This might sound stupid! But, I count find any simple example to reference! Can someone please give an example of printing confusion matrix using java?
something like this (the output):
p\a Head Tail
Head 1 4
Tail 4 1
Assuming the data stored in HashMap like this
HashMap<String,Integer>
String = "Head, Tail"
Integer = 4
update (sample code):
public static void main(String[] args) {
HashMap<String,Integer> cmatrix = new HashMap<String,Integer>();
//the string part can hold more the 2 values, all separated with comma
cmatrix.put("tail, head", 1);
cmatrix.put("head ,tail", 4);
cmatrix.put("tail, tail", 1);
cmatrix.put("head, head", 4);
for (Map.Entry entry : cmatrix.entrySet()) {
System.out.println(entry.getKey() +" : "+entry.getValue());
}
}
thanks!
To simplify the code, let's assume no spaces in the source data:
First, we need to gather the names of the classes:
Next, sort the class names:
Then print out the header row.
Then print out each line:
I'll leave the 'prettying up' of the output as an exercise for the reader.