Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
uv run --frozen pytest

- name: Lint with black
- name: Lint with ruff
run: |
uv run --frozen black --check src/
uv run --frozen black --check tests/
uv run --frozen ruff format --check src/
uv run --frozen ruff format --check tests/
62 changes: 45 additions & 17 deletions jupyter/fidelity-plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,38 @@
"outputs": [],
"source": [
"# Make up some fake fidelity data.\n",
"fidelity_data = pl.DataFrame([\n",
" {\"column-1\":\"total_score\",\"column-2\":\"sports_flg\",\"tvd\":0.001757401,\"model\":\"LPM\",\"index\":0},\n",
" {\"column-1\":\"terrace_flg\",\"column-2\":\"darts_flg\",\"tvd\":0.0018333333,\"model\":\"LPM\",\"index\":1},\n",
" {\"column-1\":\"total_score\",\"column-2\":\"live_flg\",\"tvd\":0.0020490196,\"model\":\"LPM\",\"index\":2},\n",
" {\"column-1\":\"total_score\",\"column-2\":\"closed\",\"tvd\":0.056201461,\"model\":\"LPM\",\"index\":35}\n",
"])"
"fidelity_data = pl.DataFrame(\n",
" [\n",
" {\n",
" \"column-1\": \"total_score\",\n",
" \"column-2\": \"sports_flg\",\n",
" \"tvd\": 0.001757401,\n",
" \"model\": \"LPM\",\n",
" \"index\": 0,\n",
" },\n",
" {\n",
" \"column-1\": \"terrace_flg\",\n",
" \"column-2\": \"darts_flg\",\n",
" \"tvd\": 0.0018333333,\n",
" \"model\": \"LPM\",\n",
" \"index\": 1,\n",
" },\n",
" {\n",
" \"column-1\": \"total_score\",\n",
" \"column-2\": \"live_flg\",\n",
" \"tvd\": 0.0020490196,\n",
" \"model\": \"LPM\",\n",
" \"index\": 2,\n",
" },\n",
" {\n",
" \"column-1\": \"total_score\",\n",
" \"column-2\": \"closed\",\n",
" \"tvd\": 0.056201461,\n",
" \"model\": \"LPM\",\n",
" \"index\": 35,\n",
" },\n",
" ]\n",
")"
]
},
{
Expand All @@ -39,24 +65,25 @@
"text/html": [
"\n",
"<style>\n",
" #altair-viz-7b641f7c0e5b41afbc0db1e112806a48.vega-embed {\n",
" #altair-viz-ccc2885fcee74291bbc48cce44ffaecd.vega-embed {\n",
" width: 100%;\n",
" display: flex;\n",
" }\n",
"\n",
" #altair-viz-7b641f7c0e5b41afbc0db1e112806a48.vega-embed details,\n",
" #altair-viz-7b641f7c0e5b41afbc0db1e112806a48.vega-embed details summary {\n",
" #altair-viz-ccc2885fcee74291bbc48cce44ffaecd.vega-embed details,\n",
" #altair-viz-ccc2885fcee74291bbc48cce44ffaecd.vega-embed details summary {\n",
" position: relative;\n",
" }\n",
"</style>\n",
"<div id=\"altair-viz-7b641f7c0e5b41afbc0db1e112806a48\"></div>\n",
"<div id=\"altair-viz-ccc2885fcee74291bbc48cce44ffaecd\"></div>\n",
"<script type=\"text/javascript\">\n",
" var VEGA_DEBUG = (typeof VEGA_DEBUG == \"undefined\") ? {} : VEGA_DEBUG;\n",
" (function(spec, embedOpt){\n",
" let outputDiv = document.currentScript.previousElementSibling;\n",
" if (outputDiv.id !== \"altair-viz-7b641f7c0e5b41afbc0db1e112806a48\") {\n",
" outputDiv = document.getElementById(\"altair-viz-7b641f7c0e5b41afbc0db1e112806a48\");\n",
" if (outputDiv.id !== \"altair-viz-ccc2885fcee74291bbc48cce44ffaecd\") {\n",
" outputDiv = document.getElementById(\"altair-viz-ccc2885fcee74291bbc48cce44ffaecd\");\n",
" }\n",
"\n",
" const paths = {\n",
" \"vega\": \"https://cdn.jsdelivr.net/npm/vega@5?noext\",\n",
" \"vega-lib\": \"https://cdn.jsdelivr.net/npm/vega-lib?noext\",\n",
Expand Down Expand Up @@ -93,15 +120,16 @@
"\n",
" if(typeof define === \"function\" && define.amd) {\n",
" requirejs.config({paths});\n",
" require([\"vega-embed\"], displayChart, err => showError(`Error loading script: ${err.message}`));\n",
" let deps = [\"vega-embed\"];\n",
" require(deps, displayChart, err => showError(`Error loading script: ${err.message}`));\n",
" } else {\n",
" maybeLoadScript(\"vega\", \"5\")\n",
" .then(() => maybeLoadScript(\"vega-lite\", \"5.20.1\"))\n",
" .then(() => maybeLoadScript(\"vega-embed\", \"6\"))\n",
" .catch(showError)\n",
" .then(() => displayChart(vegaEmbed));\n",
" }\n",
" })({\"config\": {\"view\": {\"continuousWidth\": 300, \"continuousHeight\": 300}}, \"layer\": [{\"mark\": {\"type\": \"line\", \"strokeDash\": [5, 5]}, \"encoding\": {\"color\": {\"field\": \"model\", \"type\": \"nominal\"}, \"x\": {\"axis\": null, \"field\": \"index\", \"type\": \"ordinal\"}, \"y\": {\"field\": \"tvd\", \"title\": \"Total variation distance\", \"type\": \"quantitative\"}}}, {\"mark\": {\"type\": \"point\"}, \"encoding\": {\"color\": {\"field\": \"model\", \"type\": \"nominal\"}, \"tooltip\": [{\"field\": \"column-1\", \"title\": \"Column 1\", \"type\": \"nominal\"}, {\"field\": \"column-2\", \"title\": \"Column 2\", \"type\": \"nominal\"}], \"x\": {\"axis\": {\"labels\": false}, \"field\": \"index\", \"title\": \"Pairs of columns (ordered from best fit to worst)\", \"type\": \"ordinal\"}, \"y\": {\"field\": \"tvd\", \"type\": \"quantitative\"}}}], \"data\": {\"name\": \"data-7397a78c2d03a088ce5ee99bbed1e8bb\"}, \"height\": 400, \"width\": 400, \"$schema\": \"https://vega.github.io/schema/vega-lite/v5.20.1.json\", \"datasets\": {\"data-7397a78c2d03a088ce5ee99bbed1e8bb\": [{\"column-1\": \"total_score\", \"column-2\": \"sports_flg\", \"tvd\": 0.001757401, \"model\": \"LPM\", \"index\": 0}, {\"column-1\": \"terrace_flg\", \"column-2\": \"darts_flg\", \"tvd\": 0.0018333333, \"model\": \"LPM\", \"index\": 1}, {\"column-1\": \"total_score\", \"column-2\": \"live_flg\", \"tvd\": 0.0020490196, \"model\": \"LPM\", \"index\": 2}, {\"column-1\": \"total_score\", \"column-2\": \"closed\", \"tvd\": 0.056201461, \"model\": \"LPM\", \"index\": 35}]}}, {\"mode\": \"vega-lite\"});\n",
" })({\"$schema\": \"https://vega.github.io/schema/vega/v5.json\", \"data\": [{\"name\": \"source_0\", \"values\": [{\"column-1\": \"total_score\", \"column-2\": \"sports_flg\", \"tvd\": 0.001757401, \"model\": \"LPM\", \"index\": 0}, {\"column-1\": \"terrace_flg\", \"column-2\": \"darts_flg\", \"tvd\": 0.0018333333, \"model\": \"LPM\", \"index\": 1}, {\"column-1\": \"total_score\", \"column-2\": \"live_flg\", \"tvd\": 0.0020490196, \"model\": \"LPM\", \"index\": 2}, {\"column-1\": \"total_score\", \"column-2\": \"closed\", \"tvd\": 0.056201461, \"model\": \"LPM\", \"index\": 35}]}, {\"name\": \"data_0\", \"values\": [{\"column-1\": \"total_score\", \"column-2\": \"sports_flg\", \"index\": 0, \"model\": \"LPM\", \"tvd\": 0.001757401}, {\"column-1\": \"terrace_flg\", \"column-2\": \"darts_flg\", \"index\": 1, \"model\": \"LPM\", \"tvd\": 0.0018333333}, {\"column-1\": \"total_score\", \"column-2\": \"live_flg\", \"index\": 2, \"model\": \"LPM\", \"tvd\": 0.0020490196}, {\"column-1\": \"total_score\", \"column-2\": \"closed\", \"index\": 35, \"model\": \"LPM\", \"tvd\": 0.056201461}]}, {\"name\": \"source_0_x_domain_index_0\", \"values\": [{\"index\": 0}, {\"index\": 1}, {\"index\": 2}, {\"index\": 35}]}, {\"name\": \"data_0_x_domain_index_1\", \"values\": [{\"index\": 0}, {\"index\": 1}, {\"index\": 2}, {\"index\": 35}]}, {\"name\": \"source_0_color_domain_model_0\", \"values\": [{\"model\": \"LPM\"}]}, {\"name\": \"data_0_color_domain_model_1\", \"values\": [{\"model\": \"LPM\"}]}], \"marks\": [{\"type\": \"group\", \"name\": \"layer_0_pathgroup\", \"from\": {\"facet\": {\"data\": \"source_0\", \"name\": \"faceted_path_layer_0_main\", \"groupby\": [\"model\"]}}, \"encode\": {\"update\": {\"width\": {\"field\": {\"signal\": null, \"datum\": null, \"group\": \"width\", \"parent\": null}}, \"height\": {\"field\": {\"signal\": null, \"datum\": null, \"group\": \"height\", \"parent\": null}}}}, \"marks\": [{\"type\": \"line\", \"name\": \"layer_0_marks\", \"from\": {\"data\": \"faceted_path_layer_0_main\"}, \"sort\": {\"field\": \"x\"}, \"encode\": {\"update\": {\"y\": {\"field\": \"tvd\", \"scale\": \"y\"}, \"stroke\": {\"field\": \"model\", \"scale\": \"color\"}, \"strokeDash\": {\"value\": [5, 5]}, \"x\": {\"field\": \"index\", \"scale\": \"x\"}, \"defined\": {\"signal\": \"isValid(datum[\\\"tvd\\\"]) && isFinite(+datum[\\\"tvd\\\"])\"}}}, \"style\": [\"line\"]}]}, {\"type\": \"symbol\", \"name\": \"layer_1_marks\", \"from\": {\"data\": \"data_0\"}, \"encode\": {\"update\": {\"fill\": {\"value\": \"transparent\"}, \"tooltip\": {\"signal\": \"{\\\"Column 1\\\": isValid(datum[\\\"column-1\\\"]) ? datum[\\\"column-1\\\"] : \\\"\\\"+datum[\\\"column-1\\\"], \\\"Column 2\\\": isValid(datum[\\\"column-2\\\"]) ? datum[\\\"column-2\\\"] : \\\"\\\"+datum[\\\"column-2\\\"]}\"}, \"stroke\": {\"field\": \"model\", \"scale\": \"color\"}, \"x\": {\"field\": \"index\", \"scale\": \"x\"}, \"y\": {\"field\": \"tvd\", \"scale\": \"y\"}, \"opacity\": {\"value\": 0.7}}}, \"style\": [\"point\"]}], \"scales\": [{\"name\": \"x\", \"type\": \"point\", \"domain\": {\"fields\": [{\"data\": \"source_0_x_domain_index_0\", \"field\": \"index\"}, {\"data\": \"data_0_x_domain_index_1\", \"field\": \"index\"}], \"sort\": true}, \"range\": [0, {\"signal\": \"width\"}], \"padding\": 0.5}, {\"name\": \"y\", \"type\": \"linear\", \"domain\": {\"fields\": [{\"data\": \"source_0\", \"field\": \"tvd\"}, {\"data\": \"data_0\", \"field\": \"tvd\"}]}, \"range\": [{\"signal\": \"height\"}, 0], \"nice\": true, \"zero\": true}, {\"name\": \"color\", \"type\": \"ordinal\", \"domain\": {\"fields\": [{\"data\": \"source_0_color_domain_model_0\", \"field\": \"model\"}, {\"data\": \"data_0_color_domain_model_1\", \"field\": \"model\"}], \"sort\": true}, \"range\": \"category\"}], \"axes\": [{\"scale\": \"y\", \"zindex\": 0, \"minExtent\": 0, \"labels\": false, \"grid\": true, \"ticks\": false, \"maxExtent\": 0, \"aria\": false, \"gridScale\": \"x\", \"tickCount\": {\"signal\": \"ceil(height/40)\"}, \"orient\": \"left\", \"domain\": false}, {\"scale\": \"x\", \"orient\": \"bottom\", \"title\": \"Pairs of columns (ordered from best fit to worst)\", \"zindex\": 0, \"labelAngle\": 270, \"labelBaseline\": \"middle\", \"grid\": false, \"labels\": false, \"labelAlign\": \"right\"}, {\"scale\": \"y\", \"zindex\": 0, \"title\": \"Total variation distance\", \"orient\": \"left\", \"grid\": false, \"labelOverlap\": true, \"tickCount\": {\"signal\": \"ceil(height/40)\"}}], \"style\": \"cell\", \"legends\": [{\"stroke\": \"color\", \"symbolType\": \"circle\", \"title\": \"model\", \"encode\": {\"symbols\": {\"update\": {\"fill\": {\"value\": \"transparent\"}, \"opacity\": {\"value\": 0.7}}}}}], \"width\": 400, \"background\": \"white\", \"padding\": 5, \"height\": 400}, {\"mode\": \"vega\"});\n",
"</script>"
],
"text/plain": [
Expand All @@ -120,9 +148,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "LPM Plot (Python 3.12)",
"language": "python",
"name": "python3"
"name": "lpm-plot"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -134,7 +162,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.11"
}
},
"nbformat": 4,
Expand Down
141 changes: 141 additions & 0 deletions jupyter/heatmap-interaction-demo.ipynb

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions jupyter/heatmap-plot.ipynb

Large diffs are not rendered by default.

Loading