SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2212.10847 · 2022

VCNet: A self-explaining model for realistic counterfactual generation

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 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 6 have no contract verdict; 0 failures of our instrument; 4 no recorded run), measured 2026-11-23; 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/2212.10847.json · badge: /api/ran/2212.10847.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
Orange-OpenSource/carla_croco_vcnet canonical (classifier label)
classifier basis not recorded on the link
6 ran · 4 no recorded run
FunctionStatusWhere it lives
cat_normalize Ran
ran on a synthesized input
Orange-OpenSource/carla_croco_vcnet/carla/self_explaining_model/catalog/vcnet/library/utils.py
code served (permissive licence) · get_code("5ad5d0944ec31447")
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
import torch.nn.functional as F

torch.manual_seed(0)

# Create a batch of continuous and categorical data
# The tensor has shape (batch_size=2, total_features)
# First cont_shape columns are continuous, rest are categorical
batch_size = 2
cont_shape = 3
cat_features_1 = 4
cat_features_2 = 5
total_features = cont_shape + cat_features_1 + cat_features_2

c = torch.randn(batch_size, total_features)

# cat_arrays: list of arrays representing categorical feature groups
# Each inner array represents the one-hot encoded options for that categorical variable
cat_arrays = [
    [0, 1, 2, 3],           # First categorical variable with 4 options
    [0, 1, 2, 3, 4]         # Second categorical variable with 5 options
]

# cat_idx: starting index for categorical features in the tensor
cat_idx = cont_shape

# cont_shape: number of continuous features at the start
cont_shape = cont_shape

# hard: whether to use hard discretization
hard = False

# used_carla: whether to use CARLA-specific processing (sigmoid) vs standard softmax
used_carla = True

ARGS = {
    "c": c,
    "cat_arrays": cat_arrays,
    "cat_idx": cat_idx,
    "cont_shape": cont_shape,
    "hard": hard,
    "used_carla": used_carla
}
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
int_round_dataset Ran
ran on a synthesized input
Orange-OpenSource/carla_croco_vcnet/carla/self_explaining_model/catalog/vcnet/library/utils.py
code served (permissive licence) · get_code("8b3abecc77b71942")
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 DataFrame. 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 pandas as pd
import numpy as np

# Create a simple dataset using pandas DataFrame
dataset = pd.DataFrame({
    'price': [10.456, 20.789, 30.123],
    'discount': [5.678, 15.234, 25.890],
    'rating': [4.5678, 3.2345, 4.9876]
})

# Create a dictionary mapping column names to number of decimal places
dico_round = {
    'price': 2,
    'discount': 1,
    'rating': 3
}

ARGS = {
    'dataset': dataset,
    'dico_round': dico_round
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
perturb_sample Ran
ran on a synthesized input
Orange-OpenSource/carla_croco_vcnet/carla/evaluation/robustness_metrics.py
code served (permissive licence) · get_code("07e37d41ea7bce74")
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
from torch.distributions.multivariate_normal import MultivariateNormal
from torch.distributions import Uniform

torch.manual_seed(0)

# Create a small sample tensor with shape (1, 4) - batch of 1, dimension 4
x = torch.randn(1, 4)

# Parameters for the function
n_samples = 2
sigma2 = 0.1
distrib = 'gaussian'

ARGS = {
    'x': x,
    'n_samples': n_samples,
    'sigma2': sigma2,
    'distrib': distrib
}
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 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
perturb_sample_gaussian Ran
ran on a synthesized input
Orange-OpenSource/carla_croco_vcnet/carla/evaluation/robustness_metrics.py
code served (permissive licence) · get_code("6bb4672b81a18f29")
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
from torch.distributions.multivariate_normal import MultivariateNormal

torch.manual_seed(0)

# Create a small sample tensor: shape (1, 4) - batch of 1, dimension 4
x = torch.randn(1, 4)

# Number of samples to generate
n_samples = 2

# Variance parameter for the Gaussian perturbation
sigma2 = 0.1

ARGS = {
    "x": x,
    "n_samples": n_samples,
    "sigma2": sigma2
}
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 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
perturb_sample_uniform Ran
ran on a synthesized input
Orange-OpenSource/carla_croco_vcnet/carla/evaluation/robustness_metrics.py
code served (permissive licence) · get_code("565236516cde7f18")
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
from torch.distributions import Uniform

torch.manual_seed(0)

# Create a small sample tensor (batch size 1, dimension 4)
x = torch.randn(1, 4)

# Number of samples to generate
n_samples = 2

# Sigma2 parameter for uniform distribution bounds
sigma2 = 0.5

ARGS = {
    "x": x,
    "n_samples": n_samples,
    "sigma2": sigma2,
}
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 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
remove_nans Ran
ran on a synthesized input
Orange-OpenSource/carla_croco_vcnet/carla/evaluation/process_nans.py
code served (permissive licence) · get_code("94cef7815945f3ca")
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, ndim 3, 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 pandas as pd
import numpy as np

# Create sample DataFrames for counterfactuals and factuals
# counterfactuals: DataFrame with some NaN values
counterfactuals_data = {
    'feature_1': [1.0, 2.0, np.nan, 4.0],
    'feature_2': [5.0, 6.0, 7.0, 8.0],
    'feature_3': [9.0, np.nan, 11.0, 12.0]
}
counterfactuals = pd.DataFrame(counterfactuals_data)

# factuals: DataFrame with same shape as counterfactuals, no NaNs
factuals_data = {
    'feature_1': [0.1, 0.2, 0.3, 0.4],
    'feature_2': [0.5, 0.6, 0.7, 0.8],
    'feature_3': [0.9, 1.0, 1.1, 1.2]
}
factuals = pd.DataFrame(factuals_data)

ARGS = {
    'counterfactuals': counterfactuals,
    'factuals': factuals
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, dtype family float — a tuple 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
load_json Not yet run
unverified (harvested, no recorded run)
Orange-OpenSource/carla_croco_vcnet/carla/self_explaining_model/catalog/vcnet/library/utils.py
code served (permissive licence) · get_code("934c3e9b8141d431")
How it ran

no invocation recorded.

reparametrization_trick Not yet run
unverified (harvested, no recorded run)
Orange-OpenSource/carla_croco_vcnet/carla/recourse_methods/catalog/croco/library/croco.py
code served (permissive licence) · get_code("c37a3f324b04124c")
How it ran

no invocation recorded.

reparametrization_trick_gaussian Not yet run
unverified (harvested, no recorded run)
Orange-OpenSource/carla_croco_vcnet/carla/recourse_methods/catalog/croco/library/croco.py
code served (permissive licence) · get_code("85bc5d90f2a78ca5")
How it ran

no invocation recorded.

reparametrization_trick_uniform Not yet run
unverified (harvested, no recorded run)
Orange-OpenSource/carla_croco_vcnet/carla/recourse_methods/catalog/croco/library/croco.py
code served (permissive licence) · get_code("eb844a32fb77d424")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 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 8 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
load_json 1 other paper
1 dated earlier
2206.00700 (2022-06)
RoCourseNet: Distributionally Robust Training of a Prediction Aware Recourse Model
remove_nans 1 other paper
1 dated earlier
2108.00783 (2021-08)
CARLA: A Python Library to Benchmark Algorithmic Recourse and Counterfactual Explanation Algorithms

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-23.

Repositories linked to this paper

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

Abstract

Counterfactual explanation is a common class of methods to make local explanations of machine learning decisions. For a given instance, these methods aim to find the smallest modification of feature values that changes the predicted decision made by a machine learning model. One of the challenges of counterfactual explanation is the efficient generation of realistic counterfactuals. To address this challenge, we propose VCNet-Variational Counter Net-a model architecture that combines a predictor and a counterfactual generator that are jointly trained, for regression or classification tasks. VCNet is able to both generate predictions, and to generate counterfactual explanations without having to solve another minimisation problem. Our contribution is the generation of counterfactuals that are close to the distribution of the predicted class. This is done by learning a variational autoencoder conditionally to the output of the predictor in a join-training fashion. We present an empirical evaluation on tabular datasets and across several interpretability metrics. The results are competitive with the state-of-the-art method.

For agents

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

get_harvested_code_for_paper("2212.10847")
get_code_for_paper("2212.10847")
have("2212.10847")

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

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

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

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

Connect an agent — have() is free.