SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2303.09989 · 2023

Finding Competence Regions in Domain Generalization

arXiv · PDF · Open in the Atlas

Code that ran

7 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 7 have no contract verdict; 0 failures of our instrument; 1 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/2303.09989.json · badge: /api/ran/2303.09989.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
xarwinm/competence_estimation canonical (classifier label)
classifier basis not recorded on the link
7 ran · 1 no recorded run
FunctionStatusWhere it lives
compute_metric Ran
ran on a synthesized input
xarwinm/competence_estimation/competence_estimation/metrics.py
code served (permissive licence) · get_code("51bfa38a289b0fb8")
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)
np.random.seed(0)

# Create small numpy arrays for scores
batch_size_val = 2
batch_size_test = 3
batch_size_ood = 2
num_classes = 4

score_id_val = np.random.rand(batch_size_val).astype(np.float32)
score_id_test = np.random.rand(batch_size_test).astype(np.float32)
score_ood_test = np.random.rand(batch_size_ood).astype(np.float32)

# Create small logits arrays (batch_size, num_classes)
logits_id_val = np.random.randn(batch_size_val, num_classes).astype(np.float32)
logits_id_test = np.random.randn(batch_size_test, num_classes).astype(np.float32)
logits_ood_test = np.random.randn(batch_size_ood, num_classes).astype(np.float32)

# Create small labels arrays
labels_id_val = np.random.randint(0, num_classes, batch_size_val).astype(np.int64)
labels_id_test = np.random.randint(0, num_classes, batch_size_test).astype(np.int64)
labels_ood_test = np.random.randint(0, num_classes, batch_size_ood).astype(np.int64)

# Create metrics list
metrics = ['accuracy', 'quantile_95']

ARGS = {
    'score_id_val': score_id_val,
    'score_id_test': score_id_test,
    'score_ood_test': score_ood_test,
    'logits_id_val': logits_id_val,
    'labels_id_val': labels_id_val,
    'logits_id_test': logits_id_test,
    'labels_id_test': labels_id_test,
    'logits_ood_test': logits_ood_test,
    'labels_ood_test': labels_ood_test,
    'metrics': metrics,
}
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_score_function Ran
ran on a synthesized input
xarwinm/competence_estimation/competence_estimation/scores.py
code served (permissive licence) · get_code("f6883c27951a7ce1")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 faiss
from scipy.special import softmax, logsumexp
from sklearn.covariance import EmpiricalCovariance
from numpy.linalg import norm, pinv

torch.manual_seed(0)

# Set up small sample data
N_train = 8
N_val = 4
D = 4  # feature dimension
L = 3  # number of classes

# Generate random features and logits for training set
x_id_train = np.random.randn(N_train, D).astype(np.float32)
logits_id_train = np.random.randn(N_train, L).astype(np.float32)
y_id_train = np.array([0, 1, 2, 0, 1, 2, 0, 1], dtype=np.int32)

# Generate random features and logits for validation set
x_id_val = np.random.randn(N_val, D).astype(np.float32)
logits_id_val = np.random.randn(N_val, L).astype(np.float32)
y_id_val = np.array([0, 1, 2, 0], dtype=np.int32)

# Generate random weight matrix and bias for last layer
w = np.random.randn(L, D).astype(np.float32)
b = np.random.randn(L).astype(np.float32)

# Prepare kwargs for different score functions
kwargs = {
    'PCA': {'n_components': 0.95},
    'GMM': {'n_components': 2},
    'HBOS': {'n_bins': 10},
    'knn': {'K': 3},
}

ARGS = {
    'x_id_train': x_id_train,
    'logits_id_train': logits_id_train,
    'y_id_train': y_id_train,
    'x_id_val': x_id_val,
    'logits_id_val': logits_id_val,
    'y_id_val': y_id_val,
    'w': w,
    'b': b,
    'score_function': 'Softmax',
    'kwargs': kwargs,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
faiss, numpy, pyod, scipy, sklearn, 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
ecdf Ran
ran on a synthesized input
xarwinm/competence_estimation/competence_estimation/plots.py
code served (permissive licence) · get_code("6ae6d6c0f0c19f14")
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 2, 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 numpy as np

# Create a small array of numeric values for testing the ECDF function
x = np.array([3.2, 1.1, 4.5, 1.1, 2.3, 5.1], dtype=np.float32)

ARGS = {
    "x": x
}
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, ndim 2, 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_network_weights Ran
ran on a synthesized input
xarwinm/competence_estimation/competence_estimation/utils.py
code served (permissive licence) · get_code("5e435bfc41923202")
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 tempfile
import os

# Create a temporary directory structure to hold the numpy files
temp_dir = tempfile.mkdtemp()
dataset_name = "test_dataset"
test_env = "0"
algorithm_name = "test_algorithm"

# Create the nested directory structure
dataset_dir = os.path.join(temp_dir, dataset_name, f"test_env_{test_env}")
os.makedirs(dataset_dir, exist_ok=True)

# Create sample numpy arrays for weights and bias
W = np.random.randn(4, 3).astype(np.float32)
b = np.random.randn(3,).astype(np.float32)

# Save them to the expected file paths
np.save(os.path.join(dataset_dir, f"{algorithm_name}_W.npy"), W)
np.save(os.path.join(dataset_dir, f"{algorithm_name}_b.npy"), b)

ARGS = {
    "algorithm": algorithm_name,
    "dataset": dataset_name,
    "test_domain": test_env,
    "dataset_path": temp_dir,
}
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
load_data Ran
ran on a synthesized input
xarwinm/competence_estimation/competence_estimation/utils.py
code served (permissive licence) · get_code("cd5939d86709372a")
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 tempfile
import os

# Create a temporary directory structure with mock data files
temp_dir = tempfile.mkdtemp()
dataset_name = "RotatedMNIST"
test_domain = 0
algorithm = "ERM"

# Create the nested directory structure
dataset_path = os.path.join(temp_dir, dataset_name, f"test_env_{test_domain}")
os.makedirs(dataset_path, exist_ok=True)

# Create mock numpy arrays with distinct shapes
# Features: (batch_size, feature_dim)
# Logits: (batch_size, num_classes)
# Labels: (batch_size,)

train_size, val_size, id_test_size, ood_test_size = 10, 8, 6, 4
feature_dim, num_classes = 5, 3

# Create and save mock data files
np.save(os.path.join(dataset_path, f"{algorithm}_features_id_train.npy"), 
        np.random.randn(train_size, feature_dim).astype(np.float32))
np.save(os.path.join(dataset_path, f"{algorithm}_labels_id_train.npy"), 
        np.random.randint(0, num_classes, train_size))

np.save(os.path.join(dataset_path, f"{algorithm}_features_id_val.npy"), 
        np.random.randn(val_size, feature_dim).astype(np.float32))
np.save(os.path.join(dataset_path, f"{algorithm}_labels_id_val.npy"), 
        np.random.randint(0, num_classes, val_size))

np.save(os.path.join(dataset_path, f"{algorithm}_features_id_test.npy"), 
        np.random.randn(id_test_size, feature_dim).astype(np.float32))
np.save(os.path.join(dataset_path, f"{algorithm}_labels_id_test.npy"), 
        np.random.randint(0, num_classes, id_test_size))

np.save(os.path.join(dataset_path, f"{algorithm}_features_ood_test.npy"), 
        np.random.randn(ood_test_size, feature_dim).astype(np.float32))
np.save(os.path.join(dataset_path, f"{algorithm}_labels_ood_test.npy"), 
        np.random.randint(0, num_classes, ood_test_size))

np.save(os.path.join(dataset_path, f"{algorithm}_logits_id_train.npy"), 
        np.random.randn(train_size, num_classes).astype(np.float32))
np.save(os.path.join(dataset_path, f"{algorithm}_logits_id_val.npy"), 
        np.random.randn(val_size, num_classes).astype(np.float32))
np.save(os.path.join(dataset_path, f"{algorithm}_logits_id_test.npy"), 
        np.random.randn(id_test_size, num_classes).astype(np.float32))
np.save(os.path.join(dataset_path, f"{algorithm}_logits_ood_test.npy"), 
        np.random.randn(ood_test_size, num_classes).astype(np.float32))

ARGS = {
    "algorithm": "ERM",
    "dataset": "RotatedMNIST",
    "test_domain": 0,
    "data_dir": temp_dir,
    "fast": False
}
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
mix_open Ran
ran on a synthesized input
xarwinm/competence_estimation/competence_estimation/utils.py
code served (permissive licence) · get_code("3326f1ac801e81be")
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

torch.manual_seed(0)

# Create small numpy arrays for features, logits, and labels
batch_size_ood = 4
batch_size_open = 6
feature_dim = 8
num_classes = 3

# OOD data (in-distribution)
features_ood = np.random.randn(batch_size_ood, feature_dim).astype(np.float32)
logits_ood = np.random.randn(batch_size_ood, num_classes).astype(np.float32)
labels_ood = np.array([0, 1, 2, 0], dtype=np.int64)

# Open/unknown class data
features_open = np.random.randn(batch_size_open, feature_dim).astype(np.float32)
logits_open = np.random.randn(batch_size_open, num_classes).astype(np.float32)

# Percentage of unknowns in output
percentage = 0.5

ARGS = {
    "features_ood": features_ood,
    "logits_ood": logits_ood,
    "labels_ood": labels_ood,
    "features_open": features_open,
    "logits_open": logits_open,
    "percentage": percentage,
}
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
plot_accuracy_curve Ran
ran on a synthesized input
xarwinm/competence_estimation/competence_estimation/plots.py
code served (permissive licence) · get_code("d7f4b7fda092dfbc")
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 matplotlib.pyplot as plt

# Create small synthetic data structures matching the function's expectations

# The function expects nested dictionaries with specific structure:
# results_scores[score_func][dataset][classifier][domain][percentage][data_type]
# results_true_false[score_func][dataset][classifier][domain][percentage][data_type]

np.random.seed(0)

# Create score functions list
score_functions = ['score_func_1', 'score_func_2']

# Create results_scores dictionary
# Structure: {score_func: {dataset: {classifier: {domain: {percentage: {data_type: array}}}}}}
results_scores = {}
for score_func in score_functions:
    results_scores[score_func] = {
        'PACS': {
            'resnet50': {
                0: {
                    0.0: {
                        'id_val': np.random.randn(50),
                        'id_test': np.random.randn(30),
                        'ood_test': np.random.randn(25)
                    }
                }
            }
        }
    }

# Create results_true_false dictionary
# Structure: {score_func: {dataset: {classifier: {domain: {percentage: {data_type: array}}}}}}
results_true_false = {}
for score_func in score_functions:
    results_true_false[score_func] = {
        'PACS': {
            'resnet50': {
                0: {
                    0.0: {
                        'id_test': np.random.randint(0, 2, size=30),
                        'ood_test': np.random.randint(0, 2, size=25)
                    }
                }
            }
        }
    }

ARGS = {
    'results_scores': results_scores,
    'results_true_false': results_true_false,
    'score_functions': score_functions,
    'data_set': 'PACS',
    'classifier': 'resnet50',
    'domain': 0,
    'axarr': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy, seaborn — 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
plot_accuracy_coverage Not yet run
unverified (harvested, no recorded run)
xarwinm/competence_estimation/competence_estimation/plots.py
code served (permissive licence) · get_code("26c0718c9ecac125")
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-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

We investigate a "learning to reject" framework to address the problem of silent failures in Domain Generalization (DG), where the test distribution differs from the training distribution. Assuming a mild distribution shift, we wish to accept out-of-distribution (OOD) data from a new domain whenever a model's estimated competence foresees trustworthy responses, instead of rejecting OOD data outright. Trustworthiness is then predicted via a proxy incompetence score that is tightly linked to the performance of a classifier. We present a comprehensive experimental evaluation of existing proxy scores as incompetence scores for classification and highlight the resulting trade-offs between rejection rate and accuracy gain. For comparability with prior work, we focus on standard DG benchmarks and consider the effect of measuring incompetence via different learned representations in a closed versus an open world setting. Our results suggest that increasing incompetence scores are indeed predictive of reduced accuracy, leading to significant improvements of the average accuracy below a suitable incompetence threshold. However, the scores are not yet good enough to allow for a favorable accuracy/rejection trade-off in all tested domains. Surprisingly, our results also indicate that classifiers optimized for DG robustness do not outperform a naive Empirical Risk Minimization (ERM) baseline in the competence region, that is, where test samples elicit low incompetence scores.

For agents

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

get_harvested_code_for_paper("2303.09989")
get_code_for_paper("2303.09989")
have("2303.09989")

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

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

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

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

Connect an agent — have() is free.