Skip to content

Commit

Permalink
Add example data loading (#212)
Browse files Browse the repository at this point in the history
* Add local example datasets

* Add DataDeps as dependency

* Define utility types for file metadata

* Define all example datasets

* Register data on initialization

* Define load_example_data function

* Test load_example_data

* Deprecate load_arviz_data

* Update load_arviz_data tests

* Rename load_arviz_data to load_example_data

* Increment patch number

* Add arviz_example_data as git submodule

* Remove local data from repo

* Add JSON3 as dependency

* Load example data metadata from submodule

* Run formatter

* Checkout submodules in GitHub Actions

* Simplify code to load from JSON

* Declare correct defaults

* Avoid missing constant

* Add additional tests

* Increment version number
  • Loading branch information
sethaxen authored Aug 17, 2022
1 parent 50950ea commit 931c3ec
Show file tree
Hide file tree
Showing 24 changed files with 273 additions and 62 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: julia-actions/setup-julia@v1
- name: Cache CmdStan
id: cache-cmdstan
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/futures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
arviz_version: "release"
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/data/example_data"]
path = deps/data/example_data
url = https://github.com/arviz-devs/arviz_example_data
6 changes: 5 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name = "ArviZ"
uuid = "131c737c-5715-5e2e-ad31-c244f01c1dc7"
authors = ["Seth Axen <[email protected]>"]
version = "0.6.3"
version = "0.6.4"

[deps]
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"
InferenceObjects = "b5cf5a8d-e756-4ee3-b014-01d49d192c00"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Expand All @@ -21,9 +23,11 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
Conda = "1.0"
DataDeps = "0.7"
DataFrames = "0.20, 0.21, 0.22, 1.0"
DimensionalData = "0.20, 0.21"
InferenceObjects = "0.1"
JSON3 = "1"
LogExpFunctions = "0.2.0, 0.3"
OrderedCollections = "1"
PSIS = "0.2, 0.3, 0.4, 0.5"
Expand Down
1 change: 1 addition & 0 deletions deps/data/example_data
Submodule example_data added at 594a6a
2 changes: 1 addition & 1 deletion docs/src/api/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ extract_dataset
## Example data

```@docs
load_arviz_data
load_example_data
```
2 changes: 1 addition & 1 deletion docs/src/creating_custom_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In this parameterization, the model has some sampling issues.
"""

# ╔═╡ cbd81558-e355-4e7a-ba51-0ba9299cb558
idata = load_arviz_data("centered_eight")
idata = load_example_data("centered_eight")

# ╔═╡ 898d83d1-cd3a-47a4-84b1-f2cf0f7bf959
idata.posterior
Expand Down
70 changes: 35 additions & 35 deletions docs/src/mpl_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("centered_eight")
data = load_example_data("centered_eight")
plot_autocorr(data; var_names=[:tau, :mu])
gcf()
Expand All @@ -26,7 +26,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("regression1d")
data = load_example_data("regression1d")
plot_bpv(data)
gcf()
Expand All @@ -43,7 +43,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("regression1d")
data = load_example_data("regression1d")
plot_bpv(data; kind=:t_stat, t_stat="0.5")
gcf()
Expand All @@ -62,8 +62,8 @@ ArviZ.use_style("arviz-darkgrid")
model_compare = compare(
Dict(
"Centered 8 schools" => load_arviz_data("centered_eight"),
"Non-centered 8 schools" => load_arviz_data("non_centered_eight"),
"Centered 8 schools" => load_example_data("centered_eight"),
"Non-centered 8 schools" => load_example_data("non_centered_eight"),
),
)
plot_compare(model_compare; figsize=(12, 4))
Expand All @@ -82,8 +82,8 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
centered_data = load_arviz_data("centered_eight")
non_centered_data = load_arviz_data("non_centered_eight")
centered_data = load_example_data("centered_eight")
non_centered_data = load_example_data("non_centered_eight")
plot_density(
[centered_data, non_centered_data];
data_labels=["Centered", "Non Centered"],
Expand Down Expand Up @@ -129,8 +129,8 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
d1 = load_arviz_data("centered_eight")
d2 = load_arviz_data("non_centered_eight")
d1 = load_example_data("centered_eight")
d2 = load_example_data("non_centered_eight")
plot_elpd(Dict("Centered eight" => d1, "Non centered eight" => d2); xlabels=true)
gcf()
Expand All @@ -147,7 +147,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("centered_eight")
data = load_example_data("centered_eight")
plot_energy(data; figsize=(12, 8))
gcf()
Expand All @@ -164,7 +164,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
idata = load_arviz_data("radon")
idata = load_example_data("radon")
plot_ess(idata; var_names=[:b], kind=:evolution)
gcf()
Expand All @@ -181,7 +181,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
idata = load_arviz_data("non_centered_eight")
idata = load_example_data("non_centered_eight")
plot_ess(idata; var_names=[:mu], kind=:local, marker="_", ms=20, mew=2, rug=true)
gcf()
Expand All @@ -198,7 +198,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
idata = load_arviz_data("radon")
idata = load_example_data("radon")
plot_ess(idata; var_names=[:sigma], kind=:quantile, color="C4")
gcf()
Expand All @@ -215,8 +215,8 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
centered_data = load_arviz_data("centered_eight")
non_centered_data = load_arviz_data("non_centered_eight")
centered_data = load_example_data("centered_eight")
non_centered_data = load_example_data("non_centered_eight")
plot_forest(
[centered_data, non_centered_data];
model_names=["Centered", "Non Centered"],
Expand All @@ -238,7 +238,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
rugby_data = load_arviz_data("rugby")
rugby_data = load_example_data("rugby")
plot_forest(
rugby_data;
kind=:ridgeplot,
Expand Down Expand Up @@ -288,7 +288,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("non_centered_eight")
data = load_example_data("non_centered_eight")
plot_pair(
data;
var_names=[:theta],
Expand All @@ -312,7 +312,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("centered_eight")
data = load_example_data("centered_eight")
## Combine different posterior draws from different chains
obs = data.posterior_predictive.obs
Expand Down Expand Up @@ -381,7 +381,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
idata = load_arviz_data("radon")
idata = load_example_data("radon")
loo_data = loo(idata)
plot_khat(loo_data; show_bins=true)
Expand All @@ -399,7 +399,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
idata = load_arviz_data("radon")
idata = load_example_data("radon")
plot_loo_pit(idata; y=:y, ecdf=true, color=:maroon)
Expand All @@ -417,7 +417,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
idata = load_arviz_data("non_centered_eight")
idata = load_example_data("non_centered_eight")
plot_loo_pit(; idata, y=:obs, color=:indigo)
gcf()
Expand All @@ -434,7 +434,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("centered_eight")
data = load_example_data("centered_eight")
plot_mcse(data; var_names=[:tau, :mu], rug=true, extra_methods=true)
gcf()
Expand All @@ -451,7 +451,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("radon")
data = load_example_data("radon")
plot_mcse(data; var_names=[:sigma_a], color="C4", errorbar=true)
gcf()
Expand All @@ -468,7 +468,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
centered = load_arviz_data("centered_eight")
centered = load_example_data("centered_eight")
coords = Dict(:school => ["Choate", "Deerfield"])
plot_pair(
centered; var_names=[:theta, :mu, :tau], coords, divergences=true, textsize=22
Expand All @@ -488,7 +488,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
centered = load_arviz_data("centered_eight")
centered = load_example_data("centered_eight")
coords = Dict(:school => ["Choate", "Deerfield"])
plot_pair(
centered;
Expand All @@ -513,7 +513,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
centered = load_arviz_data("centered_eight")
centered = load_example_data("centered_eight")
coords = Dict(:school => ["Choate", "Deerfield"])
plot_pair(
centered;
Expand All @@ -538,7 +538,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
centered = load_arviz_data("centered_eight")
centered = load_example_data("centered_eight")
coords = Dict(:school => ["Choate", "Deerfield"])
plot_pair(
centered;
Expand All @@ -565,7 +565,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("centered_eight")
data = load_example_data("centered_eight")
ax = plot_parallel(data; var_names=[:theta, :tau, :mu])
ax.set_xticklabels(ax.get_xticklabels(); rotation=70)
draw()
Expand All @@ -584,7 +584,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("centered_eight")
data = load_example_data("centered_eight")
coords = Dict(:school => ["Choate"])
plot_posterior(data; var_names=[:mu, :theta], coords, rope=(-1, 1))
Expand All @@ -602,7 +602,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("non_centered_eight")
data = load_example_data("non_centered_eight")
plot_ppc(data; data_pairs=Dict(:obs => :obs), alpha=0.03, figsize=(12, 6), textsize=14)
gcf()
Expand All @@ -619,7 +619,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("non_centered_eight")
data = load_example_data("non_centered_eight")
plot_ppc(data; alpha=0.3, kind=:cumulative, figsize=(12, 6), textsize=14)
gcf()
Expand All @@ -636,7 +636,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("centered_eight")
data = load_example_data("centered_eight")
plot_rank(data; var_names=[:tau, :mu])
gcf()
Expand All @@ -653,7 +653,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("classification10d")
data = load_example_data("classification10d")
plot_separation(data; y=:outcome, y_hat=:outcome, figsize=(8, 1))
gcf()
Expand All @@ -670,7 +670,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("non_centered_eight")
data = load_example_data("non_centered_eight")
plot_trace(data; var_names=[:tau, :mu])
gcf()
Expand All @@ -687,7 +687,7 @@ using ArviZ
ArviZ.use_style("arviz-darkgrid")
data = load_arviz_data("non_centered_eight")
data = load_example_data("non_centered_eight")
plot_violin(data; var_names=[:mu, :tau])
gcf()
Expand Down
2 changes: 1 addition & 1 deletion docs/src/working_with_inference_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Let's load one of ArviZ's example datasets.
In this HTML view, you can click a group name to expand a summary of the group.

```@example wwid
idata = load_arviz_data("centered_eight")
idata = load_example_data("centered_eight")
```

!!! info
Expand Down
Loading

2 comments on commit 931c3ec

@sethaxen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/66451

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.4 -m "<description of version>" 931c3ec16247ec1b5f8a20f47c8361aece1faf59
git push origin v0.6.4

Please sign in to comment.