SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1802.07623 · 2018

Explanations based on the Missing: Towards Contrastive Explanations with Pertinent Negatives

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 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 2 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-21; 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/1802.07623.json · badge: /api/ran/1802.07623.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
IBM/Contrastive-Explanation-Method canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
FunctionStatusWhere it lives
extract_data Ran
ran, honoured the contract we drafted
IBM/Contrastive-Explanation-Method/setup_mnist.py
code served (permissive licence) · get_code("86c9fa246614e9a9")
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 4, dtype family float, shape (2, 28, 28, 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 gzip
import io

# Create a minimal gzip file containing MNIST-like data
def create_test_gzip_file():
    # MNIST format: 16-byte header + image data
    # Header: magic number (4 bytes) + num images (4 bytes) + rows (4 bytes) + cols (4 bytes)
    header = np.array([2051, 2, 28, 28], dtype='>i4').tobytes()
    
    # Create image data: 2 images of 28x28 pixels
    num_images = 2
    image_data = np.random.randint(0, 256, size=(num_images * 28 * 28), dtype=np.uint8).tobytes()
    
    # Combine header and image data
    full_data = header + image_data
    
    # Compress with gzip and write to BytesIO
    buffer = io.BytesIO()
    with gzip.GzipFile(fileobj=buffer, mode='wb') as gz:
        gz.write(full_data)
    
    buffer.seek(0)
    return buffer

# Create the test gzip file
test_gzip_buffer = create_test_gzip_file()
test_filename = io.BytesIO(test_gzip_buffer.getvalue())

# Monkey-patch gzip.open to return our test file
import gzip as gzip_module
original_open = gzip_module.open

def mock_gzip_open(filename, *args, **kwargs):
    return gzip.GzipFile(fileobj=io.BytesIO(test_gzip_buffer.getvalue()), mode='rb')

gzip_module.open = mock_gzip_open

ARGS = {
    "filename": "test_mnist.gz",
    "num_images": 2
}
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 4, dtype family float, shape (2, 28, 28, 1) — shape (2, 28, 28, 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
extract_labels Ran
ran, honoured the contract we drafted
IBM/Contrastive-Explanation-Method/setup_mnist.py
code served (permissive licence) · get_code("a0cf6bb81ff7819e")
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 (5, 10) 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 gzip
import io
import tempfile
import os

# Create a temporary gzip file with mock label data
# MNIST label format: 8-byte magic header + 1 byte per label
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "labels.gz")

num_images = 5
magic_number = np.array([0, 0, 0, 8], dtype=np.uint8)  # MNIST magic number
num_images_bytes = np.array([0, 0, 0, num_images], dtype=np.uint8)
labels_data = np.array([0, 1, 2, 3, 4], dtype=np.uint8)

with gzip.open(temp_file, 'wb') as f:
    f.write(magic_number.tobytes())
    f.write(num_images_bytes.tobytes())
    f.write(labels_data.tobytes())

ARGS = {
    'filename': temp_file,
    'num_images': num_images
}
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 (5, 10) — shape (5, 10) 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
generate_data Ran
ran on a synthesized input
IBM/Contrastive-Explanation-Method/Utils.py
code served (permissive licence) · get_code("f8fb91c06db9efe1")
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

class MockData:
    def __init__(self):
        # test_data: list/array of input samples
        # Each sample should be indexable by id
        self.test_data = [
            np.random.randn(4, 3),  # sample 0
            np.random.randn(4, 3),  # sample 1
        ]
        # test_labels: 2D array where shape[1] is number of classes
        # Used to create one-hot encoding via np.eye(data.test_labels.shape[1])
        self.test_labels = np.zeros((2, 5))  # 2 samples, 5 classes

data = MockData()
id = 0
target_label = 2

ARGS = {
    "data": data,
    "id": id,
    "target_label": target_label,
}
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
model_prediction Ran
ran on a synthesized input
IBM/Contrastive-Explanation-Method/Utils.py
code served (permissive licence) · get_code("b02a81555adb2686")
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 torch
import torch.nn as nn

torch.manual_seed(0)

class StandInModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def predict(self, inputs):
        # Convert to tensor if needed
        if isinstance(inputs, np.ndarray):
            inputs = torch.from_numpy(inputs).float()
        logits = self.linear(inputs)
        # Apply softmax to get probabilities
        probs = torch.softmax(logits, dim=-1)
        return probs.detach().cpu().numpy()

class ModelWrapper:
    def __init__(self):
        self.model = StandInModel()

# Create tiny input: batch_size=2, feature_dim=4
inputs = np.random.randn(2, 4).astype(np.float32)

# Create the model wrapper
model_wrapper = ModelWrapper()

ARGS = {
    "model": model_wrapper,
    "inputs": inputs
}
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 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
load_AE Not yet run
unverified (harvested, no recorded run)
IBM/Contrastive-Explanation-Method/Utils.py
code served (permissive licence) · get_code("d6d05eebf4a4b6e9")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 2 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
extract_data 8 other papers
8 later
1805.10367 (2018-05)
Zeroth-Order Stochastic Variance Reduction for Nonconvex Optimization
1805.11090 (2018-05)
GenAttack: Practical Black-box Attacks with Gradient-Free Optimization
1805.11770 (2018-05)
AutoZOOM: Autoencoder-based Zeroth Order Optimization Method for Attacking Black-box Neural Networks
and 5 more not named here
extract_labels 8 other papers
8 later
1805.10367 (2018-05)
Zeroth-Order Stochastic Variance Reduction for Nonconvex Optimization
1805.11090 (2018-05)
GenAttack: Practical Black-box Attacks with Gradient-Free Optimization
1805.11770 (2018-05)
AutoZOOM: Autoencoder-based Zeroth Order Optimization Method for Attacking Black-box Neural Networks
and 5 more not named here
generate_data 1 other paper
1 later
1805.11770 (2018-05)
AutoZOOM: Autoencoder-based Zeroth Order Optimization Method for Attacking Black-box Neural Networks

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

Repositories linked to this paper

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

Abstract

In this paper we propose a novel method that provides contrastive explanations justifying the classification of an input by a black box classifier such as a deep neural network. Given an input we find what should be %necessarily and minimally and sufficiently present (viz. important object pixels in an image) to justify its classification and analogously what should be minimally and necessarily \emph{absent} (viz. certain background pixels). We argue that such explanations are natural for humans and are used commonly in domains such as health care and criminology. What is minimally but critically \emph{absent} is an important part of an explanation, which to the best of our knowledge, has not been explicitly identified by current explanation methods that explain predictions of neural networks. We validate our approach on three real datasets obtained from diverse domains; namely, a handwritten digits dataset MNIST, a large procurement fraud dataset and a brain activity strength dataset. In all three cases, we witness the power of our approach in generating precise explanations that are also easy for human experts to understand and evaluate.

For agents

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

get_harvested_code_for_paper("1802.07623")
get_code_for_paper("1802.07623")
have("1802.07623")

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

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

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

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

Connect an agent — have() is free.