4

I am busy with creating a confusion matrix table where I also add the original total in the column Actual.

How can I make my table look like this (The column actual and total can be removed in my tables (i want this look))?

(Without the green and red colors)

enter image description here

\documentclass{article}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}
\begin{document}
\begin{table}[]
\begin{tabular}{ccccc}
\cline{3-5}
 &  & \multicolumn{2}{c}{\textbf{Predicted}} &  \\ \cline{3-5} 
 &  & \textbf{default} & \textbf{non-default} & \textbf{Actual} \\ \hline
\multirow{2}{*}{\textbf{References}} & \textbf{default} & 31300 & 6774 & 38074 \\ \cline{2-2}
 & \textbf{non-default} & 4053 & 72101 & 76154 \\ \hline
 & \textbf{Total} & 35353 & 78875 & 114228 \\ \cline{2-5} 
\end{tabular}
\end{table}
\end{document}
3
  • What do you think needs to be improved? – AndréC Dec 2 '19 at 6:13
  • @AndréC Thank you for the suggestion I edited my question – jennifer ruurs Dec 2 '19 at 6:19
  • 1
    Any table you would like to make coul be easily done using tablesgenerator.com. In the same way, for the math equations I recommend you to use codecogs.com/latex/eqneditor.php. Changing the text color is as simple as use \textcolor{blue}{This is a sample text in blue.} with \usepackage{xcolor}. – scd Dec 3 '19 at 8:36
4

This should give you a foundation from which you can start:

enter image description here

\documentclass{article}

\usepackage{array,makecell}
\usepackage{multirow}

\newcommand{\mc}{\multicolumn{1}{c}}

\begin{document}

\begin{tabular}{ *{5}{|c} | }
  \cline{3-4}
  \mc{} & & \multicolumn{2}{c|}{Condition Phase (worst case)} & \mc{} \\
  \cline{3-4}
  \mc{} & & \makecell{Condition \\ Positive/ \\ Shaded} & 
    \makecell{Condition \\ Negative/ \\ Unshaded} & \mc{\textbf{Actual}} \\
  \hline
  \multirow{5}{*}{\makecell{Testing \\ Phase \\ (best case)}} & 
    \makecell{Test \\ Positive/ \\ Shaded} & 
    \makecell{True positive \\ shaded \\ $T_p$ \\ \textit{(Correct)}} & 
    \makecell{False positive \\ shaded \\ $F_p$ \\ \textit{(Incorrect)}} &
    \makecell{Precision/Positive \\ Predictive Value \\ (PPV) \\ $\frac{T_p}{T_p + F_p} \times 100\%$} \\
  \cline{2-5}
  & 
    \makecell{Test \\ Negative/ \\ Unshaded} & 
    \makecell{False negative \\ unshaded \\ $F_n$ \\ \textit{(Incorrect)}} &
    \makecell{True negative \\ unshaded \\ $T_n$ \\ \textit{(Correct)}} &
    \makecell{Negative \\ Predictive Value \\ (NPV) \\ $\frac{T_n}{T_n + F_n} \times 100\%$} \\
  \hline
  \mc{} & & \makecell{Sensitivity/Recall \\ Rate (RR) \\ $\frac{T_p}{T_p + F_n} \times 100\%$} &
    \makecell{Specificity Rate \\ (SR) \\ $\frac{T_n}{T_n + F_p} \times 100\%$} & \mc{} \\
  \cline{3-4}
\end{tabular}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.