SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.07762 · 2024

Scalable Structure Learning for Sparse Context-Specific Systems

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 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 0 have no contract verdict; 5 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/2402.07762.json · badge: /api/ran/2402.07762.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
felixleopoldo/cslearn canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
KL_divergence Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
felixleopoldo/cslearn/src/cslearn/evaluate.py
code served (permissive licence) · get_code("56a7eeefc6a58db3")
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 float64, ndim 0, 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
import pandas as pd
from scipy.special import rel_entr

# Create two small dataframes with 'prob' columns
# These represent probability distributions

# First distribution (estimated)
df_distr1 = pd.DataFrame({
    'prob': np.array([0.1, 0.2, 0.3, 0.4])
})

# Second distribution (true)
df_distr2 = pd.DataFrame({
    'prob': np.array([0.15, 0.25, 0.35, 0.25])
})

ARGS = {
    'df_distr1': df_distr1,
    'df_distr2': df_distr2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
decomposition Ran
ran; our contract draft was wrong, not the code
felixleopoldo/cslearn/src/cslearn/dependence.py
code served (permissive licence) · get_code("2a2a3a20fec7bc88")
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 list, ndim 1, 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 itertools

def _mymax(s):
    if isinstance(s, set) and len(s) > 0:
        return max(s)
    else:
        return 0

class CI:
    """This is a conditional independence relation on the form a ⊥ b | sep.

    Args:
        a (set): The first set of variables.
        b (set): The second set of variables.
        sep (set): The set of variables that separate a and b.

    Examples:
        >>> from cslearn.dependence import CI
        >>> print(CI({1}, {2}, {4, 0}, labels=["X" + str(i) for i in range(1, 6)]))
        X2 ⊥ X3 | X1, X5
    """

    def __init__(self, a: set, b: set, sep: set, labels: list[str] | None=None) -> None:
        self.a = a
        self.b = b
        self.sep = sep
        if labels is None:
            levels = max(_mymax(self.a), _mymax(self.b), _mymax(self.sep)) + 1
            self.labels = range(levels)
        else:
            self.labels = labels

    def __eq__(self, o: object) -> bool:
        return ((self.a == o.a) & (self.b == o.b) | (self.a == o.b) & (self.b == o.a)) & (self.sep == o.sep)

    def __str__(self) -> str:
        s1 = ''
        for i in self.a:
            s1 += '{}, '.format(self.labels[i])
        s1 = s1[:-2]
        s2 = ''
        for i in self.b:
            s2 += '{}, '.format(self.labels[i])
        s2 = s2[:-2]
        s3 = ''
        if len(self.sep) > 0:
            for i in self.sep:
                s3 += '{}, '.format(self.labels[i])
            s3 = s3[:-2]
            return '{} ⊥ {} | {}'.format(s1, s2, s3)
        return '{} ⊥ {}'.format(s1, s2)

def decomposition(ci: CI):
    """Generate all possible pairwise CI relations that are implied by
    decomposition rule.

    Args:
        ci (CI): A CI relation.

    Returns:
        list: List of pairwise CI relations.

    Examples:
        >>> from cslearn.dependence import CI, decomposition
        >>> for d in decomposition(CI({1, 2}, {3, 4}, {0})):
        ...     print(d)
        1 ⊥ 3 | 0
        1 ⊥ 4 | 0
        2 ⊥ 3 | 0
        2 ⊥ 4 | 0
    """
    cilist = []
    for x in itertools.product(ci.a, ci.b):
        new_ci = CI({x[0]}, {x[1]}, ci.sep)
        if new_ci == ci:
            continue
        cilist.append(new_ci)
    return cilist


# Construct a CI object for testing
# Using sets with indices: a={1, 2}, b={3, 4}, sep={0}
ci_instance = CI(
    a={1, 2},
    b={3, 4},
    sep={0},
    labels=["X0", "X1", "X2", "X3", "X4"]
)

ARGS = {
    "ci": ci_instance
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
num_stagings Ran
ran, honoured the contract we drafted
felixleopoldo/cslearn/src/cslearn/double_cvar_stagings.py
code served (permissive licence) · get_code("5a2c9a09f7a03d00")
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 int, ndim 0, dtype family int, shape () 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 torch
import numpy as np

torch.manual_seed(0)

# The function num_stagings takes a single integer parameter 'lvl'
# and returns an integer based on a formula.
# No complex objects needed - just an integer argument.

ARGS = {
    "lvl": 2
}
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 int, ndim 0, dtype family int, shape () — shape () 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
pairwise_cis Ran
ran; our contract draft was wrong, not the code
felixleopoldo/cslearn/src/cslearn/dependence.py
code served (permissive licence) · get_code("0761d21a6e6fd22e")
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 list, ndim 1, 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 itertools

def _mymax(s):
    if isinstance(s, set) and len(s) > 0:
        return max(s)
    else:
        return 0

class CI:
    """This is a conditional independence relation on the form a ⊥ b | sep.

    Args:
        a (set): The first set of variables.
        b (set): The second set of variables.
        sep (set): The set of variables that separate a and b.

    Examples:
        >>> from cslearn.dependence import CI
        >>> print(CI({1}, {2}, {4, 0}, labels=["X" + str(i) for i in range(1, 6)]))
        X2 ⊥ X3 | X1, X5
    """

    def __init__(self, a: set, b: set, sep: set, labels: list[str] | None=None) -> None:
        self.a = a
        self.b = b
        self.sep = sep
        if labels is None:
            levels = max(_mymax(self.a), _mymax(self.b), _mymax(self.sep)) + 1
            self.labels = range(levels)
        else:
            self.labels = labels

    def __eq__(self, o: object) -> bool:
        return ((self.a == o.a) & (self.b == o.b) | (self.a == o.b) & (self.b == o.a)) & (self.sep == o.sep)

    def __str__(self) -> str:
        s1 = ''
        for i in self.a:
            s1 += '{}, '.format(self.labels[i])
        s1 = s1[:-2]
        s2 = ''
        for i in self.b:
            s2 += '{}, '.format(self.labels[i])
        s2 = s2[:-2]
        s3 = ''
        if len(self.sep) > 0:
            for i in self.sep:
                s3 += '{}, '.format(self.labels[i])
            s3 = s3[:-2]
            return '{} ⊥ {} | {}'.format(s1, s2, s3)
        return '{} ⊥ {}'.format(s1, s2)

def pairwise_cis(ci: CI):
    """Using weak union just to get pairwise independence relations from a CI.

    Args:
        ci (CI): CI relation
    Returns:
        list: List of pairwise CI relations.
    Examples:
        >>> from cslearn.dependence import CI, pairwise_cis
        >>> for x in pairwise_cis(CI({1, 2}, {3, 4}, {0})):
        ...     print(x)
        1 ⊥ 3 | 0, 2, 4
        1 ⊥ 4 | 0, 2, 3
        2 ⊥ 3 | 0, 1, 4
        2 ⊥ 4 | 0, 1, 3
    """
    cis = []
    A = ci.a
    B = ci.b
    for x in itertools.product(A, B):
        rest = A - {x[0]} | B - {x[1]}
        cis.append(CI({x[0]}, {x[1]}, ci.sep | rest))
    return cis

ci_example = CI(a={1, 2}, b={3, 4}, sep={0})

ARGS = {
    "ci": ci_example
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
score_order Ran
ran, honoured the contract we drafted
felixleopoldo/cslearn/src/cslearn/scoring.py
code served (permissive licence) · get_code("4ffd4fad4b067873")
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 float, ndim 0, dtype family float, shape () 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 random
import numpy as np

# Set seeds for reproducibility
np.random.seed(1)
random.seed(1)

# Build a minimal order_scores dictionary that matches what the function expects
# The function iterates through an order and looks up scores based on variable names
# and their possible parents

order_scores = {
    'poss_cvars': {
        'X1': ['X2', 'X3'],
        'X2': ['X1', 'X3'],
        'X3': ['X1', 'X2']
    },
    'scores': {
        'X1': {
            'None': -2.5,
            'X2': -3.1,
            'X3': -3.2,
            'X2,X3': -4.0
        },
        'X2': {
            'None': -2.3,
            'X1': -2.9,
            'X3': -3.0,
            'X1,X3': -3.8
        },
        'X3': {
            'None': -2.4,
            'X1': -3.0,
            'X2': -3.1,
            'X1,X2': -3.9
        }
    }
}

# The order is a list of variables to score
order = ['X3', 'X2', 'X1']

ARGS = {
    'order': order,
    'order_scores': order_scores
}
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 float, ndim 0, dtype family float, shape () — shape () 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
shd_edges Ran
ran; our contract draft was wrong, not the code
felixleopoldo/cslearn/src/cslearn/evaluate.py
code served (permissive licence) · get_code("c9955ba204e1c22b")
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 int, ndim 0, dtype family int, shape () 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 torch

torch.manual_seed(0)

# estimated_edges: a set or iterable of tuples representing estimated directed edges
# Each edge is a tuple (source, target)
estimated_edges = [(0, 1), (1, 2), (2, 3), (1, 0)]

# true_edges: a set or iterable of tuples representing true directed edges
# Each edge is a tuple (source, target)
true_edges = [(0, 1), (1, 2), (3, 2), (0, 2)]

ARGS = {
    "estimated_edges": estimated_edges,
    "true_edges": true_edges,
}
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 int, ndim 0, dtype family int, shape () — shape () 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
weak_union Ran
ran; our contract draft was wrong, not the code
felixleopoldo/cslearn/src/cslearn/dependence.py
code served (permissive licence) · get_code("5b6590bd01959de4")
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 list, ndim 1, 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.

from itertools import chain, combinations

def _mymax(s):
    if isinstance(s, set) and len(s) > 0:
        return max(s)
    else:
        return 0

class CI:
    """This is a conditional independence relation on the form a ⊥ b | sep."""

    def __init__(self, a: set, b: set, sep: set, labels: list[str] | None=None) -> None:
        self.a = a
        self.b = b
        self.sep = sep
        if labels is None:
            levels = max(_mymax(self.a), _mymax(self.b), _mymax(self.sep)) + 1
            self.labels = range(levels)
        else:
            self.labels = labels

    def __eq__(self, o: object) -> bool:
        return ((self.a == o.a) & (self.b == o.b) | (self.a == o.b) & (self.b == o.a)) & (self.sep == o.sep)

    def __str__(self) -> str:
        s1 = ''
        for i in self.a:
            s1 += '{}, '.format(self.labels[i])
        s1 = s1[:-2]
        s2 = ''
        for i in self.b:
            s2 += '{}, '.format(self.labels[i])
        s2 = s2[:-2]
        s3 = ''
        if len(self.sep) > 0:
            for i in self.sep:
                s3 += '{}, '.format(self.labels[i])
            s3 = s3[:-2]
            return '{} ⊥ {} | {}'.format(s1, s2, s3)
        return '{} ⊥ {}'.format(s1, s2)

def _powerset(iterable):
    """Returns the set of all subsets of a set."""
    s = list(iterable)
    return chain.from_iterable((combinations(s, r) for r in range(len(s) + 1)))

def weak_union(ci: CI):
    """Using weak union just to get pairwise independence relations from a CSI."""
    cis = []
    for d in _powerset(ci.b):
        d = set(d)
        if (len(d) == 0) | (d == ci.b):
            continue
        BuD = ci.b
        cis.append(CI(ci.a, BuD - d, ci.sep | d))
    for d in _powerset(ci.a):
        d = set(d)
        if (len(d) == 0) | (d == ci.a):
            continue
        d = set(d)
        AuD = ci.a
        cis.append(CI(AuD - d, ci.b, ci.sep | d))
    return cis

# Create a valid CI object with non-overlapping sets
ci_obj = CI(
    a={0, 1},
    b={2, 3},
    sep={4},
    labels=["X0", "X1", "X2", "X3", "X4"]
)

ARGS = {
    "ci": ci_obj
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
plot Not yet run
unverified (harvested, no recorded run)
felixleopoldo/cslearn/src/cslearn/cstree.py
code served (permissive licence) · get_code("b53c12e40a76de4d")
How it ran

no invocation recorded.

sachs_observational Not yet run
unverified (harvested, no recorded run)
felixleopoldo/cslearn/src/cslearn/examp_datasets.py
code served (permissive licence) · get_code("357af2038c2dae1c")
How it ran

no invocation recorded.

Also present in other papers' code

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

Several approaches to graphically representing context-specific relations among jointly distributed categorical variables have been proposed, along with structure learning algorithms. While existing optimization-based methods have limited scalability due to the large number of context-specific models, the constraint-based methods are more prone to error than even constraint-based directed acyclic graph learning algorithms since more relations must be tested. We present an algorithm for learning context-specific models that scales to hundreds of variables. Scalable learning is achieved through a combination of an order-based Markov chain Monte-Carlo search and a novel, context-specific sparsity assumption that is analogous to those typically invoked for directed acyclic graphical models. Unlike previous Markov chain Monte-Carlo search methods, our Markov chain is guaranteed to have the true posterior of the variable orderings as the stationary distribution. To implement the method, we solve a first case of an open problem recently posed by Alon and Balogh. Future work solving increasingly general instances of this problem would allow our methods to learn increasingly dense models. The method is shown to perform well on synthetic data and real world examples, in terms of both accuracy and scalability.

For agents

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

get_harvested_code_for_paper("2402.07762")
get_code_for_paper("2402.07762")
have("2402.07762")

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

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

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

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

Connect an agent — have() is free.