From bd09f04ba52dfb449a729c7e15bff6200f9ea686 Mon Sep 17 00:00:00 2001 From: reshamas Date: Wed, 28 Sep 2022 12:49:38 -0400 Subject: [PATCH 1/3] adding myst file --- .../sampler-stats.ipynb | 36 +++++++++++-------- .../sampler-stats.myst.md | 25 ++++++------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/examples/diagnostics_and_criticism/sampler-stats.ipynb b/examples/diagnostics_and_criticism/sampler-stats.ipynb index 81a308d2c..c9075beef 100644 --- a/examples/diagnostics_and_criticism/sampler-stats.ipynb +++ b/examples/diagnostics_and_criticism/sampler-stats.ipynb @@ -7,11 +7,6 @@ "(sampler_stats)=\n", "# Sampler Statistics\n", "\n", - "When checking for convergence or when debugging a badly behaving\n", - "sampler, it is often helpful to take a closer look at what the\n", - "sampler is doing. For this purpose some samplers export\n", - "statistics for each generated sample.\n", - "\n", ":::{post} May 31, 2022\n", ":tags: diagnostics \n", ":category: beginner\n", @@ -65,6 +60,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "When checking for convergence or when debugging a badly behaving sampler, it is often helpful to take a closer look at what the sampler is doing. For this purpose some samplers export statistics for each generated sample. \n", + "\n", "As a minimal example we sample from a standard normal distribution:" ] }, @@ -151,7 +148,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- `Note`: NUTS provides the following statistics( these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC3, to learn more about them, [check this page](https://docs.pymc.io/api/inference.html#module-pymc3.step_methods.hmc.nuts)." + "- `Note`: NUTS provides the following statistics (these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC, to learn more about them, [`pymc.NUTS`](https://www.pymc.io/projects/docs/en/latest/api/generated/pymc.NUTS.html#pymc.NUTS)." ] }, { @@ -1746,6 +1743,23 @@ ");" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Authors\n", + "* Moved from pymc to pymc-examples repo in December 2020 ([pymc-examples#8](https://github.com/pymc-devs/pymc-examples/pull/8))\n", + "* Updated by Meenal Jhajharia in April 2021 ([pymc-examples#95](https://github.com/pymc-devs/pymc-examples/pull/95))\n", + "* Updated to v4 by Christian Luhmann in May 2022 ([pymc-examples#338](https://github.com/pymc-devs/pymc-examples/pull/338))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Watermark" + ] + }, { "cell_type": "code", "execution_count": 16, @@ -1777,14 +1791,6 @@ "%watermark -n -u -v -iv -w" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Updated by Meenal Jhajharia\n", - "* Updated by Christian Luhmann" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -1799,7 +1805,7 @@ "notebook_metadata_filter": "substitutions" }, "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, diff --git a/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md b/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md index ad69e24ea..7a1b502ec 100644 --- a/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md +++ b/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md @@ -7,7 +7,7 @@ jupytext: format_version: 0.13 jupytext_version: 1.13.7 kernelspec: - display_name: Python 3 (ipykernel) + display_name: Python 3 language: python name: python3 --- @@ -15,11 +15,6 @@ kernelspec: (sampler_stats)= # Sampler Statistics -When checking for convergence or when debugging a badly behaving -sampler, it is often helpful to take a closer look at what the -sampler is doing. For this purpose some samplers export -statistics for each generated sample. - :::{post} May 31, 2022 :tags: diagnostics :category: beginner @@ -43,6 +38,8 @@ az.style.use("arviz-darkgrid") plt.rcParams["figure.constrained_layout.use"] = False ``` +When checking for convergence or when debugging a badly behaving sampler, it is often helpful to take a closer look at what the sampler is doing. For this purpose some samplers export statistics for each generated sample. + As a minimal example we sample from a standard normal distribution: ```{code-cell} ipython3 @@ -57,7 +54,7 @@ with model: idata = pm.sample(2000, tune=1000, init=None, step=step, chains=4) ``` -- `Note`: NUTS provides the following statistics( these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC3, to learn more about them, [check this page](https://docs.pymc.io/api/inference.html#module-pymc3.step_methods.hmc.nuts). +- `Note`: NUTS provides the following statistics (these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC, to learn more about them, [`pymc.NUTS`](https://www.pymc.io/projects/docs/en/latest/api/generated/pymc.NUTS.html#pymc.NUTS). ```{code-cell} ipython3 idata.sample_stats @@ -189,15 +186,19 @@ az.plot_density( ); ``` +## Authors +* Moved from pymc to pymc-examples repo in December 2020 ([pymc-examples#8](https://github.com/pymc-devs/pymc-examples/pull/8)) +* Updated by Meenal Jhajharia in April 2021 ([pymc-examples#95](https://github.com/pymc-devs/pymc-examples/pull/95)) +* Updated to v4 by Christian Luhmann in May 2022 ([pymc-examples#338](https://github.com/pymc-devs/pymc-examples/pull/338)) + ++++ + +## Watermark + ```{code-cell} ipython3 %load_ext watermark %watermark -n -u -v -iv -w ``` -* Updated by Meenal Jhajharia -* Updated by Christian Luhmann - -+++ - :::{include} ../page_footer.md ::: From 768538bc9760071c8227a2c1a105b2039c29d5fd Mon Sep 17 00:00:00 2001 From: "Oriol (ZBook)" Date: Sat, 5 Nov 2022 21:50:47 +0100 Subject: [PATCH 2/3] remove notebook from pre-commit exception and fix --- .pre-commit-config.yaml | 1 - examples/diagnostics_and_criticism/sampler-stats.ipynb | 7 +++---- myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 71974c5c2..e3029c2ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -68,7 +68,6 @@ repos: examples/case_studies/blackbox_external_likelihood.ipynb| examples/case_studies/blackbox_external_likelihood_numpy.ipynb| examples/case_studies/item_response_nba.ipynb| - examples/diagnostics_and_criticism/sampler-stats.ipynb| examples/gaussian_processes/GP-MaunaLoa2.ipynb| examples/generalized_linear_models/GLM-logistic.ipynb| examples/generalized_linear_models/GLM-out-of-sample-predictions.ipynb| diff --git a/examples/diagnostics_and_criticism/sampler-stats.ipynb b/examples/diagnostics_and_criticism/sampler-stats.ipynb index c9075beef..01abea208 100644 --- a/examples/diagnostics_and_criticism/sampler-stats.ipynb +++ b/examples/diagnostics_and_criticism/sampler-stats.ipynb @@ -148,7 +148,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- `Note`: NUTS provides the following statistics (these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC, to learn more about them, [`pymc.NUTS`](https://www.pymc.io/projects/docs/en/latest/api/generated/pymc.NUTS.html#pymc.NUTS)." + "- `Note`: NUTS provides the following statistics (these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC, to learn more about them, {class}`pymc.NUTS`." ] }, { @@ -1748,7 +1748,6 @@ "metadata": {}, "source": [ "## Authors\n", - "* Moved from pymc to pymc-examples repo in December 2020 ([pymc-examples#8](https://github.com/pymc-devs/pymc-examples/pull/8))\n", "* Updated by Meenal Jhajharia in April 2021 ([pymc-examples#95](https://github.com/pymc-devs/pymc-examples/pull/95))\n", "* Updated to v4 by Christian Luhmann in May 2022 ([pymc-examples#338](https://github.com/pymc-devs/pymc-examples/pull/338))" ] @@ -1805,7 +1804,7 @@ "notebook_metadata_filter": "substitutions" }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1819,7 +1818,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.4" + "version": "3.9.10" } }, "nbformat": 4, diff --git a/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md b/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md index 7a1b502ec..6e8ebe715 100644 --- a/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md +++ b/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md @@ -7,7 +7,7 @@ jupytext: format_version: 0.13 jupytext_version: 1.13.7 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 --- @@ -54,7 +54,7 @@ with model: idata = pm.sample(2000, tune=1000, init=None, step=step, chains=4) ``` -- `Note`: NUTS provides the following statistics (these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC, to learn more about them, [`pymc.NUTS`](https://www.pymc.io/projects/docs/en/latest/api/generated/pymc.NUTS.html#pymc.NUTS). +- `Note`: NUTS provides the following statistics (these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC, to learn more about them, {class}`pymc.NUTS`. ```{code-cell} ipython3 idata.sample_stats @@ -187,7 +187,6 @@ az.plot_density( ``` ## Authors -* Moved from pymc to pymc-examples repo in December 2020 ([pymc-examples#8](https://github.com/pymc-devs/pymc-examples/pull/8)) * Updated by Meenal Jhajharia in April 2021 ([pymc-examples#95](https://github.com/pymc-devs/pymc-examples/pull/95)) * Updated to v4 by Christian Luhmann in May 2022 ([pymc-examples#338](https://github.com/pymc-devs/pymc-examples/pull/338)) From 4942d23ce6e43560018dbab3fb8ad7ffeacc40f8 Mon Sep 17 00:00:00 2001 From: "Oriol (ZBook)" Date: Sat, 5 Nov 2022 21:58:36 +0100 Subject: [PATCH 3/3] fix extra url link --- examples/diagnostics_and_criticism/sampler-stats.ipynb | 6 +++--- myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/diagnostics_and_criticism/sampler-stats.ipynb b/examples/diagnostics_and_criticism/sampler-stats.ipynb index 01abea208..2839cd9c6 100644 --- a/examples/diagnostics_and_criticism/sampler-stats.ipynb +++ b/examples/diagnostics_and_criticism/sampler-stats.ipynb @@ -8,7 +8,7 @@ "# Sampler Statistics\n", "\n", ":::{post} May 31, 2022\n", - ":tags: diagnostics \n", + ":tags: diagnostics\n", ":category: beginner\n", ":author: Meenal Jhajharia, Christian Luhmann\n", ":::" @@ -60,7 +60,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "When checking for convergence or when debugging a badly behaving sampler, it is often helpful to take a closer look at what the sampler is doing. For this purpose some samplers export statistics for each generated sample. \n", + "When checking for convergence or when debugging a badly behaving sampler, it is often helpful to take a closer look at what the sampler is doing. For this purpose some samplers export statistics for each generated sample.\n", "\n", "As a minimal example we sample from a standard normal distribution:" ] @@ -692,7 +692,7 @@ "metadata": {}, "source": [ "Some points to `Note`:\n", - "- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow [ArviZ's naming convention](https://arviz-devs.github.io/arviz/schema/schema.html#sample-stats), while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object.\n", + "- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow {ref}`ArviZ's naming convention `, while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object.\n", "- `InferenceData` also stores additional info like the date, versions used, sampling time and tuning steps as attributes." ] }, diff --git a/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md b/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md index 6e8ebe715..8a3467ad6 100644 --- a/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md +++ b/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md @@ -16,7 +16,7 @@ kernelspec: # Sampler Statistics :::{post} May 31, 2022 -:tags: diagnostics +:tags: diagnostics :category: beginner :author: Meenal Jhajharia, Christian Luhmann ::: @@ -38,7 +38,7 @@ az.style.use("arviz-darkgrid") plt.rcParams["figure.constrained_layout.use"] = False ``` -When checking for convergence or when debugging a badly behaving sampler, it is often helpful to take a closer look at what the sampler is doing. For this purpose some samplers export statistics for each generated sample. +When checking for convergence or when debugging a badly behaving sampler, it is often helpful to take a closer look at what the sampler is doing. For this purpose some samplers export statistics for each generated sample. As a minimal example we sample from a standard normal distribution: @@ -91,7 +91,7 @@ The sample statistics variables are defined as follows: +++ Some points to `Note`: -- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow [ArviZ's naming convention](https://arviz-devs.github.io/arviz/schema/schema.html#sample-stats), while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object. +- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow {ref}`ArviZ's naming convention `, while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object. - `InferenceData` also stores additional info like the date, versions used, sampling time and tuning steps as attributes. ```{code-cell} ipython3