SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1912.00965 · 2019

AP-Perf: Incorporating Generic Performance Metrics in Differentiable Learning

arXiv · PDF · Open in the Atlas

Code that ran

3 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; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 0 failures of our instrument; 2 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/1912.00965.json · badge: /api/ran/1912.00965.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
rizalzaf/ap_perf community (classifier label)
classifier basis not recorded on the link
3 ran · 1 no recorded run
rizalzaf/ap_perf_py community (classifier label)
classifier basis not recorded on the link
0 ran · 1 no recorded run
FunctionStatusWhere it lives
marginal_projection Ran
ran on a synthesized input
rizalzaf/ap_perf/ap_perf/projection.py
code served (permissive licence) · get_code("264babbb39562cc0")
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 (4, 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

# Create a small matrix A for testing
# The function expects A to be a 2D numpy array where shape[0] == n
# It will access A[:, i] for each column i
np.random.seed(0)
A = np.random.randn(4, 4) + 2.0  # Small 4x4 matrix with positive bias

ARGS = {
    "A": A,
    "init_storage_id": 0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numba, numpy, scipy — 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 (4, 4) — shape (4, 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
obj_rho Ran
ran on a synthesized input
rizalzaf/ap_perf/ap_perf/projection.py
code served (permissive licence) · get_code("c678c401463fa71a")
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 numba import jit

@jit(nopython=True)
def solve_p_given_abk(a, b, k):
    n = len(a)
    raw = a - b
    sorted_raw = np.sort(raw)[::-1]
    neg_cut_id = n - np.searchsorted(sorted_raw[::-1], 0.0)
    if neg_cut_id == n:
        sraw_neg = np.zeros(0)
        n_neg = 0
    else:
        sraw_neg = sorted_raw[neg_cut_id:]
        n_neg = len(sraw_neg)
    sum_p = np.sum(sorted_raw[0:neg_cut_id])
    if sorted_raw[0] <= sum_p / k:
        return np.maximum(raw, 0)
    i = 1
    j = neg_cut_id - 1
    l = 0
    sum_p_edge = sorted_raw[0]
    sum_p_else = sum_p - sorted_raw[0]
    sum_p_neg = 0.0
    sol_r = 0.0
    p_add = 0.0
    while True:
        next_r = (sum_p_else + sum_p_neg + sum_p_edge * (j + l) / (k - i)) / (k - i + i * (j + l) / (k - i))
        p_else_add = (sum_p_edge - i * next_r) / (k - i)
        if l < n_neg and p_else_add + sraw_neg[l] > 0:
            sum_p_neg += sraw_neg[l]
            l += 1
            continue
        if i == k - 1 or next_r + 1e-06 >= sorted_raw[i] + p_else_add:
            sol_r = next_r
            p_add = p_else_add
            break
        sum_p_edge += sorted_raw[i]
        sum_p_else -= sorted_raw[i]
        i += 1
        j -= 1
    res = np.minimum(np.maximum(raw + p_add, 0), sol_r)
    return res

@jit(nopython=True)
def obj_rho(rho_arr, A):
    rho = rho_arr[0]
    n = A.shape[0]
    best_P = np.zeros((n, n))
    obj = 0.0
    grad = np.array([0.0])
    for i in range(n):
        k = i + 1
        a = A[:, i]
        b = np.ones(n) * rho / k
        opt_p = solve_p_given_abk(a, b, k)
        best_P[:, i] = opt_p
        obj += np.sum(opt_p) * rho / k + np.linalg.norm(opt_p - a) ** 2 / 2
        grad += np.sum(opt_p) / k
    obj -= rho
    grad -= 1
    return (-obj, -grad, best_P)


# Create small test data
rho_arr = np.array([2.5])
A = np.random.randn(4, 4)

ARGS = {
    "rho_arr": rho_arr,
    "A": A
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numba, 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
solve_p_given_abk Ran
ran on a synthesized input
rizalzaf/ap_perf/ap_perf/projection.py
code served (permissive licence) · get_code("ccb14484708276f7")
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

# Set seed for reproducibility
np.random.seed(0)

# Create small test arrays for the function parameters
# The function expects numpy arrays of floats
a = np.array([1.5, 2.3, -0.5, 3.1], dtype=np.float64)
b = np.array([0.8, 1.2, 0.3, 2.0], dtype=np.float64)
k = 2  # integer parameter for the algorithm

ARGS = {
    "a": a,
    "b": b,
    "k": k,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numba, 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
load_data Not yet run
unverified (harvested, no recorded run)
rizalzaf/ap_perf_py/simple.py
code served (permissive licence) · get_code("b94c84b76136c545")
How it ran

no invocation recorded.

sqrt Not yet run
unverified (harvested, no recorded run)
rizalzaf/ap_perf/ap_perf/expression.py
code served (permissive licence) · get_code("bee26ca4d596099b")
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, 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 5 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 propose a method that enables practitioners to conveniently incorporate custom non-decomposable performance metrics into differentiable learning pipelines, notably those based upon neural network architectures. Our approach is based on the recently developed adversarial prediction framework, a distributionally robust approach that optimizes a metric in the worst case given the statistical summary of the empirical distribution. We formulate a marginal distribution technique to reduce the complexity of optimizing the adversarial prediction formulation over a vast range of non-decomposable metrics. We demonstrate how easy it is to write and incorporate complex custom metrics using our provided tool. Finally, we show the effectiveness of our approach various classification tasks on tabular datasets from the UCI repository and benchmark datasets, as well as image classification tasks. The code for our proposed method is available at https://github.com/rizalzaf/AdversarialPrediction.jl.

For agents

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

get_harvested_code_for_paper("1912.00965")
get_code_for_paper("1912.00965")
have("1912.00965")

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

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

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

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

Connect an agent — have() is free.