probmods / webppl-viz

Visualization for WebPPL
http://probmods.github.io/webppl-viz/
Other
14 stars 9 forks source link
visualization webppl

Notice: The architecture of this library is still evolving, so expect (many) backwards-incompatible changes

WebPPL visualization library. Demo: probmods.github.io/webppl-viz/.

Dependencies:

Installation:

cd ~                             # or however you get to the home directory
mkdir .webppl                    # make a folder called .webppl (if it doesn't already exist)
cd .webppl
npm install probmods/webppl-viz  # install this node package

Usage:

Plotting data

Methods for plotting raw data.

Bar plot

viz.bar(df, [options])

viz.bar(xs, ys, [options])

Options:

Line plot

viz.line(df, [options])

viz.line(xs, ys, [options])

Options:

Scatter plot

viz.scatter(xs, ys, [options])

viz.scatter(df, [options])

Options:

Plotting distributions (basic)

Basic methods for visualizing samples and marginal distributions. These plot data that are up to 2-dimensional.

Table

viz.table(dist, [options])

viz.table(samples, [options])

Options:

Histogram

viz.hist(samples, [options])

viz.hist(dist, [options])

Options:

Density plot

viz.density(samples, [options])

viz.density(dist, [options])

Options:

Heat map

viz.heatMap(samples, [options])

viz.heatMap(dist, [options])

Options:

Parallel coordinates

TODO: document this

Plotting distributions (complex)

More complex methods for visualizing smaples and distributions. These can plot data that are higher dimensional.

Marginals

viz.marginals(dist) shows each component of a joint distribution dist -- density plots for real components and histograms for categorical components.

Automatic visualization

viz.auto tries to automatically construct a useful visualization based on the types of the different components in the posterior.

Options:

How it works

viz.auto uses the types of the components to constrain visualization. Let's use c to denote categorical variables and r for real variables (for now, ordinal variables are treated as categorical). Some examples of types:

Support element Type Notes
String c
Integer r
Real number r
Object concatenation of component types The type of {fruit: 'apple', price: 3.6} is rc
Array concatenation of component types The type of [9.2, 8.1, 'candy bar'] is rrc

How each type is visualized:

Type Visualization
c histogram
r density plot
cc bar plot (but if both dimensions have size >5, then heat map)
cr density curve, colors for different categorical groups
rr scatter plot (TODO add heatmap)
ccc trellis frequency table
ccr trellis density plot, colors for different categorical groups
crr trellis scatter plot (TODO add trellis heatmap)
rrr+ parallel coordinates plot
cccc trellis frequency table (TODO)
cccr trellis scatter plot (TODO add trellis heat map)
ccrr trellis scatter plot / heat map (TODO)
crrr trellis parallel coordinates plot (TODO)
ccrrr trellis parallel coordinates plot (TODO)

Development notes

grunt setup-demo       # make webppl and webppl-editor dependencies for demo
grunt bundle           # compile js + minify, make css
grunt browserify       # compiling js
grunt uglify           # minify js
grunt browserify-watch # watchified compile js
grunt css              # make css