SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.01876 · ICML · 2023

Which Invariance Should We Transfer? A Causal Minimax Learning Approach

Yizhou Wang, Xinwei Sun, Mingzhou Liu, Xiangyu Zheng, Fang Fang

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 3 honoured the contract we drafted, 0 violated it and 4 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/2107.01876.json · badge: /api/ran/2107.01876.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
lmz123321/which_invariance canonical (classifier label)
classifier basis: classifier_2025
9 ran · 2 no recorded run
FunctionStatusWhere it lives
BaseSet Ran
ran on a synthesized input · constructed an object; no result was computed
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("8525b5bfafe1c30a")
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 an instance of its own class, BaseSet: the run constructed the object and did not call it, so no result was computed. 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 os
import pandas as pd
import tempfile
import shutil

torch.manual_seed(0)

# Create a temporary directory structure for test data
temp_dir = tempfile.mkdtemp()

# Create a training CSV file
train_data = {
    'node1': [1.0, 2.0],
    'node2': [3.0, 4.0],
    'node3': [5.0, 6.0],
    'E': [0.5, 0.7]
}
train_df = pd.DataFrame(train_data)
train_csv_path = os.path.join(temp_dir, 'train.csv')
train_df.to_csv(train_csv_path, index=False)

# Create a test folder with test CSV files
test_folder = os.path.join(temp_dir, 'train')
os.makedirs(test_folder, exist_ok=True)

test_data_1 = {
    'node1': [1.5, 2.5],
    'node2': [3.5, 4.5],
    'node3': [5.5, 6.5],
    'E': [0.6, 0.8]
}
test_df_1 = pd.DataFrame(test_data_1)
test_csv_path_1 = os.path.join(test_folder, 'test1.csv')
test_df_1.to_csv(test_csv_path_1, index=False)

test_data_2 = {
    'node1': [1.2, 2.2],
    'node2': [3.2, 4.2],
    'node3': [5.2, 6.2],
    'E': [0.55, 0.75]
}
test_df_2 = pd.DataFrame(test_data_2)
test_csv_path_2 = os.path.join(test_folder, 'test2.csv')
test_df_2.to_csv(test_csv_path_2, index=False)

# Create parser config
parser = {
    'X_S': 3,
    'X_M': 2,
    'X_dostar': True
}

ARGS = {
    'trainsplit': 'train',
    'path': temp_dir,
    'parser': parser,
    'need_norm': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BaseSet — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BaseSet 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
EarlyStopping Ran
ran on a synthesized input · constructed an object; no result was computed
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("3efc81b90aa688b0")
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 an instance of its own class, EarlyStopping: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

ARGS = {
    "patience": 3,
    "min_delta": 0.01,
    "verbose": True,
}
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 EarlyStopping — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a EarlyStopping 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
NonLinearF Ran
ran on a synthesized input · constructed an object; no result was computed
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("42a16c34a54474ad")
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 an instance of its own class, NonLinearF: the run constructed the object and did not call it, so no result was computed. 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 torch.nn as nn
import pandas as pd
import numpy as np

torch.manual_seed(0)

# Create minimal valid arguments for NonLinearF.__init__
ARGS = {
    'in_dim': 4,
    'baseinit': True,
    'hidden': 8,
    'out_dim': 1,
    'nonlin': True,
    'patience': 10,
    'min_delta': 0.01,
    'verbose': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type NonLinearF — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a NonLinearF 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
StEq Ran
ran on a synthesized input · constructed an object; no result was computed
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("0ce589516bdf4ef9")
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 an instance of its own class, StEq: the run constructed the object and did not call it, so no result was computed. 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
import pandas as pd

torch.manual_seed(0)

# Define a simple nonlinear function
def simple_nonlin(x):
    return torch.sin(x)

# Define linear parameters
lin_params = [0.5, -0.3, 0.2, 0.1]

ARGS = {
    "nonlin": simple_nonlin,
    "lin": lin_params
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type StEq — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a StEq 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
concat Ran
ran, honoured the contract we drafted
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("33d995585c147c9b")
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 2, dtype family float, shape (2, 12) 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

torch.manual_seed(0)

# Create a dictionary with tensor values to concatenate along dim=1
dic = {
    'tensor_a': torch.randn(2, 4),  # batch=2, features=4
    'tensor_b': torch.randn(2, 3),  # batch=2, features=3
    'tensor_c': torch.randn(2, 5),  # batch=2, features=5
}

# Create a list of keys to concatenate
keys = ['tensor_a', 'tensor_b', 'tensor_c']

ARGS = {
    'dic': dic,
    'keys': keys,
}
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 2, dtype family float, shape (2, 12) — shape (2, 12) 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
dfTotensor Ran
ran; our contract draft was wrong, not the code
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("e4ac4ec9482c424f")
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 2, dtype family float, shape (2, 4) 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 pandas as pd
import numpy as np

torch.manual_seed(0)

# Create a small DataFrame with numeric data
df = pd.DataFrame({
    'col1': [1.0, 2.0],
    'col2': [3.0, 4.0],
    'col3': [5.0, 6.0],
    'col4': [7.0, 8.0]
})

ARGS = {
    'df': df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
order Ran
ran, honoured the contract we drafted
lmz123321/which_invariance/causal_discovery/causal_discovery.py
code served (permissive licence) · get_code("fee338106eb0430c")
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) and returned int, ndim 0, dtype family int, 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

torch.manual_seed(0)

ARGS = {
    'string': 'X1',
    'maxnum': 2000
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, 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
regularizer Ran
ran, honoured the contract we drafted
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("a19bab3200fcd75c")
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)

# Build a minimal model that has named_parameters with 'weight' in the name
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
        self.bias_only = nn.Parameter(torch.randn(2))
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    'model': model,
    'lamb': 0.01,
    'p': 2,
    'items': ['weight']
}
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
sort_topology Ran
ran; our contract draft was wrong, not the code
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("8db73106e0f2c5b7")
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
from copy import deepcopy

# Construct arguments for sort_topology function
ARGS = {
    'llist': ['X1', 'X3'],
    'order': ['Y', 'X3', 'X1', 'X2']
}
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 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
OptSet Not yet run
unverified (harvested, no recorded run)
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("04f9916e300a43a2")
How it ran

no invocation recorded.

_weightcut Not yet run
unverified (harvested, no recorded run)
lmz123321/which_invariance/findoptset/findoptset.py
code served (permissive licence) · get_code("d1540a9de04fa0fc")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 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.

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

A major barrier to deploying current machine learning models lies in their non-reliability to dataset shifts. To resolve this problem, most existing studies attempted to transfer stable information to unseen environments. Particularly, independent causal mechanisms-based methods proposed to remove mutable causal mechanisms via the do-operator. Compared to previous methods, the obtained stable predictors are more effective in identifying stable information. However, a key question remains: which subset of this whole stable information should the model transfer, in order to achieve optimal generalization ability? To answer this question, we present a comprehensive minimax analysis from a causal perspective. Specifically, we first provide a graphical condition for the whole stable set to be optimal. When this condition fails, we surprisingly find with an example that this whole stable set, although can fully exploit stable information, is not the optimal one to transfer. To identify the optimal subset under this case, we propose to estimate the worst-case risk with a novel optimization scheme over the intervention functions on mutable causal mechanisms. We then propose an efficient algorithm to search for the subset with minimal worst-case risk, based on a newly defined equivalence relation between stable subsets. Compared to the exponential cost of exhaustively searching over all subsets, our searching strategy enjoys a polynomial complexity. The effectiveness and efficiency of our methods are demonstrated on synthetic data and the diagnosis of Alzheimer's disease.

For agents

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

get_harvested_code_for_paper("2107.01876")
get_code_for_paper("2107.01876")
have("2107.01876")

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

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

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

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

Connect an agent — have() is free.