Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

[WIP] Aggregate all diagnostic tools together #1810

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/beanmachine/ppl/diagnostics/tools/js/.prettierrc

This file was deleted.

19 changes: 19 additions & 0 deletions src/beanmachine/ppl/diagnostics/tools/js/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arrowParens": "always",
"bracketSameLine": false,
"bracketSpacing": false,
"embeddedLanguageFormatting": "auto",
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"jsxSingleQuote": false,
"printWidth": 88,
"proseWrap": "never",
"quoteProps": "as-needed",
"semi": true,
"singleAttributePerLine": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false,
"vueIndentScriptAndStyle": false
}
31 changes: 26 additions & 5 deletions src/beanmachine/ppl/diagnostics/tools/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ class DiagnosticsTools:

def __init__(self: DiagnosticsTools, mcs: MonteCarloSamples) -> None:
"""Initialize."""
from beanmachine.ppl.diagnostics.tools.marginal1d.tool import Marginal1d
from beanmachine.ppl.diagnostics.tools.trace.tool import Trace

self.mcs = mcs
self.idata = self.mcs.to_inference_data()
self.marginal1d_tool = Marginal1d
self.trace_tool = Trace

@_requires_dev_packages
def marginal1d(self: DiagnosticsTools) -> None:
Expand All @@ -55,9 +60,7 @@ def marginal1d(self: DiagnosticsTools) -> None:
Returns:
None: Displays the tool directly in a Jupyter notebook.
"""
from beanmachine.ppl.diagnostics.tools.marginal1d.tool import Marginal1d

Marginal1d(self.mcs).show()
self.marginal1d_tool(self.mcs).show()

@_requires_dev_packages
def trace(self: DiagnosticsTools) -> None:
Expand All @@ -67,6 +70,24 @@ def trace(self: DiagnosticsTools) -> None:
Returns:
None: Displays the tool directly in a Jupyter notebook.
"""
from beanmachine.ppl.diagnostics.tools.trace.tool import Trace
self.trace_tool(self.mcs).show()

Trace(self.mcs).show()
@_requires_dev_packages
def dashboard(self: DiagnosticsTools) -> None:
"""
Dashboard showing all available diagnostic tools.

Returns:
None: Displays the tool directly in a Jupyter notebook.
"""
from bokeh.embed import file_html
from bokeh.models.widgets.panels import Panel, Tabs
from bokeh.resources import INLINE
from IPython.display import display, HTML

marginal1d_tool_view = self.marginal1d_tool(self.mcs).create_document()
marginal1d_panel = Panel(child=marginal1d_tool_view, title="Marginal 1D tool")
trace_tool_view = self.trace_tool(self.mcs).create_document()
trace_panel = Panel(child=trace_tool_view, title="Trace tool")
tabs = Tabs(tabs=[marginal1d_panel, trace_panel], sizing_mode="scale_both")
display(HTML(file_html(tabs, resources=INLINE)))
427 changes: 359 additions & 68 deletions tutorials/Coin_flipping.ipynb

Large diffs are not rendered by default.