| 1 |
% example.tex |
| 2 |
% |
| 3 |
% Copyright (C) 2010,2011 Laura Dietz |
| 4 |
% Copyright (C) 2012 Jaakko Luttinen |
| 5 |
% |
| 6 |
% This file may be distributed and/or modified |
| 7 |
% |
| 8 |
% 1. under the LaTeX Project Public License and/or |
| 9 |
% 2. under the GNU General Public License. |
| 10 |
% |
| 11 |
% See the files LICENSE_LPPL and LICENSE_GPL for more details. |
| 12 |
|
| 13 |
\documentclass[a4paper]{article} |
| 14 |
|
| 15 |
\usepackage{tikz} |
| 16 |
\usetikzlibrary{bayesnet} |
| 17 |
%\pgfrealjobname{example} % name of this file |
| 18 |
|
| 19 |
\title{Graphical Models in Tikz} |
| 20 |
\author{Laura Dietz, Jaakko Luttinen} |
| 21 |
|
| 22 |
\begin{document} |
| 23 |
|
| 24 |
\maketitle |
| 25 |
|
| 26 |
TikZ examples for graphical models (Bayesian networks) and directed |
| 27 |
factor graphs \cite{Dietz:2010}. |
| 28 |
|
| 29 |
% A table of node types |
| 30 |
\begin{table}[ht] |
| 31 |
\caption{Node types} |
| 32 |
\begin{center} |
| 33 |
\begin{tabular}{llc} |
| 34 |
Type & Syntax & Output |
| 35 |
\\ |
| 36 |
\hline |
| 37 |
Latent variable & |
| 38 |
\texttt{\textbackslash node[latent]} & |
| 39 |
\tikz{ % |
| 40 |
\node[latent] {$x$}; % |
| 41 |
} |
| 42 |
\\ |
| 43 |
Observed variable & |
| 44 |
\texttt{\textbackslash node[obs]} & |
| 45 |
\tikz{ % |
| 46 |
\node[obs] {$y$}; % |
| 47 |
} |
| 48 |
\\ |
| 49 |
Deterministic & |
| 50 |
\texttt{\textbackslash node[det]} & |
| 51 |
\tikz{ % |
| 52 |
\node[det] {dot} ; % |
| 53 |
} |
| 54 |
\\ |
| 55 |
Constant & |
| 56 |
\texttt{\textbackslash node[const]} & |
| 57 |
\tikz{ % |
| 58 |
\node[const] {$a$}; % |
| 59 |
} |
| 60 |
\\ |
| 61 |
Factor & |
| 62 |
\texttt{\textbackslash node[factor]} & |
| 63 |
\tikz{ % |
| 64 |
\node[factor] [label=$\mathcal{N}$] {}; % |
| 65 |
} |
| 66 |
\\ |
| 67 |
Factor with nodes & |
| 68 |
& |
| 69 |
\tikz{ % |
| 70 |
\node[obs] (y) {$y$} ; % |
| 71 |
\node[latent, left=of y, yshift=0.5cm] (mu) {$\mu$} ; % |
| 72 |
\node[latent, left=of y, yshift=-0.5cm] (tau) {$\tau$} ; % |
| 73 |
\factor[left=of y] {y-factor} {$\mathcal{N}$} {} {}; |
| 74 |
\factoredge {mu,tau} {y-factor} {y} ; % |
| 75 |
} |
| 76 |
\\ |
| 77 |
Plate & |
| 78 |
\texttt{\textbackslash plate} & |
| 79 |
\tikz{ % |
| 80 |
\node[latent] (x) {$x_m$}; % |
| 81 |
\plate {} {(x)} {$m \in \mathcal{M}$}; % |
| 82 |
} |
| 83 |
\\ |
| 84 |
Gate & |
| 85 |
& |
| 86 |
\tikz{ |
| 87 |
% Nodes |
| 88 |
\node[obs] (k) {$k$}; % |
| 89 |
\node[latent, above=2 of k] (l) {$\lambda$}; % |
| 90 |
\factor[above=0.8 of k] {k-f} {Multi} {} {}; % |
| 91 |
\node[latent, right=of k-f] (paa) {$\phi$}; % |
| 92 |
%\node[latent, right=of k-f] (p) {$\phi$}; % |
| 93 |
% Connections |
| 94 |
\factoredge {paa} {k-f} {k} ; % |
| 95 |
% Gate |
| 96 |
\gate {} {(k-f)(k-f-caption)} {l} ; % |
| 97 |
} |
| 98 |
\end{tabular} |
| 99 |
\end{center} |
| 100 |
\end{table} |
| 101 |
|
| 102 |
|
| 103 |
% Simple Bayesian network |
| 104 |
\begin{figure}[ht] |
| 105 |
\begin{center} |
| 106 |
\begin{tabular}{cc} |
| 107 |
\input{model_pca} & |
| 108 |
\input{model_pca2} |
| 109 |
\end{tabular} |
| 110 |
\end{center} |
| 111 |
\caption{PCA model as a Bayesian network and a directed factor |
| 112 |
graph.} |
| 113 |
\end{figure} |
| 114 |
|
| 115 |
% Latent Dirichlet allocation |
| 116 |
\begin{figure}[ht] |
| 117 |
\begin{center} |
| 118 |
\input{model_lda} |
| 119 |
\end{center} |
| 120 |
\caption{Latent Dirichlet allocation as directed factor graph.} |
| 121 |
\end{figure} |
| 122 |
|
| 123 |
% Citation influence model |
| 124 |
\begin{figure}[ht] |
| 125 |
\begin{center} |
| 126 |
\input{model_citation_influence} |
| 127 |
\end{center} |
| 128 |
\caption{Citation influence model with own topics \cite{Dietz:2007} |
| 129 |
as directed factor graph.} |
| 130 |
\end{figure} |
| 131 |
|
| 132 |
\clearpage |
| 133 |
|
| 134 |
\begin{thebibliography}{9} |
| 135 |
|
| 136 |
\bibitem{Dietz:2010} |
| 137 |
Laura Dietz, |
| 138 |
\emph{Directed Factor Graph Notation for Generative Models}. |
| 139 |
Technical Report. 2010 |
| 140 |
|
| 141 |
% Laura Dietz, Steffen Bickel, Tobias Scheffer. |
| 142 |
% Unsupervised Prediction of Citation Influences. |
| 143 |
% In: Proceedings of International Conference on Machine Learning. 2007 |
| 144 |
\bibitem{Dietz:2007} |
| 145 |
Laura Dietz, Steffen Bickel, Tobias Scheffer, |
| 146 |
\emph{Unsupervised Prediction of Citation Influences}. |
| 147 |
In: Proceedings of International Conference on Machine |
| 148 |
Learning. 2007 |
| 149 |
|
| 150 |
|
| 151 |
\end{thebibliography} |
| 152 |
|
| 153 |
\end{document} |
| 154 |
|
| 155 |
%%% Local Variables: |
| 156 |
%%% mode: tex-pdf |
| 157 |
%%% TeX-master: t |
| 158 |
%%% End: |