Code Monkey home page Code Monkey logo

turkie.jl's Introduction

Turing + Makie -> Turkie!

WIP for an inference visualization package.

This package is not registered at the moment and will probably be merged with TuringCallbacks at some point. To try it nonetheless run :

] add https://github.com/theogf/Turkie.jl

To plot during sampling :

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

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 Makie # You could also use CairoMakie or another backend
@model function demo(x) # Some random Turing model
    v ~ InverseGamma(3, 2)
    s ~ InverseGamma(2, 3)
    m ~ Normal(0, s)
    for i in eachindex(x)
        x[i] ~ Normal(m, s)
    end
end

xs = randn(100) .+ 1;
m = demo(xs);
cb = TurkieCallback(m) # Create a callback function to be given to sample
chain = sample(m, NUTS(0.65), 300; callback = cb)

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

cb = TurkieCallback(Dict(:v => [:trace, :mean],
                        :s => [:autocov, :var]))

You can also directly pass OnlineStats object :

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

If you want to record the video do

using Makie
record(cb.scene, joinpath(@__DIR__, "video.webm")) do io
    addIO!(cb, io)
    sample(m,  NUTS(0.65), 300; callback = cb)
end

turkie.jl's People

Contributors

alfredjmduncan avatar github-actions[bot] avatar jlperla avatar theogf avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.