23

So I see graphical models expressed in plate notation in research papers and online all the time (for example: http://www.cs.princeton.edu/~blei/papers/BleiNgJordan2003.pdf).

Is there a quick and easy way to produce these?? I've searched and searched but all I've found are solutions like GraphViz which are really way more powerful than what I need (and hence much more difficult to use). PGF/Tikz seems like my best bet, but again it seems like overkill.

Maybe my best bet is to just produce them in Inkscape, or bite the bullet and learn PGF/Tikz. They're just so popular that I thought there would be a simpler way to churn them out, but maybe not... TIA.

JMS
  • 331
  • 2
  • 4

5 Answers5

11

GraphViz really isn't that hard to learn. The basic language is really simple for these kinds of graphs. It took me just a few moments to replicate (more or less) the first example from that pdf, and the nice thing about it is that, due to it's simplicity, it's quite easy to generate graphs procedurally from some other data source.

Digraph fig1 {
rankdir = LR; //order things from left to right

//define alpha and beta as existing
α [shape=circle];
β [shape=circle];
//not strictly nescessary but helps if you want to
//assign them specific shapes or colours

subgraph cluster_M //names beginning with "cluster" get a box drawn, an odd hack
{
    label = "M"

    θ [shape=circle];
    subgraph cluster_N
    {
        label = "N"
        z [shape=circle];
        w [shape=circle, style=filled]
        z->w; //quite literally z points at w
    }

    θ -> z;
}
α -> θ;
β -> w;
}

compiled with dot -Tpng input.txt -o graph.png it comes out looking like this. If having the labels below the bubbles was important, you could do that with a couple of extra lines, similarly if specific placement of nodes is important you can adjust that too. In fact, if you don't specify an image format, the default behaviour of dot is to output a version of the input file with co-ordinates for the position of each element.

The output image

Tyr
  • 782
  • 8
  • 19
  • 1
    LOL! I've just seen how old this question is. Ah well, I hope my answer will be useful for anyone else who stumbles upon this question. – Tyr May 02 '13 at 09:26
  • That doesn't matter. Small typo though: `w [shape=circle; style=filled]` should have a comma, not a semicolon: `w [shape=circle, style=filled]` – Anne van Rossum Jul 15 '13 at 09:42
10

Here is a more refined fork of Dietz's scripts: https://github.com/jluttine/tikz-bayesnet

Karsten
  • 882
  • 6
  • 18
9

Check out the excellent Tikz-package by Laura Dietz, available from http://www.mpi-inf.mpg.de/~dietz/probabilistic-models-tikz.zip. A pdf with some examples is available at http://www.mpi-inf.mpg.de/~dietz/probabilistic-models-tikz.pdf.

4

I really like GLE (Graphics Layout Engine). It's what Christopher Bishop used in his book, "Pattern Recognition and Machine Learning". It has a simple syntax with variables, loops, and functions, and it supports TeX equations. Results output as either pdf or eps and look very nice.

Lots of examples are available, including this Bayes net from PRML.

Kyle Simek
  • 9,576
  • 4
  • 26
  • 32
0

As a complement to other answers: a "low-skills" approach I've used is to draw them in Google Slides, with some add-on for producing the formulas.

Valentin Waeselynck
  • 5,950
  • 26
  • 43