SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2002.04083 · 2020

Estimating Counterfactual Treatment Outcomes over Time Through Adversarially Balanced Representations

arXiv · PDF · Open in the Atlas

Code that ran

3 of 7 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; 2 honoured the contract we drafted, 0 violated it and 1 has 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/2002.04083.json · badge: /api/ran/2002.04083.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
ioanabica/Counterfactual-Recurrent-Network canonical (classifier label)
classifier basis: census
3 ran · 4 no recorded run
FunctionStatusWhere it lives
calc_diameter Ran
ran, honoured the contract we drafted
ioanabica/Counterfactual-Recurrent-Network/utils/cancer_simulation.py
code served (permissive licence) · get_code("49da0ce0fcbb45b8")
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 numpy as np

def calc_diameter(volume):
    return (volume / (4.0 / 3.0 * np.pi)) ** (1.0 / 3.0) * 2.0

# The function takes a volume parameter and performs mathematical operations on it
# volume can be a scalar or numpy array
volume = np.array(100.0)

ARGS = {
    "volume": volume
}
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 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
calc_volume Ran
ran, honoured the contract we drafted
ioanabica/Counterfactual-Recurrent-Network/utils/cancer_simulation.py
code served (permissive licence) · get_code("b3ddbda44f74ad61")
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 numpy as np

# The function calc_volume takes a diameter parameter and computes sphere volume
# Reading the function body:
# - diameter is used in arithmetic operations (division, exponentiation)
# - It should be a numeric value (int, float, or numpy array)

# Create a simple numeric value for diameter
diameter = 5.0

ARGS = {
    "diameter": diameter
}
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 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
process_seq_data Ran
ran on a synthesized input
ioanabica/Counterfactual-Recurrent-Network/CRN_decoder_evaluate.py
code served (permissive licence) · get_code("6d0986a34107d942")
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 numpy as np

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

# Define dimensions
num_patients = 2
num_time_steps = 5
num_features = 4
state_dim = 3
previous_treatments_dim = 2
current_treatments_dim = 2
current_covariates_dim = 3
active_entries_dim = 1
projection_horizon = 3

# Create data_map with all required arrays
outputs = np.random.randn(num_patients, num_time_steps, num_features)
sequence_lengths = np.array([5, 4], dtype=np.int32)  # Two patients with different sequence lengths
active_entries = np.random.randint(0, 2, size=(num_patients, num_time_steps, active_entries_dim))
current_treatments = np.random.randn(num_patients, num_time_steps, current_treatments_dim)
previous_treatments = np.random.randn(num_patients, num_time_steps, previous_treatments_dim)
current_covariates = np.random.randn(num_patients, num_time_steps, current_covariates_dim)
output_means = np.random.randn(num_features)
output_stds = np.abs(np.random.randn(num_features)) + 0.1

data_map = {
    'outputs': outputs,
    'sequence_lengths': sequence_lengths,
    'active_entries': active_entries,
    'current_treatments': current_treatments,
    'previous_treatments': previous_treatments,
    'current_covariates': current_covariates,
    'output_means': output_means,
    'output_stds': output_stds,
}

# Create states array
states = np.random.randn(num_patients, num_time_steps, state_dim)

ARGS = {
    'data_map': data_map,
    'states': states,
    'projection_horizon': projection_horizon,
}
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 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
get_confounding_params Not yet run
unverified (harvested, no recorded run)
ioanabica/Counterfactual-Recurrent-Network/utils/cancer_simulation.py
code served (permissive licence) · get_code("15186e50c588f77d")
How it ran

no invocation recorded.

get_mse_at_follow_up_time Not yet run
unverified (harvested, no recorded run)
ioanabica/Counterfactual-Recurrent-Network/utils/evaluation_utils.py
code served (permissive licence) · get_code("f8b7195b5d9d50be")
How it ran

no invocation recorded.

get_processed_data Not yet run
unverified (harvested, no recorded run)
ioanabica/Counterfactual-Recurrent-Network/utils/evaluation_utils.py
code served (permissive licence) · get_code("786623c0bcd0335a")
How it ran

no invocation recorded.

process_counterfactual_seq_test_data Not yet run
unverified (harvested, no recorded run)
ioanabica/Counterfactual-Recurrent-Network/CRN_decoder_evaluate.py
code served (permissive licence) · get_code("51ca65759ce4ce19")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 4 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 4 later) and 3 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
calc_diameter 2 other papers
2 later
2206.08311 (2022-06)
Continuous-Time Modeling of Counterfactual Outcomes Using Neural Controlled Differential Equations
2306.04255 (2023-06)
Accounting For Informative Sampling When Learning to Forecast Treatment Outcomes Over Time
calc_volume 2 other papers
2 later
2206.08311 (2022-06)
Continuous-Time Modeling of Counterfactual Outcomes Using Neural Controlled Differential Equations
2306.04255 (2023-06)
Accounting For Informative Sampling When Learning to Forecast Treatment Outcomes Over Time
get_confounding_params 1 other paper
1 later
2206.08311 (2022-06)
Continuous-Time Modeling of Counterfactual Outcomes Using Neural Controlled Differential Equations
get_mse_at_follow_up_time 1 other paper
1 later
2202.11987 (2022-02)
Predicting the impact of treatments over time with uncertainty aware neural differential equations

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

Identifying when to give treatments to patients and how to select among multiple treatments over time are important medical problems with a few existing solutions. In this paper, we introduce the Counterfactual Recurrent Network (CRN), a novel sequence-to-sequence model that leverages the increasingly available patient observational data to estimate treatment effects over time and answer such medical questions. To handle the bias from time-varying confounders, covariates affecting the treatment assignment policy in the observational data, CRN uses domain adversarial training to build balancing representations of the patient history. At each timestep, CRN constructs a treatment invariant representation which removes the association between patient history and treatment assignments and thus can be reliably used for making counterfactual predictions. On a simulated model of tumour growth, with varying degree of time-dependent confounding, we show how our model achieves lower error in estimating counterfactuals and in choosing the correct treatment and timing of treatment than current state-of-the-art methods.

For agents

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

get_harvested_code_for_paper("2002.04083")
get_code_for_paper("2002.04083")
have("2002.04083")

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

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

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

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

Connect an agent — have() is free.