All Projects → theogf → Turkie.jl

theogf / Turkie.jl

Licence: MIT license
Turing + Makie = Turkie

Programming Languages

julia
2034 projects

Docs Latest Docs Stable Coverage Status CI

Turing + Makie -> Turkie!

WIP for an inference visualization package.

To plot during sampling :

  • Trace of the chains
  • Statistics (mean and var)
  • Marginals (KDE/Histograms)
  • Autocorrelation plots
  • Show multiple chains

Additional features :

  • Selecting which variables are plotted
  • Selecting what plots to show
  • Giving a recording option
  • Additional fine tuning features like
    • Thinning
    • Creating a buffer to limit the viewing

Extra Features

  • Using a color mapping given some statistics
  • Allow to apply transformation before plotting

Usage:

Small example:

using Turing
using Turkie
using GLMakie # You could also use CairoMakie or another backend
@model function demo(x) # Some random Turing model
    m0 ~ Normal(0, 2)
    s ~ InverseGamma(2, 3)
    m ~ Normal(m0, s)
    for i in eachindex(x)
        x[i] ~ Normal(m, s)
    end
end

xs = randn(100) .+ 1 # Create some random data
m = demo(xs) # Create the model
cb = TurkieCallback(m) # Create a callback function to be given to the sample
chain = sample(m, NUTS(0.65), 300; callback = cb) # Sample and plot at the same time

If you want to show only some variables you can give a Dict to TurkieCallback :

cb = TurkieCallback(
            (m0 = [:trace, :mean], s = [:autocov, :var])
          )

You can also directly pass OnlineStats object :

using OnlineStats
cb = TurkieCallback(
            (v = [Mean(), AutoCov(20)],)
          )

If you want to record the video do

using Makie
record(cb.figure, joinpath(@__DIR__, "video.webm")) do io
    addIO!(cb, io)
    sample(m,  NUTS(0.65), 300; callback = cb)
end
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].