SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1911.12199 · 2019

FOCUS: Flexible Optimizable Counterfactual Explanations for Tree Ensembles

arXiv · PDF · Open in the Atlas

Code that ran

6 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 6 have no contract verdict; 0 failures of our instrument; 2 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/1911.12199.json · badge: /api/ran/1911.12199.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
a-lucic/focus canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
get_indices Ran
ran on a synthesized input
a-lucic/focus/src/dataset.py
code served (permissive licence) · get_code("b461486afd1165ba")
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 int, 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
import pandas as pd
import tempfile
import os

# Create a temporary TSV file with test data
temp_dir = tempfile.gettempdir()
temp_file = os.path.join(temp_dir, "test_input.tsv")

# Create a small test dataset with an 'id' column
test_data = pd.DataFrame({
    'id': [101, 102, 103, 104],
    'value': [1.1, 2.2, 3.3, 4.4]
})

# Write to TSV file
test_data.to_csv(temp_file, sep='\t', index=False)

ARGS = {
    'input_file': temp_file
}
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 1, dtype family int, 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
get_prob_classification_forest Ran
ran on a synthesized input
a-lucic/focus/src/trees.py
code served (permissive licence) · get_code("630006c3a2ea1901")
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 EagerTensor, ndim 2, dtype family float, shape (2, 2) 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 tensorflow as tf
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
from sklearn.tree import DecisionTreeClassifier

# Set seeds for reproducibility
np.random.seed(0)
tf.random.set_seed(0)

# Create a small synthetic dataset
X, y = make_classification(n_samples=20, n_features=4, n_informative=3, 
                           n_redundant=0, n_classes=2, random_state=0)

# Train a small RandomForestClassifier with minimal trees
model = RandomForestClassifier(n_estimators=5, max_depth=3, random_state=0)
model.fit(X, y)

# Create feature columns (list of feature names/indices)
feat_columns = ['feat_0', 'feat_1', 'feat_2', 'feat_3']

# Create a small batch of feature input as TensorFlow tensor
feat_input = tf.constant(X[:2, :], dtype=tf.float32)

# Define sigma and temperature parameters
sigma = 10.0
temperature = 1.0

ARGS = {
    'model': model,
    'feat_columns': feat_columns,
    'feat_input': feat_input,
    'sigma': sigma,
    'temperature': temperature
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 2, dtype family float, shape (2, 2) — shape (2, 2) 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
get_prob_classification_tree Ran
ran on a synthesized input
a-lucic/focus/src/trees.py
code served (permissive licence) · get_code("35dea20c96c023b6")
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 EagerTensor, ndim 2, dtype family float, shape (2, 2) 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 tensorflow as tf
import numpy as np
from sklearn.tree import DecisionTreeClassifier

# Create a simple trained decision tree
np.random.seed(0)
X_train = np.random.randn(20, 4).astype(np.float32)
y_train = (X_train[:, 0] + X_train[:, 1] > 0).astype(int)

tree = DecisionTreeClassifier(max_depth=2, random_state=0)
tree.fit(X_train, y_train)

# Create feature input tensor
feat_input = tf.constant(np.random.randn(2, 4).astype(np.float32))

# Feature columns (list of column names)
feat_columns = ['feat_0', 'feat_1', 'feat_2', 'feat_3']

# Sigma parameter for the sigmoid approximation
sigma = 1.0

ARGS = {
    'tree': tree,
    'feat_columns': feat_columns,
    'feat_input': feat_input,
    'sigma': sigma
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 2, dtype family float, shape (2, 2) — shape (2, 2) 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
read_tsv_file Ran
ran on a synthesized input
a-lucic/focus/src/dataset.py
code served (permissive licence) · get_code("45d10176e075b7fb")
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
import pandas as pd
import tempfile
import os

# Create a temporary TSV file for testing
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test_data.tsv")

# Create sample data with index and columns
data = {
    'col1': [1.5, 2.3, -1.0],
    'col2': [0.5, -0.5, 3.2],
    'col3': [2.1, 1.1, 0.9]
}
df = pd.DataFrame(data)
df.index.name = 'idx'
df.to_csv(temp_file, sep='\t')

ARGS = {
    'input_file': temp_file,
    'negative_is_missing': 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 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
safe_euclidean Ran
ran on a synthesized input
a-lucic/focus/src/utils.py
code served (permissive licence) · get_code("7d450d769c3817b7")
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 EagerTensor, ndim 1, dtype family float, shape (2,) 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 tensorflow as tf
import numpy as np

# Create a small TensorFlow tensor for testing
x = tf.constant(np.random.randn(2, 4), dtype=tf.float32)

# Define arguments for safe_euclidean
ARGS = {
    "x": x,
    "epsilon": 10.0 ** (-10),
    "axis": -1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 1, dtype family float, shape (2,) — shape (2,) 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
true_euclidean Ran
ran on a synthesized input
a-lucic/focus/src/utils.py
code served (permissive licence) · get_code("d8f81cd1bb22f7a0")
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 EagerTensor, ndim 1, dtype family float, shape (2,) 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 tensorflow as tf
import numpy as np

def true_euclidean(x, axis=-1):
    return tf.reduce_sum(x ** 2, axis=axis) ** 0.5

# Create a small TensorFlow tensor
x = tf.constant(np.random.randn(2, 4).astype(np.float32))

ARGS = {
    "x": x,
    "axis": -1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 1, dtype family float, shape (2,) — shape (2,) 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
filter_hinge_loss Not yet run
unverified (harvested, no recorded run)
a-lucic/focus/src/utils.py
code served (permissive licence) · get_code("268b8e02cea293a9")
How it ran

no invocation recorded.

get_exact_classification_tree Not yet run
unverified (harvested, no recorded run)
a-lucic/focus/src/trees.py
code served (permissive licence) · get_code("e44c92a22d6734f7")
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, 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 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.

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

Model interpretability has become an important problem in machine learning (ML) due to the increased effect that algorithmic decisions have on humans. Counterfactual explanations can help users understand not only why ML models make certain decisions, but also how these decisions can be changed. We frame the problem of finding counterfactual explanations as a gradient-based optimization task and extend previous work that could only be applied to differentiable models. In order to accommodate non-differentiable models such as tree ensembles, we use probabilistic model approximations in the optimization framework. We introduce an approximation technique that is effective for finding counterfactual explanations for predictions of the original model and show that our counterfactual examples are significantly closer to the original instances than those produced by other methods specifically designed for tree ensembles.

For agents

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

get_harvested_code_for_paper("1911.12199")
get_code_for_paper("1911.12199")
have("1911.12199")

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

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

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

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

Connect an agent — have() is free.