From 16cf91d065b2c684cb20afe27a3ce06d49b1af79 Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 15 Mar 2021 21:04:51 +0530 Subject: [PATCH 1/9] Added example to plot_hdi using Inference data --- arviz/plots/hdiplot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py index 164fe10523..ece0914e2d 100644 --- a/arviz/plots/hdiplot.py +++ b/arviz/plots/hdiplot.py @@ -108,6 +108,16 @@ def plot_hdi( >>> hdi_data = az.hdi(y_data, input_core_dims=[["draw"]]) >>> ax = az.plot_hdi(x_data, hdi_data=hdi_data[0], color="r", fill_kwargs={"alpha": .2}) >>> az.plot_hdi(x_data, hdi_data=hdi_data[1], color="k", ax=ax, fill_kwargs={"alpha": .2}) + + ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive to plot the HDI interval. + + .. plot:: + :context: close-figs + + >>> data = az.load_arviz_data('radon') + >>> x_data = np.array(data.posterior_predictive.obs_id) + >>> y_data = np.array(data.posterior_predictive.y) + >>> az.plot_hdi(x_data, y_data) """ if hdi_kwargs is None: From 086b00179cc01b1a5f16c90fc0caa9ba1da95368 Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 15 Mar 2021 21:20:57 +0530 Subject: [PATCH 2/9] Minor Changes --- arviz/plots/hdiplot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py index ece0914e2d..4631fd198a 100644 --- a/arviz/plots/hdiplot.py +++ b/arviz/plots/hdiplot.py @@ -108,7 +108,7 @@ def plot_hdi( >>> hdi_data = az.hdi(y_data, input_core_dims=[["draw"]]) >>> ax = az.plot_hdi(x_data, hdi_data=hdi_data[0], color="r", fill_kwargs={"alpha": .2}) >>> az.plot_hdi(x_data, hdi_data=hdi_data[1], color="k", ax=ax, fill_kwargs={"alpha": .2}) - + ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive to plot the HDI interval. .. plot:: From 888d3ad51b0d101e2f9f52ecb760ff68b285d98e Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 15 Mar 2021 21:35:48 +0530 Subject: [PATCH 3/9] linted code --- arviz/plots/hdiplot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py index 4631fd198a..1207223986 100644 --- a/arviz/plots/hdiplot.py +++ b/arviz/plots/hdiplot.py @@ -109,7 +109,8 @@ def plot_hdi( >>> ax = az.plot_hdi(x_data, hdi_data=hdi_data[0], color="r", fill_kwargs={"alpha": .2}) >>> az.plot_hdi(x_data, hdi_data=hdi_data[1], color="k", ax=ax, fill_kwargs={"alpha": .2}) - ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive to plot the HDI interval. + ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive + to plot the HDI interval. .. plot:: :context: close-figs From d40cd9d951293a3e150cebe0fcaddd80d728c3e1 Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 29 Mar 2021 00:25:05 +0530 Subject: [PATCH 4/9] Added x values to Inference Data Object --- arviz/plots/hdiplot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py index 1207223986..6d5bf8264c 100644 --- a/arviz/plots/hdiplot.py +++ b/arviz/plots/hdiplot.py @@ -115,9 +115,13 @@ def plot_hdi( .. plot:: :context: close-figs - >>> data = az.load_arviz_data('radon') - >>> x_data = np.array(data.posterior_predictive.obs_id) - >>> y_data = np.array(data.posterior_predictive.y) + >>> X = np.random.normal(0,1,100) + >>> Y = np.random.normal(2 + X * 0.5, 0.5, (10,100)) + >>> X = {"x":X} + >>> Y = {"y": Y} + >>> dataset = az.from_dict(posterior=Y, constant_data = X) + >>> x_data = dataset.constant_data.x + >>> y_data = dataset.posterior.y >>> az.plot_hdi(x_data, y_data) """ From 0d6e1a5f4240a36a3a0ed379b6ec340f97007d4d Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 15 Mar 2021 21:04:51 +0530 Subject: [PATCH 5/9] Added example to plot_hdi using Inference data --- arviz/plots/hdiplot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py index 6d5bf8264c..3dc214d9df 100644 --- a/arviz/plots/hdiplot.py +++ b/arviz/plots/hdiplot.py @@ -108,6 +108,16 @@ def plot_hdi( >>> hdi_data = az.hdi(y_data, input_core_dims=[["draw"]]) >>> ax = az.plot_hdi(x_data, hdi_data=hdi_data[0], color="r", fill_kwargs={"alpha": .2}) >>> az.plot_hdi(x_data, hdi_data=hdi_data[1], color="k", ax=ax, fill_kwargs={"alpha": .2}) + + ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive to plot the HDI interval. + + .. plot:: + :context: close-figs + + >>> data = az.load_arviz_data('radon') + >>> x_data = np.array(data.posterior_predictive.obs_id) + >>> y_data = np.array(data.posterior_predictive.y) + >>> az.plot_hdi(x_data, y_data) ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive to plot the HDI interval. From 36c1a0ca27670aa31034e63c72095567475890dd Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 15 Mar 2021 21:20:57 +0530 Subject: [PATCH 6/9] Minor Changes --- arviz/plots/hdiplot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py index 3dc214d9df..5375bd6284 100644 --- a/arviz/plots/hdiplot.py +++ b/arviz/plots/hdiplot.py @@ -108,7 +108,7 @@ def plot_hdi( >>> hdi_data = az.hdi(y_data, input_core_dims=[["draw"]]) >>> ax = az.plot_hdi(x_data, hdi_data=hdi_data[0], color="r", fill_kwargs={"alpha": .2}) >>> az.plot_hdi(x_data, hdi_data=hdi_data[1], color="k", ax=ax, fill_kwargs={"alpha": .2}) - + ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive to plot the HDI interval. .. plot:: From e32eb87827b77df0fa2093a52bbb92c093fb8f12 Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 15 Mar 2021 21:35:48 +0530 Subject: [PATCH 7/9] linted code --- arviz/plots/hdiplot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py index 5375bd6284..2ad015f65e 100644 --- a/arviz/plots/hdiplot.py +++ b/arviz/plots/hdiplot.py @@ -109,7 +109,8 @@ def plot_hdi( >>> ax = az.plot_hdi(x_data, hdi_data=hdi_data[0], color="r", fill_kwargs={"alpha": .2}) >>> az.plot_hdi(x_data, hdi_data=hdi_data[1], color="k", ax=ax, fill_kwargs={"alpha": .2}) - ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive to plot the HDI interval. + ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive + to plot the HDI interval. .. plot:: :context: close-figs From 740ce3f73c03198d423cdb787d58a07f8b322e94 Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 29 Mar 2021 13:13:23 +0530 Subject: [PATCH 8/9] Minor changes --- arviz/plots/hdiplot.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py index 2ad015f65e..7b75370175 100644 --- a/arviz/plots/hdiplot.py +++ b/arviz/plots/hdiplot.py @@ -112,27 +112,14 @@ def plot_hdi( ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive to plot the HDI interval. - .. plot:: - :context: close-figs - - >>> data = az.load_arviz_data('radon') - >>> x_data = np.array(data.posterior_predictive.obs_id) - >>> y_data = np.array(data.posterior_predictive.y) - >>> az.plot_hdi(x_data, y_data) - - ``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive - to plot the HDI interval. - .. plot:: :context: close-figs >>> X = np.random.normal(0,1,100) >>> Y = np.random.normal(2 + X * 0.5, 0.5, (10,100)) - >>> X = {"x":X} - >>> Y = {"y": Y} - >>> dataset = az.from_dict(posterior=Y, constant_data = X) - >>> x_data = dataset.constant_data.x - >>> y_data = dataset.posterior.y + >>> idata = az.from_dict(posterior={"y": Y}, constant_data={"x":X}) + >>> x_data = idata.constant_data.x + >>> y_data = idata.posterior.y >>> az.plot_hdi(x_data, y_data) """ From 42afbcc5dcfbcaeec7164e3b5e2ee1d21268733a Mon Sep 17 00:00:00 2001 From: Rishabh261998 Date: Mon, 29 Mar 2021 13:16:42 +0530 Subject: [PATCH 9/9] Updated CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96eff9724e..99546fae67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ * Added "Label guide" page and API section for `arviz.labels` module ([1201](https://github.com/arviz-devs/arviz/pull/1201) and [1635](https://github.com/arviz-devs/arviz/pull/1635)) * Add "Installation guide" page to the documentation ([1551](https://github.com/arviz-devs/arviz/pull/1551)) * Improve documentation on experimental `SamplingWrapper` classes ([1582](https://github.com/arviz-devs/arviz/pull/1582)) +* Added example to `plot_hdi` using Inference Data ([1615](https://github.com/arviz-devs/arviz/pull/1615)) ## v0.11.2 (2021 Feb 21) ### New features