The Unix philosophy – applied to inference for dynamical models. – Plug-and-play inference for dynamical models



The Unix philosophy – applied to inference for dynamical models. – Plug-and-play inference for dynamical models

0 0


inference_unix

My presentation for EEB @ Princeton

On Github sballesteros / inference_unix

The Unix philosophy

applied to inference for dynamical models.

cat theta.json | simplex -M 1e4 | ksimplex -M 1e4 | mif -M 1e2 > mle.json

Sebastien Ballesteros, Tiffany Bogich, Joseph Dureau

The Unix philosophy

Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.

cat index.html | wc

ls | grep .html | wc -l

Plug-and-play inference for dynamical models

Code → Inference

plug-and-play methods require only simulations from a model

Plug-and-play methods for everything

  • Deterministic (process) models: simplex, MCMC, ...
  • Stochastic models in a Gaussian world: Kalman filters (EKF, UKF, ...).
  • Stochastic models: MIF, pMCMC, SMC2, ...

Plug-and-play methods have to be combined to be efficient

  • Deterministic (process) models: simplex, MCMC, ...Fast but approximative.
  • Stochastic models in a Gaussian world: Kalman filters (EKF, UKF, ...) Fast but approximative.
  • Stochastic models: MIF, pMCMC, SMC2, ... Slow but exact.

  • Need to generate all the implementations of a model.
    • ODE
    • SDE (diffusion approximation)
    • Stochastic process (Euler Multinomial, Gillespie...)
  • Some methods need the Jacobians.

Back to Unix

  • Rule of Generation: Developers should avoid writing code by hand and instead write abstract high-level programs that generate code. This rule aims to reduce humans errors and save time.
  • Rule of Composition: Developers should write programs that can communicate easily with other programs. This rule aims to allow developers to break down projects into small, simple programs rather than overly complex monolithic programs.

Plug-and-play2

Semantic → Code → Inference

  • A layered formal grammar for model semantics, playing well with symbolic calculus libraries (e.g sympy).
  • Independant inference methods being able to be communicate with each other (outside any framework) to solve complex problems on distributed computing architectures.

JSON as a universal text interface for modeling

  • Model as data, data as JSON, implementation of model semantics relegated to machines.
      "model": [
        {"from": "S", "to": "I",  "rate": "beta*S*I/N"},
        {"from": "I", "to": "R",  "rate": "v"}
      ],
    
      "white_noise": [
        {
          "reaction": [{"from":"S", "to": "I"}],
          "sd": "sto"
        }
      ]
  • Interaction: JSON as an ideal exchange format for structured models.
    {
      "beta": {
        "transformation": "log",
        "unit": "D"
        "guess": {"NewYork": 90, "Paris": 120}
      },
    }

Inference the Unix way

cat theta.json | simplex -M 1e4 | ksimplex -M 1e4 | mif -M 1e2 > mle.json
  • Work at the semantic level to add structure.
    • Erlangify
    • Space, age, ...
  • Work at the implementation level to perform simulation, filtering, optimisation and sampling.
    • simul [implementation]
    • smc [implementation]
    • kalman [implementation]
    • simplex [implementation]
    • ksimplex [implementation]
    • kmcmc [implementation]
    • pmcmc [implementation]
    • mif [implementation]
  • Universal I/O.

Inference pipeline

[
  {
    name: "lhs_simplex",  
    id: "lhs",
    H: 500,  
    cmd: [
      {
        comment: "Get the initial conditions",
        fit: "-D -p -I",
        algorithm: "simul ode -T 100000"
      },
      {
        comment: "First simplex",
        fit: "-D -X -p -r rep -j",
        algorithm: "simplex -M 10000 --no_trace --prior"
      },
      {
        comment: "We chain ksimplex",
        fit: "-B -u 0.01",
        algorithm: "ksimplex -M 10000 --no_trace --prior",
        repeat: 19
      }
    ]
  },
  {
   reduce: "best"
  },
  {
    name: "pMCMC_sampler", 
    id: "replicate",
    H: 19,  
    cmd: [
      {
        comment: "Get a covariance matrix",
        fit: "-D",
        algorithm: "kmcmc -M 20000 --full"
      },
      {
        comment: "sample",
        fit: "-D -C",
        algorithm: "pmcmc -M 1000000 -J 1000 --full -C"
      }
    ]
  }
]

Demo

>

Get involved

https://github.com/plom/plom-sfi