Working with the IEEE document template ( ieeetran
document class) to create a nice-looking table for the confusion matrix. Initially, I created the table for normalized values and it was looking perfect.
When I created a second table, with the actual class value for the confusion matrix, the table alignment somehow changed and for a couple of minutes, I could not understand how to make it aligned well as in table 1.
Code below reproduces the 2-tables:
\documentclass{ieeetran}
\usepackage{rotating}
\usepackage{booktabs, makecell, multirow}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{c}{#2}}
\usepackage{siunitx}
\begin{document}
\begin{table}[ht]
\caption{Confusion matrix normalized}
\label{tab1}
\settowidth\rotheadsize{\textbf{Predicted}}
\centering
\begin{tabular}{*{2}{>{\bfseries}l} *{6}{S[table-format=2.2]} }
\toprule
& & \mcc[6]{\textbf{Actual}} \\
\cmidrule{3-8}
& & {\textbf{Foot}} & {\textbf{Bike}} & {\textbf{Bus}}
& {\textbf{Car}} & {\textbf{Metro}} & {\textbf{Precision}}\\
\midrule
\multirow{5}{*}{\rothead{Predicted}}
& Foot & 0.34 & 0.13 & 0.17 & 0.09 & 0.27 & 0.59 \\
& Bike & 0.29 & 0.17 & 0.21 & 0.02 & 0.33 & 0.05 \\
& Bus & 0.20 & 0.16 & 0.26 & 0.16 & 0.21 & 0.22 \\
& Car & 0.12 & 0.15 & 0.22 & 0.36 & 0.15 & 0.65 \\
& Metro & 0.34 & 0.13 & 0.10 & 0.17 & 0.26 & 0.01 \\
\midrule
& Recall & 0.35 & 0.05 & 0.03 & 0.78 & 0.16 & \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[ht]
\caption{Confusion matrix actual class values}
\label{tab2}
\settowidth\rotheadsize{\textbf{Predicted}}
\centering
\begin{tabular}{*{2}{>{\bfseries}l} *{6}{S[table-format=2.2]} }
\toprule
& & \mcc[6]{\textbf{Actual}} \\
\cmidrule{3-8}
& & {\textbf{Foot}} & {\textbf{Bike}} & {\textbf{Bus}}
& {\textbf{Car}} & {\textbf{Metro}} & {\textbf{Precision}}\\
\midrule
\multirow{5}{*}{\rothead{Predicted}}
& Foot & 5007 & 1896 & 2437 & 1314 & 3947 & 0.59 \\
& Bike & 409 & 218 & 286 & 27 & 458 & 0.05 \\
& Bus & 1688 & 1365 & 2159 & 1346 & 1759 & 0.22 \\
& Car & 2386 & 3093 & 4521 & 7323 & 2978 & 0.65 \\
& Metro & 311 & 113 & 93 & 154 & 233 & 0.01 \\
\midrule
&Recall & 0.35 & 0.05 & 0.03 & 0.78 & 0.16 & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}