I'm trying to print a confusion matrix, but I'm not sure if there is an easy way to print this kind of tables without write complex loops to concatenate the string. Right now, I just did it like this example. Is it there a different way.
t1 = "|" + " " \* 8 + "|" + " " \* 10 + "| Predicted |" + " " \*10 + "|\\n"
t2 = "|" + " " \* 8 + "|" + " " \* 10 + "| Positive |" + " Negative |\\n"
t3 = "| Actual |" + " Positive |" + " " \* (10 - len(str(TP))) + str(TP) + " |" + " " \* (9 - len(str(FN))) + str(FN) + " |\\n"
t4 = "|" + " " \* 8 + "|" + " Negative |" + " " \* (10 - len(str(FP))) + str(FP) + " |" + " " \* (9 - len(str(TN))) + str(TN) + " |\\n"
print(t1+t2+t3+t4)
| | | Predicted | |
| | | Positive | Negative |
| Actual | Positive | 1 | 2 |
| | Negative | 1 | 2 |
I am trying to find an easy way to print this kind of tables.