From 3e88c8e101e55b5689209470e60ddcb4e4962d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Rozet?= Date: Tue, 13 Feb 2024 11:37:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Move=20diagnostics=20into=20sepa?= =?UTF-8?q?rate=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tutorials/coverage.ipynb | 2 +- lampe/diagnostics/__init__.py | 3 +++ lampe/{diagnostics.py => diagnostics/coverage.py} | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 lampe/diagnostics/__init__.py rename lampe/{diagnostics.py => diagnostics/coverage.py} (98%) diff --git a/docs/tutorials/coverage.ipynb b/docs/tutorials/coverage.ipynb index 98bb001..0215131 100644 --- a/docs/tutorials/coverage.ipynb +++ b/docs/tutorials/coverage.ipynb @@ -170,7 +170,7 @@ "source": [ "## Expected coverage\n", "\n", - "Using the [`expected_coverage_mc`](lampe.diagnostics.expected_coverage_mc) and [`expected_coverage_ni`](lampe.diagnostics.expected_coverage_ni) functions provided by the [`lampe.diagnostics`](lampe.diagnostics) module, we estimate the respective expected coverage of the three estimators. The expected coverage at credible level $1 - \\alpha$ is the probability of a set of parameters $\\theta^*$ to fall inside the highest posterior density \n", + "Using the [`expected_coverage_mc`](lampe.diagnostics.coverage.expected_coverage_mc) and [`expected_coverage_ni`](lampe.diagnostics.coverage.expected_coverage_ni) functions provided by the [`lampe.diagnostics`](lampe.diagnostics) module, we estimate the respective expected coverage of the three estimators. The expected coverage at credible level $1 - \\alpha$ is the probability of a set of parameters $\\theta^*$ to fall inside the highest posterior density \n", "\n", "The expected coverage of a posterior estimator $q(\\theta | x)$ at credible level $1 - \\alpha$ is the probability of a set of parameters $\\theta^*$ to be included in the highest density region of total probability $1 - \\alpha$ of the posterior estimator, given an observation $x^* \\sim p(x | \\theta^*)$. If the estimator is callibrated, the expected coverage at credible level $1 - \\alpha$ is exactly $1 - \\alpha$. If it is overconfident, the highest density regions are smaller than they should be, which translates into lower coverages. If it is conservative/underconfident, the highest density regions are larger than they should be and the expected coverages are larger than their nominal level." ] diff --git a/lampe/diagnostics/__init__.py b/lampe/diagnostics/__init__.py new file mode 100644 index 0000000..a25b52b --- /dev/null +++ b/lampe/diagnostics/__init__.py @@ -0,0 +1,3 @@ +r"""Diagnostics and reliability assessment.""" + +from .coverage import * diff --git a/lampe/diagnostics.py b/lampe/diagnostics/coverage.py similarity index 98% rename from lampe/diagnostics.py rename to lampe/diagnostics/coverage.py index 36437c2..1d0463f 100644 --- a/lampe/diagnostics.py +++ b/lampe/diagnostics/coverage.py @@ -1,4 +1,4 @@ -r"""Diagnostics and reliability assessment.""" +r"""Coverage diagnostics.""" import torch @@ -8,7 +8,7 @@ from typing import Callable, Iterable, Tuple # isort: local -from .utils import gridapply +from ..utils import gridapply def expected_coverage_mc(