SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1507.05333 · 2015

Invariant Models for Causal Transfer Learning

arXiv · PDF · Open in the Atlas

Code that ran

8 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; 0 failures of our instrument; 4 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/1507.05333.json · badge: /api/ran/1507.05333.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
mrojascarulla/causal_transfer_learning canonical (classifier label)
classifier basis: census
8 ran · 4 no recorded run
FunctionStatusWhere it lives
e_step Ran
ran on a synthesized input
mrojascarulla/causal_transfer_learning/code/fiml.py
code served (permissive licence) · get_code("8bbf168e221a76ce")
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 ndarray, ndim 2, dtype family float, shape (4, 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 autograd.numpy as np

# Set seed for reproducibility
np.random.seed(0)

# Create small test data
n_samples = 2  # number of samples
n_features = 4  # number of features

# X: data matrix with some missing values (marked by mask)
X = np.random.randn(n_samples, n_features).astype(float)

# mask_var: boolean mask for which variables/features are observed
# True means the variable has missing data that needs imputation
mask_var = np.array([True, False, True, False])

# mask_samp: boolean mask for which samples have missing data
# False means the sample has some missing values
mask_samp = np.array([False, True])

# sigma: covariance matrix (features x features)
sigma = np.random.randn(n_features, n_features)
sigma = sigma @ sigma.T  # ensure it's positive semi-definite
sigma = sigma.astype(float)

# n_ul: number of unlabeled samples (optional, default 0)
n_ul = 0

ARGS = {
    'sigma': sigma,
    'X': X,
    'mask_var': mask_var,
    'mask_samp': mask_samp,
    'n_ul': n_ul,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
autograd — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (4, 4) — shape (4, 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
fiml Ran
ran on a synthesized input
mrojascarulla/causal_transfer_learning/code/fiml.py
code served (permissive licence) · get_code("d4e73aa9e9c57cb9")
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 float64, ndim 0, 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 autograd.numpy as np

# Set seed for reproducibility
np.random.seed(0)

# Parameters based on function signature and usage:
# - sigma_chol: will be reshaped to (n_predictors + 1, n_predictors + 1)
# - n_predictors: integer, number of predictors
# - mask: boolean array for test set selection
# - mask_var: boolean array for missing variables
# - X: array of shape (n_samples, n_predictors)
# - Y: array of shape (n_samples, 1)
# - sub: array of indices for subsetting sigma
# - n_ul: integer, number of unlabeled samples
# - print_val: boolean

n_predictors = 3
n_samples = 6
n_ul = 2

# Create sigma_chol: flatten it to a vector that will be reshaped to (4, 4)
sigma_chol = np.random.randn((n_predictors + 1) * (n_predictors + 1))

# Create mask: boolean array to select test set (True = test, False = train)
mask = np.array([True, False, True, False, True, False])

# Create mask_var: boolean array for missing variables
# Shape should be compatible with indexing sigma
mask_var = np.array([False, True, False, True])

# Create X: predictor matrix (n_samples, n_predictors)
X = np.random.randn(n_samples, n_predictors)

# Create Y: outcome vector (n_samples, 1)
Y = np.random.randn(n_samples, 1)

# Create sub: array of indices for subsetting sigma
# This is used as sigma[sub].T[sub].T, so it should be valid indices
sub = np.array([0, 1, 2, 3])

ARGS = {
    'sigma_chol': sigma_chol,
    'n_predictors': n_predictors,
    'mask': mask,
    'mask_var': mask_var,
    'X': X,
    'Y': Y,
    'sub': sub,
    'n_ul': n_ul,
    'print_val': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
autograd — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
gen_gauss Ran
ran on a synthesized input
mrojascarulla/causal_transfer_learning/code/data.py
code served (permissive licence) · get_code("67eb7cc91edcbeac")
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 ndarray, 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 numpy as np

np.random.seed(0)

# Parameters for gen_gauss function
mu = np.array([0.0, 1.0, 2.0, 3.0])  # mean vector, dimension 4
sigma = np.array([
    [1.0, 0.1, 0.0, 0.0],
    [0.1, 1.0, 0.1, 0.0],
    [0.0, 0.1, 1.0, 0.1],
    [0.0, 0.0, 0.1, 1.0]
])  # covariance matrix, 4x4
n = 2  # number of samples

ARGS = {
    "mu": mu,
    "sigma": sigma,
    "n": n
}
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 ndarray, 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
lasso_alpha_search_synt Ran
ran on a synthesized input
mrojascarulla/causal_transfer_learning/code/utils.py
code served (permissive licence) · get_code("62b9f74e4c789a05")
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 ndarray, ndim 1, dtype family float, shape (15,) 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 numpy as np
from sklearn import linear_model

# Create small synthetic data
np.random.seed(0)
n_samples = 10
n_features = 15

# X: n_samples x n_features matrix
X = np.random.randn(n_samples, n_features)

# Y: n_samples x 1 matrix (or 1D array)
Y = np.random.randn(n_samples, 1)

ARGS = {
    "X": X,
    "Y": Y
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (15,) — shape (15,) 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
linear Ran
ran on a synthesized input
mrojascarulla/causal_transfer_learning/code/data.py
code served (permissive licence) · get_code("1c399c604c58deaa")
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 numpy as np

torch.manual_seed(0)

# X is a tensor that gets multiplied by alphaC (a scalar parameter)
X = torch.randn(2, 4)

# params is a list/tuple where params[0] is alphaC (a scalar)
alphaC = 2.5
params = [alphaC]

ARGS = {
    'X': X,
    'params': params
}
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 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
np_getDistances Ran
ran on a synthesized input
mrojascarulla/causal_transfer_learning/code/utils.py
code served (permissive licence) · get_code("12c198326df3b153")
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 ndarray, ndim 2, dtype family float, shape (2, 3) 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 numpy as np

# Analyze the function:
# - x: indexed with x[:, :, np.newaxis], so needs shape (batch, features, 1) after newaxis
#   This means x should be shape (batch, features)
# - y: accessed with y.T, so needs to be 2D
# - K = x[:, :, np.newaxis] - y.T broadcasts to (batch, features, y_features)
# - np.linalg.norm(K, axis=1) returns shape (batch, y_features)

# Create small distinct-sized arrays
x = np.random.randn(2, 4)  # shape (2, 4) - batch_size=2, features=4
y = np.random.randn(3, 4)  # shape (3, 4) - different number of samples, same features

ARGS = {
    "x": x,
    "y": y
}
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 ndarray, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) 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
split_train_valid Ran
ran on a synthesized input
mrojascarulla/causal_transfer_learning/code/utils.py
code served (permissive licence) · get_code("9a4a5ad0cdbe551f")
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

# Construct small example data for split_train_valid
# The function expects:
# - x: feature array
# - y: label array
# - n_ex: array of example counts per task
# - valid_split: float (has default 0.1)

# Create 3 tasks with different numbers of examples
task_1_examples = 10
task_2_examples = 8
task_3_examples = 12

n_ex = np.array([task_1_examples, task_2_examples, task_3_examples])
total_examples = np.sum(n_ex)

# Create feature and label arrays
# x shape: (total_examples, feature_dim)
# y shape: (total_examples,) or (total_examples, 1)
x = np.random.randn(total_examples, 4).astype(np.float32)
y = np.random.randint(0, 2, size=total_examples).astype(np.int32)

ARGS = {
    "x": x,
    "y": y,
    "n_ex": n_ex,
    "valid_split": 0.1
}
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
zero Ran
ran on a synthesized input
mrojascarulla/causal_transfer_learning/code/data.py
code served (permissive licence) · get_code("b1e26fe487284e3b")
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 float, 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)

# The function zero(X, params) returns 0.0 regardless of inputs
# X could be a tensor or array-like
# params could be a dict, model, or other object

X = torch.randn(2, 4)
params = {}

ARGS = {
    "X": X,
    "params": params,
}
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 float, 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
mDA Not yet run
unverified (harvested, no recorded run)
mrojascarulla/causal_transfer_learning/code/mSDA.py
code served (permissive licence) · get_code("f7ae7be6a4cbf2c7")
How it ran

no invocation recorded.

mSDA Not yet run
unverified (harvested, no recorded run)
mrojascarulla/causal_transfer_learning/code/mSDA.py
code served (permissive licence) · get_code("919abc05c283859b")
How it ran

no invocation recorded.

mSDA_features Not yet run
unverified (harvested, no recorded run)
mrojascarulla/causal_transfer_learning/code/mSDA.py
code served (permissive licence) · get_code("a2297c2abae471d1")
How it ran

no invocation recorded.

m_step Not yet run
unverified (harvested, no recorded run)
mrojascarulla/causal_transfer_learning/code/fiml.py
code served (permissive licence) · get_code("473d2801c6c54c6c")
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, 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 12 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

Methods of transfer learning try to combine knowledge from several related tasks (or domains) to improve performance on a test task. Inspired by causal methodology, we relax the usual covariate shift assumption and assume that it holds true for a subset of predictor variables: the conditional distribution of the target variable given this subset of predictors is invariant over all tasks. We show how this assumption can be motivated from ideas in the field of causality. We focus on the problem of Domain Generalization, in which no examples from the test task are observed. We prove that in an adversarial setting using this subset for prediction is optimal in Domain Generalization; we further provide examples, in which the tasks are sufficiently diverse and the estimator therefore outperforms pooling the data, even on average. If examples from the test task are available, we also provide a method to transfer knowledge from the training tasks and exploit all available features for prediction. However, we provide no guarantees for this method. We introduce a practical method which allows for automatic inference of the above subset and provide corresponding code. We present results on synthetic data sets and a gene deletion data set.

For agents

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

get_harvested_code_for_paper("1507.05333")
get_code_for_paper("1507.05333")
have("1507.05333")

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

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

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

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

Connect an agent — have() is free.