Department of Computer Science Technische Universitaet Muenchen
Home People Teaching Research Publications Info Sitemap

PyMLNs: Markov logic networks in Python

Markov logic networks (MLNs) combine first-order logic with the probabilistic semantics of graphical models. PyMLNs offers you inference and learning tools for MLNs. If you are yet unfamiliar with Markov logic, I encourage you to visit Pedro Domingos' homepage for a list of relevant publications.

The PyMLNs package contains:

  • Graphical tools for performing inference in MLNs and learning the parameters of MLNs, using either PyMLNs itself or the Alchemy system as the underlying engine.
    • MLN and database files are displayed with syntax highlighting and can be edited in-place; modified data is automatically saved either to the same file or a new file (which can be named manually).
    • all your settings are saved (even context-specific, e.g. the query you made for each evidence database is remembered) so that sessions may be resumed
    • automatic naming of output files based on input filenames and settings
    • Alchemy command line arguments are interpreted or passed on to the wrapped tool.
    • The output files the Alchemy tools produce are processed so that domain declarations and constraints for mutual exclusiveness and exhaustiveness that were present in the input file are retained. Furthermore, the parameters with which the tools were invoked as well as the input files can be added as a comment to the output file so that the origins of output files are always clear.
  • An implementation of MLNs as a Python module, the PyMLNs engine. Features:
    • inference: exact inference, MC-SAT and Gibbs sampling
      All algorithms can can be used to compute the (conditional) probabilities of complex formulas, not just atoms.
    • parameter learning: maximum likelihood (several variants based on log-likelihood and pseudo-log-likelihood)
    • direct support for all logical operators and object equality with the = operator; formulas are not decomposed into clauses
    • numerous output and debugging functions, e.g. for printing the distribution over possible worlds for a given domain, the ground formulas and their truth values for a possible world, and many more.
    • experimental features:
      • constraints on formula probabilities
      • learning and inference for an alternate representation where the parameters are not regular weights but factors between 0 and 1

Prerequisites

  • Python 2.4 or above
  • The necessary Python module pyparsing is packaged with PyMLNs (v1.4.6).
    if you want/need to install a different version, go here.
  • Recommended optional Python modules:
    • To enable parameter learning with the PyMLNs engine, you need SciPy and NumPy.
    • To speed up calculations with the internal engine on i386-compatible machines, I highly recommend installing Psyco.

Download

  • pymlns.tar.gz (112K, updated 2008-06-30)
    Please refer to the readme file for usage information.

Screenshot of the query tool:

Contact

If you have any questions or comments, please don't hesitate to contact me.


Computer Science IX | Technische Universität München