SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.11210 · NeurIPS · 2025

Minimizing False-Positive Attributions in Explanations of Non-Linear Models

Lars Hansen, Stefan Haufe, Anders Gjølbye

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 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 8 have no contract verdict; 0 failures of our instrument; 3 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/2505.11210.json · badge: /api/ran/2505.11210.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
gjoelbye/patternlocal canonical (classifier label)
classifier basis not recorded on the link
8 ran · 3 no recorded run
FunctionStatusWhere it lives
create_combined_metric Ran
ran on a synthesized input
gjoelbye/patternlocal/patternlocal/optimization/metrics.py
code served (permissive licence) · get_code("00c48a4ef206beba")
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 function. 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 logging

logging.basicConfig(level=logging.WARNING)

torch.manual_seed(0)

# Define simple metric functions that accept **args and return a scalar score
def metric_1(**args):
    """Simple metric that returns a constant score."""
    return 0.5

def metric_2(**args):
    """Another metric that returns a different score."""
    return 0.7

def metric_3(**args):
    """Metric that might fail occasionally."""
    return 0.3

# Create list of metrics
metrics = [metric_1, metric_2, metric_3]

# Create weights for the metrics
weights = [0.5, 0.3, 0.2]

ARGS = {
    "metrics": metrics,
    "weights": weights,
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
create_experiment_config Ran
ran on a synthesized input
gjoelbye/patternlocal/patternlocal/optimization/utils.py
code served (permissive licence) · get_code("5904c97717c6e391")
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 torch
import numpy as np
from typing import Any, Dict, Optional

torch.manual_seed(0)

ARGS = {
    'simplification': 'lowrank',
    'solver': 'local_covariance',
    'backend': 'hyperopt',
    'max_evals': 100,
    'metric_name': 'fidelity',
    'n_jobs': -1,
    'random_state': 42,
}
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 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
create_ground_truth_metric Ran
ran on a synthesized input
gjoelbye/patternlocal/patternlocal/optimization/metrics.py
code served (permissive licence) · get_code("f353af080c6b50ab")
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 function. 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 logging
from typing import Callable, Any, Optional

logging.basicConfig(level=logging.WARNING)

# Create a simple mock explainer class
class MockExplainer:
    def explain_instance(self, instance: np.ndarray, predict_fn: Callable, X_train: np.ndarray, **kwargs) -> dict:
        # Return a mock explanation with pattern_weights
        return {'pattern_weights': np.random.randn(instance.shape[0])}

# Create a simple mock predict function
def mock_predict_fn(X: np.ndarray) -> np.ndarray:
    # Simple linear model: sum of features
    if len(X.shape) == 1:
        X = X.reshape(1, -1)
    # Return predictions for binary classification (shape: n_samples, 2)
    preds = np.sum(X, axis=1)
    return np.column_stack([1 - preds, preds])

# Set up data
np.random.seed(42)
n_features = 5
n_train_samples = 20
n_test_samples = 10

# Create training data
X_train = np.random.randn(n_train_samples, n_features)

# Create instance to explain
instance = np.random.randn(n_features)

# Create explanation weights
explanation_weights = np.random.randn(n_features)

# Create ground truth mask (binary importance mask)
ground_truth_mask = np.array([1, 1, 0, 0, 1], dtype=bool)

# Create explainer instance
explainer_instance = MockExplainer()

# Build ARGS dictionary for fidelity_error
ARGS = {
    'explanation_weights': explanation_weights,
    'instance': instance,
    'ground_truth_mask': ground_truth_mask,
    'predict_fn': mock_predict_fn,
    'X_train': X_train,
    'n_samples': 100,
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
evaluate_explanations_parallel Ran
ran on a synthesized input
gjoelbye/patternlocal/patternlocal/optimization/metrics.py
code served (permissive licence) · get_code("50eca4eb153b9c13")
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
from typing import Any, Callable, Dict, Optional

# Create a minimal stand-in explainer class
class SimpleExplainer:
    def explain_instance(self, instance: np.ndarray, predict_fn: Callable, X_train: np.ndarray, **kwargs) -> Dict[str, Any]:
        """Return a simple explanation dict with pattern_weights."""
        return {
            'pattern_weights': np.random.rand(instance.shape[0]),
            'features': list(range(instance.shape[0]))
        }

# Create a minimal metric function
def simple_metric_fn(explanation_weights: np.ndarray, instance: np.ndarray, ground_truth_mask: Optional[np.ndarray], predict_fn: Callable, X_train: np.ndarray, **kwargs) -> float:
    """Simple metric that returns a random error value."""
    return float(np.random.rand())

# Create a minimal predict function
def simple_predict_fn(X: np.ndarray) -> np.ndarray:
    """Simple predictor that returns random predictions."""
    return np.random.rand(X.shape[0])

# Create test data with distinct dimensions
instances = np.random.rand(5, 4)  # 5 instances, 4 features
masks = np.random.rand(5, 4)      # 5 masks, 4 features
X_train = np.random.rand(20, 4)   # 20 training samples, 4 features
y_train = np.random.randint(0, 2, 20)  # 20 labels

# Create the explainer instance
explainer = SimpleExplainer()

# Construct ARGS dictionary
ARGS = {
    'explainer_instance': explainer,
    'instances': instances,
    'masks': masks,
    'X_train': X_train,
    'y_train': y_train,
    'predict_fn': simple_predict_fn,
    'metric_fn': simple_metric_fn,
    'n_jobs': 1,
    'batch_size': 2,
    'subset_size': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
joblib, 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
load_optimization_results Ran
ran on a synthesized input
gjoelbye/patternlocal/patternlocal/optimization/utils.py
code served (permissive licence) · get_code("b6e28f195b115055")
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 os
import pickle
import tempfile
import torch
import logging

logging.basicConfig(level=logging.INFO)

# Create a temporary file with pickle data
temp_dir = tempfile.mkdtemp()
temp_file_path = os.path.join(temp_dir, "optimization_results.pkl")

# Create sample optimization results
sample_results = {
    "best_loss": 0.042,
    "best_params": {"learning_rate": 0.001, "batch_size": 32},
    "history": [0.5, 0.3, 0.15, 0.08, 0.042],
    "model_state": {"layer1.weight": torch.randn(4, 3), "layer1.bias": torch.randn(4)},
    "iterations": 100
}

# Pickle the sample results to the temp file
with open(temp_file_path, 'wb') as f:
    pickle.dump(sample_results, f)

# Define ARGS dict
ARGS = {
    "file_path": temp_file_path
}
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 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
parse_parameter_dict Ran
ran on a synthesized input
gjoelbye/patternlocal/patternlocal/optimization/utils.py
code served (permissive licence) · get_code("16b28e46e47404e9")
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 torch
import numpy as np

torch.manual_seed(0)

# The function parse_parameter_dict takes a flattened parameter dictionary
# with keys like 'component__param' and parses it into nested component dictionaries.
# It handles components: 'simplification', 'solver', 'lime'
# It also handles special keys: 'simplification_method', 'solver_method'

# Construct a valid flattened parameter dictionary
params = {
    'simplification__alpha': 0.5,
    'simplification__threshold': 1e-3,
    'solver__max_iter': 100,
    'solver__tolerance': 1e-6,
    'lime__num_samples': 1000,
    'lime__kernel_width': 0.25,
    'simplification_method': 'auto',
    'solver_method': 'lbfgs',
    'other_param': 'value'  # This won't be parsed into known components
}

ARGS = {
    'params': params
}
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 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
validate_array_input Ran
ran on a synthesized input
gjoelbye/patternlocal/patternlocal/config/validation.py
code served (permissive licence) · get_code("9e94143f78757d71")
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 function. 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
from functools import wraps
from typing import Any, Callable, Dict, Optional, Protocol

class ValidationError(Exception):
    """Custom validation error."""
    pass

def validate_array_input(func: Callable) -> Callable:
    """Decorator to validate numpy array inputs."""

    @wraps(func)
    def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
        for i, arg in enumerate(args):
            if isinstance(arg, np.ndarray):
                if arg.size == 0:
                    raise ValidationError(f'Argument {i} is an empty array')
                if np.any(np.isnan(arg)):
                    raise ValidationError(f'Argument {i} contains NaN values')
                if np.any(np.isinf(arg)):
                    raise ValidationError(f'Argument {i} contains infinite values')
        return func(self, *args, **kwargs)
    return wrapper


class MockClass:
    """Mock class to test the decorator."""
    
    @validate_array_input
    def process_arrays(self, arr1, arr2):
        """Method that processes arrays."""
        return arr1 + arr2


# Create valid test arguments
mock_instance = MockClass()

# Create valid numpy arrays (no NaN, no inf, non-empty)
valid_array_1 = np.array([1.0, 2.0, 3.0, 4.0])
valid_array_2 = np.array([5.0, 6.0, 7.0, 8.0])

ARGS = {
    'func': validate_array_input,
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
validate_fitted Ran
ran on a synthesized input
gjoelbye/patternlocal/patternlocal/config/validation.py
code served (permissive licence) · get_code("280645296cbb074c")
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 function. 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
from functools import wraps
from typing import Any, Callable, Dict, Optional, Protocol

torch.manual_seed(0)

class ValidationError(Exception):
    """Custom validation error for testing."""
    pass

def validate_fitted(func: Callable) -> Callable:
    """Decorator to validate that explainer is fitted before method call."""

    @wraps(func)
    def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
        if not getattr(self, 'is_fitted', False):
            raise ValidationError(f'{func.__name__} requires fitted explainer')
        return func(self, *args, **kwargs)
    return wrapper


class MockExplainer:
    """Mock explainer class with is_fitted attribute."""
    def __init__(self, is_fitted: bool = False):
        self.is_fitted = is_fitted
    
    @validate_fitted
    def explain(self, x: torch.Tensor) -> torch.Tensor:
        """Mock explain method that requires fitted explainer."""
        return x * 2


def mock_function_using_decorator(self: Any) -> str:
    """A simple function decorated with validate_fitted."""
    return "success"

decorated_func = validate_fitted(mock_function_using_decorator)


explainer_fitted = MockExplainer(is_fitted=True)
explainer_unfitted = MockExplainer(is_fitted=False)

ARGS = {
    'func': mock_function_using_decorator,
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
create_backend Not yet run
unverified (harvested, no recorded run)
gjoelbye/patternlocal/patternlocal/optimization/backends.py
code served (permissive licence) · get_code("f4541182964dfb8c")
How it ran

no invocation recorded.

create_custom_search_space Not yet run
unverified (harvested, no recorded run)
gjoelbye/patternlocal/patternlocal/optimization/search_spaces.py
code served (permissive licence) · get_code("ee60d051f983149f")
How it ran

no invocation recorded.

get_default_search_space Not yet run
unverified (harvested, no recorded run)
gjoelbye/patternlocal/patternlocal/optimization/search_spaces.py
code served (permissive licence) · get_code("fb5feb0ee52fa210")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 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 11 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

Suppressor variables can influence model predictions without being dependent on the target outcome, and they pose a significant challenge for Explainable AI (XAI) methods. These variables may cause false-positive feature attributions, undermining the utility of explanations. Although effective remedies exist for linear models, their extension to non-linear models and instance-based explanations has remained limited. We introduce PatternLocal, a novel XAI technique that addresses this gap. PatternLocal begins with a locally linear surrogate, e.g., LIME, KernelSHAP, or gradient-based methods, and transforms the resulting discriminative model weights into a generative representation, thereby suppressing the influence of suppressor variables while preserving local fidelity. In extensive hyperparameter optimization on the XAI-TRIS benchmark, PatternLocal consistently outperformed other XAI methods and reduced false-positive attributions when explaining non-linear tasks, thereby enabling more reliable and actionable insights. We further evaluate Pattern-Local on an EEG motor imagery dataset, demonstrating physiologically plausible explanations.

For agents

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

get_harvested_code_for_paper("2505.11210")
get_code_for_paper("2505.11210")
have("2505.11210")

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

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

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

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

Connect an agent — have() is free.