SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2109.11990 · 2021

Optimization-based Causal Estimation from Heterogenous Environments

arXiv · PDF · Open in the Atlas

Code that ran

10 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 8 have no contract verdict; 2 failures of our instrument; 2 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2109.11990.json · badge: /api/ran/2109.11990.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
mingzhang-yin/coco canonical (classifier label)
classifier basis: census
10 ran · 2 no recorded run
FunctionStatusWhere it lives
datagen Ran
ran on a synthesized input
mingzhang-yin/coco/src/exp_gmm/data.py
code served (permissive licence) · get_code("cebc74b1a660643e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

class Args:
    def __init__(self):
        self.K = 3
        self.N = 5
        self.spurious = True
        self.sigma = 0.5

# Create a small sudo matrix with shape [K, num_spurious_features]
sudo = np.random.randn(3, 2)

# Fraction for spurious correlation
frac = 0.4

args = Args()

ARGS = {
    'sudo': sudo,
    'frac': frac,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
example1 Ran
ran on a synthesized input
mingzhang-yin/coco/src/exp_dags/dag.py
code served (permissive licence) · get_code("18c210d7584811b4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import torch

torch.manual_seed(0)
np.random.seed(0)

ARGS = {
    "e": 1,
    "N": 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
example2 Ran
ran on a synthesized input
mingzhang-yin/coco/src/exp_dags/dag.py
code served (permissive licence) · get_code("62cea8ecb21544e8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import torch
from torch import distributions as td

torch.manual_seed(0)

ARGS = {
    "e": 1,
    "N": 10
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
example3 Ran
ran on a synthesized input
mingzhang-yin/coco/src/exp_dags/dag.py
code served (permissive licence) · get_code("072ef3112734eafb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from torch import distributions as td

torch.manual_seed(0)

ARGS = {
    "e": 0.5,
    "N": 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_classes Ran
ran on a synthesized input
mingzhang-yin/coco/src/exp_animal/dataset.py
code served (permissive licence) · get_code("9d0a9b1a4baec938")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import shutil

# Create a temporary directory structure with jpg files
temp_dir = tempfile.mkdtemp()
test_subdir = os.path.join(temp_dir, 'test_class')
os.makedirs(test_subdir, exist_ok=True)

# Create some dummy jpg files
with open(os.path.join(test_subdir, 'image1.jpg'), 'w') as f:
    f.write('dummy')
with open(os.path.join(test_subdir, 'image2.jpg'), 'w') as f:
    f.write('dummy')

# Also add a non-jpg file to ensure filtering works
with open(os.path.join(test_subdir, 'readme.txt'), 'w') as f:
    f.write('not an image')

ARGS = {
    'root_dir': temp_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
index_classes Ran
ran on a synthesized input
mingzhang-yin/coco/src/exp_animal/dataset.py
code served (permissive licence) · get_code("9efe3b3f8212845b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function index_classes expects items to be an iterable where each item
# is indexable with [1] to get a class label. It builds a dictionary mapping
# class labels to indices.

items = [
    ("sample1", "class_a"),
    ("sample2", "class_b"),
    ("sample3", "class_a"),
    ("sample4", "class_c"),
]

ARGS = {
    "items": items
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
make_environment Ran
ran on a synthesized input
mingzhang-yin/coco/src/exp_mnist/aux.py
code served (permissive licence) · get_code("030d5dc9e3dc97f0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small dummy images: batch_size=2, 28x28 grayscale
images = torch.randint(0, 256, (2, 28, 28), dtype=torch.uint8).float()

# Create small dummy labels: batch_size=2
labels = torch.tensor([3.0, 7.0])

# Environment parameter (controls correlation strength)
e = 0.5

ARGS = {
    'images': images,
    'labels': labels,
    'e': e
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
mean_accuracy Ran
ran; our contract draft was wrong, not the code
mingzhang-yin/coco/src/exp_mnist/aux.py
pointer only (licence: MIT); the stored copy get_code serves, from ahujak/IB-IRM, is pointer only (licence: NONE) · get_code("cbb762a6632ddabc")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from ahujak/IB-IRM, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

mean_nll Ran
ran; our contract draft was wrong, not the code
mingzhang-yin/coco/src/exp_mnist/aux.py
code served (permissive licence) · get_code("9b0756cbeccc505d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create small tensors for logits and labels
# logits: model output before sigmoid, shape (batch_size, num_classes)
# y: binary labels, shape (batch_size, num_classes)
batch_size = 2
num_classes = 4

logits = torch.randn(batch_size, num_classes)
y = torch.randint(0, 2, (batch_size, num_classes)).float()

ARGS = {
    "logits": logits,
    "y": y,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
testing Ran
ran on a synthesized input
mingzhang-yin/coco/src/exp_gmm/data.py
code served (permissive licence) · get_code("b4c3341e5a6b862d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import torch
import torch.nn as nn

torch.manual_seed(0)
np.random.seed(0)

class SimpleNet(nn.Module):
    def __init__(self, input_dim, num_classes):
        super(SimpleNet, self).__init__()
        self.fc1 = nn.Linear(input_dim, 16)
        self.fc2 = nn.Linear(16, num_classes)
    
    def forward(self, x):
        x = x.float()
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

class ArgsConfig:
    def __init__(self, K, N, spurious, sigma):
        self.K = K
        self.N = N
        self.spurious = spurious
        self.sigma = sigma

K = 4
N = 2
spurious = True
sigma = 0.5

args = ArgsConfig(K=K, N=N, spurious=spurious, sigma=sigma)

input_dim = K + (K // 2 + 1) if spurious else K
net = SimpleNet(input_dim=input_dim, num_classes=K)

ARGS = {
    'net': net,
    'args': args,
    'T': 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_dataset Not yet run
unverified (harvested, no recorded run)
mingzhang-yin/coco/src/exp_animal/dataset.py
code served (permissive licence) · get_code("a78439d89cf64d26")
How it ran

no invocation recorded.

training_eval Not yet run
unverified (harvested, no recorded run)
mingzhang-yin/coco/src/exp_gmm/data.py
code served (permissive licence) · get_code("3dd50fde538cefaf")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 10 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
mean_accuracy 1 other paper
1 dated earlier
2106.06607 (2021-06)
Invariance Principle Meets Information Bottleneck for Out-of-Distribution Generalization
mean_nll 1 other paper
1 dated earlier
2106.06607 (2021-06)
Invariance Principle Meets Information Bottleneck for Out-of-Distribution Generalization

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

This paper presents a new optimization approach to causal estimation. Given data that contains covariates and an outcome, which covariates are causes of the outcome, and what is the strength of the causality? In classical machine learning (ML), the goal of optimization is to maximize predictive accuracy. However, some covariates might exhibit a non-causal association with the outcome. Such spurious associations provide predictive power for classical ML, but they prevent us from causally interpreting the result. This paper proposes CoCo, an optimization algorithm that bridges the gap between pure prediction and causal inference. CoCo leverages the recently-proposed idea of environments, datasets of covariates/response where the causal relationships remain invariant but where the distribution of the covariates changes from environment to environment. Given datasets from multiple environments-and ones that exhibit sufficient heterogeneity-CoCo maximizes an objective for which the only solution is the causal solution. We describe the theoretical foundations of this approach and demonstrate its effectiveness on simulated and real datasets. Compared to classical ML and existing methods, CoCo provides more accurate estimates of the causal model and more accurate predictions under interventions.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2109.11990")
get_code_for_paper("2109.11990")
have("2109.11990")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2109.11990.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2109.11990.svg)](https://syntology.ai/paper/2109.11990)

Connect an agent — have() is free.