You can use the following lines in your latex document to generate the confusion matrix for a binary classifier.
\documentclass{article}\usepackage[utf8]{inputenc}\usepackage{multirow}\usepackage{multicol}\begin{document}\begin{table}[ht]\centering\renewcommand{\arraystretch}{1.5}\begin{tabular}{l|l|c|c|c}\multicolumn{2}{c}{}&\multicolumn{2}{c}{\textbf{Predicted}}&\\\cline{3-4}\multicolumn{2}{c|}{}&\textbf{Positive}&\textbf{Negative}&\multicolumn{1}{c}{\textbf{Total}}\\\cline{2-4}\multirow{2}{*}{\textbf{Actual}}& \textbf{Positive} & True Positive (TP) & False Negative (FN) & $TP+FN$\\\cline{2-4}& \textbf{Negative} & False Positive (FP) & True Negative (TN) & $FP+TN$\\\cline{2-4}\multicolumn{1}{c}{} & \multicolumn{1}{c}{\textbf{Total}} & \multicolumn{1}{c}{$TP+FP$} & \multicolumn{ 1}{c}{$FN+TN$} & \multicolumn{1}{c}{$N$}\\\end{tabular}\caption{Confusion matrix for binary classification}\label{tab:confusion_matrix}\end{table}\end{document}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{multicol}
\begin{document}
\begin{table}[ht]
\centering
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{l|l|c|c|c}
\multicolumn{2}{c}{}&\multicolumn{2}{c}{\textbf{Predicted}}&\\
\cline{3-4}
\multicolumn{2}{c|}{}&\textbf{Positive}&\textbf{Negative}&\multicolumn{1}{c}{\textbf{Total}}\\
\cline{2-4}
\multirow{2}{*}{\textbf{Actual}}& \textbf{Positive} & True Positive (TP) & False Negative (FN) & $TP+FN$\\
& \textbf{Negative} & False Positive (FP) & True Negative (TN) & $FP+TN$\\
\multicolumn{1}{c}{} & \multicolumn{1}{c}{\textbf{Total}} & \multicolumn{1}{c}{$TP+FP$} & \multicolumn{ 1}{c}{$FN+TN$} & \multicolumn{1}{c}{$N$}\\
\end{tabular}
\caption{Confusion matrix for binary classification}
\label{tab:confusion_matrix}
\end{table}
\end{document}