Skip to main content

Access the datasets and models from the causal chambers.

Project description

Welcome to the causalchamber package

PyPI version Downloads License: MIT

The Causal Chambers: (left) the wind tunnel, and (right) the light tunnel with the front panel removed to show its interior.

The causalchamber package gives you access to datasets, mechanistic models, and ground-truth graphs from the causal chamber project. See causalchamber.org for more details.

Download

You can install the package via pip, i.e. by typing

pip install causalchamber

in an appropriate shell.

Accessing the datasets

Datasets can be loaded directly into your Python code. For example, you can load the lt_camera_test_v1 image dataset as follows:

import causalchamber.datasets as datasets

# Download the dataset and store it, e.g., in the current directory
dataset = datasets.Dataset(name='lt_camera_test_v1', root='./', download=True)

# Select an experiment and load the observations and images
experiment = dataset.get_experiment(name='palette')
observations = experiment.as_pandas_dataframe()
images = experiment.as_image_array(size='200')

If download=True, the dataset will be downloaded and stored in the path provided by the root argument. If the dataset has already been downloaded it will not be downloaded again.

You can see what datasets are available at causalchamber.org or by typing:

datasets.list_available()

# Output:
# Available datasets (last changes on 2024-03-26):
# 
#   lt_camera_walks_v1
#   lt_test_v1
#   wt_intake_impulse_v1
#   lt_malus_v1
#   lt_camera_test_v1
#   wt_test_v1
# 
# Visit https://causalchamber.org for a detailed description of each dataset.

For the available experiments in each dataset, you can run:

dataset.available_experiments()

# Output:
# ['palette',
#  'polarizer_effect_bright',
#  'polarizer_effect_dark',
#  'pure_colors_bright',
#  'pure_colors_dark']

For the available image sizes (only in image datasets):

experiment.available_sizes()

# Output:
# ['200', '500', 'full']

Mechanistic models

The causalchamber package also contains Python implementations of the mechanistic models described in appendix IV of the original paper. The models follow the same nomenclature as in the paper, e.g., to import and run model A1 of the steady-state fan speed:

import numpy as np
from causalchamber.models import model_a1
model_a1(L=np.linspace(0,1,10), L_min=0.1, omega_max=314.15)

# Output:

# array([ 31.415     ,  34.90555556,  69.81111111, 104.71666667,
#        139.62222222, 174.52777778, 209.43333333, 244.33888889,
#        279.24444444, 314.15      ])

The implementations can be found in the src/causalchamber/models directory. You can find examples of using the models in the case_studies/mechanistic_models.ipynb notebook in the separate paper repository.

Causal ground-truth graphs

The graphs for the causal ground truths given in Fig. 3 of the original paper can be found as adjacency matrices in the ground_truths/ directory of the project repository. The adjacencies can also be loaded through the causalchamber package, e.g.,

from causalchamber.ground_truth import graph
graph(chamber="lt", configuration="standard")

# Output:

#              red  green  blue  osr_c  v_c  current  pol_1  pol_2  osr_angle_1  \
# red            0      0     0      0    0        1      0      0            0   
# green          0      0     0      0    0        1      0      0            0   
# blue           0      0     0      0    0        1      0      0            0   
# osr_c          0      0     0      0    0        1      0      0            0   

The chamber identifiers are wt,lt for the wind tunnel and light tunnel, respectively. To make it easier to plot graphs and reference them back to the original paper, the latex representation of each variable can be obtained by calling the latex_name function. For example, to obtain the latex representation $\theta_1$ of the pol_1 variable, you can run

from causalchamber.ground_truth import latex_name
latex_name('pol_1', enclose=True)

# Output:

# '$\\theta_1$'

Setting enclose=False will return the name without surrounding $.

Versioning

Non backward-compatible changes to the API are reflected by a change to the minor or major version number,

e.g. code that uses causalchamber==0.1.2 will run with causalchamber==0.1.3, but may not run with causalchamber==0.2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

causalchamber-0.1.1.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

causalchamber-0.1.1-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file causalchamber-0.1.1.tar.gz.

File metadata

  • Download URL: causalchamber-0.1.1.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.3

File hashes

Hashes for causalchamber-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aeb0e1f9a89a5ead08a9e1aff7e2b08fd4592c5ad0061cc04caecc074f39bb6c
MD5 31ac3e0d7cc1cf6a93c4f7d7ec8ac8b8
BLAKE2b-256 6927d1299a53802b257af902d680f55939ef805c5cd65984a2014f3ec9a87fea

See more details on using hashes here.

File details

Details for the file causalchamber-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for causalchamber-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a70cc418422f5ba3045684dc6da83aed82d3640e732a8dd866698dfddfaaa5ef
MD5 ac2848a9060d4d51d8505581521f2403
BLAKE2b-256 c089d93367bbb3ac7e1418b937028fbea46325d7e2d3c31c2f1238e5206724b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page