ergodicDocs
Products: switch from ergodic to another product
Get started

ReferenceDatasets

Datasets

Real-world datasets with their causal question, in the style of sklearn loaders. Import from ergodic.datasets.

Each loader returns a Bunch: the typed dataset under data, plus the treatment, the outcome, the confounders or the instrument, and the target the literature already measured. So an example can run the analysis and check itself against a known number.

load_* reads bundled or generated data and runs offline. The bundled CSVs derive from public-domain US government data (birthweight, pension) or are the authors' published replication data, which carry no explicit licence (smoking, germany); see the NOTICE for each source and its terms.

python
from ergodic.datasets import load_birthweight

ds = load_birthweight()
est = estimate_effect(graph, ds.data, ds.treatment, ds.outcome, treated=ds.treated)
assert abs(est.value - ds.target["value"]) < ds.target["tol"]

Bunch#

A dict whose keys are also attributes.

Every loader returns one of these. data holds the typed dataset; the rest is the causal question. Read it either way:

python
ds = load_birthweight()
ds.data         # the TabularData
ds.treatment    # "mbsmoke"
ds["outcome"]   # "bweight", the same as ds.outcome
ds.target       # {"value": ..., "tol": ..., "source": ...}

The keys vary by task. An adjustment dataset carries treatment, outcome, confounders, and target; a synthetic-control dataset carries treated and at; a discovery dataset carries the ground-truth target with its edges. Each loader's docstring lists its keys.

load_asia#

python
def load_asia(n: int = 3000, seed: int = 0) -> Bunch

The Asia chest-clinic network as sampled data with the true graph.

Parameter Description
n How many rows to draw.
seed The random seed; the draw is deterministic given n and seed.

Returns a Bunch with data (a TabularData of eight categorical columns) and target carrying the node names, the true edges, and a skeleton-recall floor. See the module description for the lesson.

load_berkeley#

python
def load_berkeley() -> Bunch

The Berkeley admissions table, expanded to one row per applicant.

Returns a Bunch with data (columns gender, dept, admit), treatment ("gender"), outcome ("admit"), treated ("Female"), confounders (("dept",)), and target carrying both the naive and the department-adjusted risk difference.

load_birthweight#

python
def load_birthweight() -> Bunch

Maternal smoking and infant birthweight, the textbook backdoor-adjustment set.

Returns a Bunch with data (a TabularData), treatment ("mbsmoke"), outcome ("bweight"), treated ("smoker"), confounders, and target.

load_earthquake#

python
def load_earthquake(n: int = 3000, seed: int = 0) -> Bunch

The burglar-alarm network as sampled data with the true graph.

Parameter Description
n How many rows to draw.
seed The random seed; the draw is deterministic given n and seed.

Returns a Bunch with data (five categorical columns) and target carrying the true v-structure. See the module description.

load_germany#

python
def load_germany() -> Bunch

German reunification: a second synthetic-control panel.

Returns a Bunch with data (a PanelData keyed by country and year), outcome ("gdp"), treated ("West Germany"), at (1990), and target.

load_pension401k#

python
def load_pension401k() -> Bunch

401(k) eligibility and wealth: adjustment, double ML, and an instrument in one table.

Returns a Bunch with data, treatment ("e401"), outcome ("net_tfa"), confounders, instrument ("e401"), participation ("p401", the endogenous treatment for the IV reading), and target.

load_smoking#

python
def load_smoking() -> Bunch

California Proposition 99: the canonical synthetic-control panel.

Returns a Bunch with data (a PanelData keyed by state and year), outcome ("cigsale"), treated ("California"), at (1989), and target.

Suggest an edit
Documentation

Search ergodic 0.2.0

Search ergodic by task, function or error.