减小混淆矩阵的大小

减小混淆矩阵的大小

我使用了建议的代码如何在 LaTeX 中构建混淆矩阵?创建混淆矩阵:

\documentclass{article}
\usepackage{array}
\usepackage{graphicx}
\usepackage{multirow}

\newcommand\MyBox[2]{
  \fbox{\lower0.75cm
    \vbox to 1.7cm{\vfil
      \hbox to 1.7cm{\hfil\parbox{1.4cm}{#1\\#2}\hfil}
      \vfil}%
  }%
}

\begin{document}

\noindent
\renewcommand\arraystretch{1.5}
\setlength\tabcolsep{0pt}
\begin{tabular}{c >{\bfseries}r @{\hspace{0.7em}}c @{\hspace{0.4em}}c @{\hspace{0.7em}}l}
  \multirow{10}{*}{\rotatebox{90}{\parbox{1.1cm}{\bfseries\centering actual\\ value}}} & 
    & \multicolumn{2}{c}{\bfseries Prediction outcome} & \\
  & & \bfseries p & \bfseries n & \bfseries total \\
  & p$'$ & \MyBox{True}{Positive} & \MyBox{False}{Negative} & P$'$ \\[2.4em]
  & n$'$ & \MyBox{False}{Positive} & \MyBox{True}{Negative} & N$'$ \\
  & total & P & N &
\end{tabular}

\end{document}

在此处输入图片描述

对于我的双栏文章来说,这个尺寸有点大。我该如何缩小它的尺寸?

诗篇

我将其用作\documentclass[conference,hidelinks]{IEEEtran}文档类。

答案1

如果先前答案中给出的代码生成的混淆矩阵对您来说太大(即使它可以轻松容纳在可用空间内),您可以编辑代码以将各个维度减少 20%,或者您可以将代码放在指令内\scalebox{0.8}{<code for confusion matrix>}

下面的代码使用第二种方法。它显示了未缩放的混淆矩阵和缩小 20% 的混淆矩阵。

在此处输入图片描述

\documentclass[conference,hidelinks]{IEEEtran}
\usepackage{array,graphicx,multirow}
\usepackage{lipsum} % for filler text

\newcommand\MyBox[2]{
  \fbox{\lower0.75cm
    \vbox to 1.7cm{\vfil
      \hbox to 1.7cm{\hfil\parbox{1.4cm}{#1\\#2}\hfil}
      \vfil}%
  }%
}

\begin{document}

Two sizes: First unscaled, then scaled down 20\%

\begin{center}
\renewcommand\arraystretch{1.5}
\setlength\tabcolsep{0pt}

\begin{tabular}{c >{\bfseries}r @{\hspace{0.7em}}c @{\hspace{0.4em}}c @{\hspace{0.7em}}l}
  \multirow{11}{*}{\rotatebox{90}{\parbox{1.1cm}{\bfseries\centering actual\\ value}}} & 
    & \multicolumn{2}{c}{\bfseries Prediction outcome} & \\
  & & \bfseries p & \bfseries n & \bfseries total \\
  & p$'$ & \MyBox{True}{Positive} & \MyBox{False}{Negative} & P$'$ \\[2.4em]
  & n$'$ & \MyBox{False}{Positive} & \MyBox{True}{Negative} & N$'$ \\
  & total & P & N &
\end{tabular} 

\bigskip
\scalebox{0.8}{% 
\begin{tabular}{c >{\bfseries}r @{\hspace{0.7em}}c @{\hspace{0.4em}}c @{\hspace{0.7em}}l}
  \multirow{11}{*}{\rotatebox{90}{\parbox{1.1cm}{\bfseries\centering actual\\ value}}} & 
    & \multicolumn{2}{c}{\bfseries Prediction outcome} & \\
  & & \bfseries p & \bfseries n & \bfseries total \\
  & p$'$ & \MyBox{True}{Positive} & \MyBox{False}{Negative} & P$'$ \\[2.4em]
  & n$'$ & \MyBox{False}{Positive} & \MyBox{True}{Negative} & N$'$ \\
  & total & P & N &
\end{tabular}}
\end{center}

\lipsum[2] % filler text

\end{document}

相关内容