SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2108.00783 · NeurIPS · 2021

CARLA: A Python Library to Benchmark Algorithmic Recourse and Counterfactual Explanation Algorithms

Martin Pawelczyk, Sascha Bielawski, Johannes Van Den Heuvel, Tobias Richter, Gjergji Kasneci

arXiv · PDF · Open in the Atlas

Code that ran

4 of 8 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 4 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/2108.00783.json · badge: /api/ran/2108.00783.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
indyfree/CARLA canonical (classifier label)
classifier basis: census
4 ran · 4 no recorded run
FunctionStatusWhere it lives
logistic_function Ran
ran on a synthesized input
indyfree/CARLA/carla/models/catalog/parse_xgboost.py
code served (permissive licence) · get_code("454cbfa6263a3d56")
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 (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

# The logistic_function takes a single parameter 'x' which should be a numeric value or array
# The function computes 1 / (1 + np.exp(-x))

# Create a small numpy array as input
x_value = np.array([0.5, -1.2, 2.3, -0.8])

ARGS = {
    "x": x_value
}
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 1, dtype family float, shape (4,) — shape (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
predict_label Ran
ran on a synthesized input
indyfree/CARLA/carla/models/negative_instances/predict.py
code served (permissive licence) · get_code("5045a097ab96a95f")
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, 1) 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
import pandas as pd
from typing import Any

torch_manual_seed = 0

class SimpleModel:
    """Minimal model with a predict method that returns predictions."""
    
    def predict(self, df: pd.DataFrame) -> np.ndarray:
        """Return predictions as a 2D numpy array (batch_size x 1)."""
        # Return probability-like values between 0 and 1
        n_samples = len(df)
        return np.random.rand(n_samples, 1)

# Create a small DataFrame with 2 rows and 4 columns
df = pd.DataFrame({
    'feat_0': [1.0, 2.0],
    'feat_1': [3.0, 4.0],
    'feat_2': [5.0, 6.0],
    'feat_3': [7.0, 8.0]
})

# Create model instance
model = SimpleModel()

ARGS = {
    'model': model,
    'df': df,
    'as_prob': False
}
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 ndarray, ndim 2, dtype family float, shape (2, 1) — shape (2, 1) 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
predict_negative_instances Ran
ran on a synthesized input
indyfree/CARLA/carla/models/negative_instances/predict.py
code served (permissive licence) · get_code("693981f8240930fa")
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 torch
import torch.nn as nn
import numpy as np
import pandas as pd


class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 1)
    
    def predict(self, df):
        """Convert DataFrame to tensor, pass through model, return numpy predictions"""
        X = torch.FloatTensor(df.values)
        with torch.no_grad():
            output = self.linear(X)
        return output.numpy()


torch.manual_seed(0)

# Create a simple model
model = SimpleModel()

# Create a DataFrame with 2 samples and 4 features
df = pd.DataFrame({
    'feature_0': [0.1, 0.2],
    'feature_1': [0.3, 0.4],
    'feature_2': [0.5, 0.6],
    'feature_3': [0.7, 0.8]
})

ARGS = {
    'model': model,
    'data': 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 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
remove_nans Ran
ran on a synthesized input
indyfree/CARLA/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
get_models_home Not yet run
unverified (harvested, no recorded run)
indyfree/CARLA/carla/models/catalog/load_model.py
code served (permissive licence) · get_code("5b72258632321738")
How it ran

no invocation recorded.

load_online_model Not yet run
unverified (harvested, no recorded run)
indyfree/CARLA/carla/models/catalog/load_model.py
code served (permissive licence) · get_code("142ef8036899df58")
How it ran

no invocation recorded.

load_trained_model Not yet run
unverified (harvested, no recorded run)
indyfree/CARLA/carla/models/catalog/load_model.py
code served (permissive licence) · get_code("a86c4a61b987d962")
How it ran

no invocation recorded.

parse_booster Not yet run
unverified (harvested, no recorded run)
indyfree/CARLA/carla/models/catalog/parse_xgboost.py
code served (permissive licence) · get_code("bd9c836dd3c45c49")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 2 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 2 later) and 6 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
get_models_home 1 other paper
1 later
2203.06768 (2022-03)
Probabilistically Robust Recourse: Navigating the Trade-offs between Costs and Robustness in Algorithmic Recourse
remove_nans 1 other paper
1 later
2212.10847 (2022-12)
VCNet: A self-explaining model for realistic counterfactual generation

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

Counterfactual explanations provide means for prescriptive model explanations by suggesting actionable feature changes (e.g., increase income) that allow individuals to achieve favourable outcomes in the future (e.g., insurance approval). Choosing an appropriate method is a crucial aspect for meaningful counterfactual explanations. As documented in recent reviews, there exists a quickly growing literature with available methods. Yet, in the absence of widely available open-source implementations, the decision in favour of certain models is primarily based on what is readily available. Going forward -to guarantee meaningful comparisons across explanation methods -we present CARLA (Counterfactual And Recourse LibrAry), a python library for benchmarking counterfactual explanation methods across both different data sets and different machine learning models. In summary, our work provides the following contributions: (i) an extensive benchmark of 11 popular counterfactual explanation methods, (ii) a benchmarking framework for research on future counterfactual explanation methods, and (iii) a standardized set of integrated evaluation measures and data sets for transparent and extensive comparisons of these methods. We have open sourced CARLA and our experimental results on Github, making them available as competitive baselines. We welcome contributions from other research groups and practitioners.

For agents

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

get_harvested_code_for_paper("2108.00783")
get_code_for_paper("2108.00783")
have("2108.00783")

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

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

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

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

Connect an agent — have() is free.