我们之前介绍过latex的表格。那么混淆矩阵本质上来讲也是一个表格。怎么简单,快速准确的画出来。
如果先画出来,在插入到论文中,难免会low,而且放缩的话图片会失真。百度上是没有搜索到。所以用google。
首先是不加颜色的,黑白的,使用了Tikz包
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
box/.style={draw,rectangle,minimum size=2cm,text width=1.5cm,align=left}]
\matrix (conmat) [row sep=.1cm,column sep=.1cm] {
\node (tpos) [box,
label=left:\( \mathbf{p'} \),
label=above:\( \mathbf{p} \),
] {True \\ positive};
&
\node (fneg) [box,
label=above:\textbf{n},
label=above right:\textbf{total},
label=right:\( \mathrm{P}' \)] {False \\ negative};
\\
\node (fpos) [box,
label=left:\( \mathbf{n'} \),
label=below left:\textbf{total},
label=below:P] {False \\ positive};
&
\node (tneg) [box,
label=right:\( \mathrm{N}' \),
label=below:N] {True \\ negative};
\\
};
\node [left=.05cm of conmat,text width=1.5cm,align=right] {\textbf{actual \\ value}};
\node [above=.05cm of conmat] {\textbf{prediction outcome}};
\end{tikzpicture}
\end{document}
长这样:
如果是彩色的&