SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2409.12067 · 2024

Fitting Multilevel Factor Models

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 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 0 have no contract verdict; 6 failures of our instrument; 4 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/2409.12067.json · badge: /api/ran/2409.12067.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
cvxgrp/multilevel_factor_model canonical (classifier label)
classifier basis: census
6 ran · 4 no recorded run
FunctionStatusWhere it lives
low_rank_approx Ran
ran; our contract draft was wrong, not the code
cvxgrp/multilevel_factor_model/mfmodel/utils.py
code served (permissive licence) · get_code("ed6ba062dc566cc8")
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 scipy.sparse import csr_matrix

# Create a small test matrix for low rank approximation
# Using a rectangular matrix with distinct dimensions
np.random.seed(0)
A_dense = np.random.randn(5, 3)

# Convert to sparse matrix format (scipy.sparse.linalg.svds works with sparse matrices)
A = csr_matrix(A_dense)

# Set up parameters
dim = 2  # Request low rank approximation with rank 2
symm = False  # Not symmetric
v0 = None  # No initial guess vector

ARGS = {
    'A': A,
    'dim': dim,
    'symm': symm,
    'v0': v0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — 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
mlr_matvec Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cvxgrp/multilevel_factor_model/mfmodel/mlr_matmul.py
code served (permissive licence) · get_code("1a5c621581bac650")
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, 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 scipy.sparse

# Construct hpart dictionary with required structure
# hpart needs 'pi', 'pi_inv', and 'lk' (level keys)
hpart = {
    'pi': np.array([0, 1, 2, 3]),  # permutation indices
    'pi_inv': np.array([0, 1, 2, 3]),  # inverse permutation
    'lk': [
        np.array([0, 2, 4]),  # level 0: 2 blocks of size 2
        np.array([0, 1, 2, 3, 4])  # level 1: 4 blocks of size 1
    ]
}

# x0: input vector, will be reshaped to column if needed
x0 = np.array([1.0, 2.0, 3.0, 4.0])

# B: matrix with shape matching the hierarchical structure
# Shape should be (4, sum_of_ranks) where sum_of_ranks relates to ranks parameter
# B will be indexed as B[r1:r2, ranks[:level].sum():ranks[:level+1].sum()]
B = np.random.randn(4, 5)

# C: similar shape to B, used for matrix operations
C = np.random.randn(4, 5)

# ranks: array of rank values for each level
# Used to compute cumulative sums for column indexing into B and C
ranks = np.array([2, 3])

ARGS = {
    'x0': x0,
    'B': B,
    'C': C,
    'hpart': hpart,
    'ranks': ranks
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
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, 1) — shape (4, 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
mult_blockdiag_refined_AtB Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cvxgrp/multilevel_factor_model/mfmodel/inverse.py
code served (permissive licence) · get_code("d50500faeebdccd4")
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 (8, 5) 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

# Analyze the function to understand what A, B, lk_A, lk_B should be:
# - A and B are numpy arrays (compressed format for block diagonal matrices)
# - lk_A and lk_B are numpy arrays that specify block boundaries
# - Assertions check:
#   - lk_A.size >= lk_B.size
#   - lk_B[-1] == B.shape[0]
#   - lk_A[-1] in A.shape
# - Loop iterates: for block_A in range(num_blocks_A) where num_blocks_A = lk_A.size - 1
# - Operations: A[r1:r2].T @ B[r1:r2]
#   - A needs shape (rows, cols) where rows can be sliced
#   - B needs shape (rows, cols) where rows can be sliced
#   - Result has shape (A.shape[1] * (lk_A.size - 1), B.shape[1])

# Set up small example:
# Let's use:
# - lk_A = [0, 3, 6] (2 blocks, rows 0-3 and 3-6)
# - lk_B = [0, 3, 6] (2 blocks, rows 0-3 and 3-6)
# - A shape: (6, 4) - 6 rows, 4 columns
# - B shape: (6, 5) - 6 rows, 5 columns

lk_A = np.array([0, 3, 6], dtype=np.int64)
lk_B = np.array([0, 3, 6], dtype=np.int64)

A = np.random.randn(6, 4)
B = np.random.randn(6, 5)

ARGS = {
    "A": A,
    "lk_A": lk_A,
    "B": B,
    "lk_B": lk_B,
}
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 (8, 5) — shape (8, 5) 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
mult_blockdiag_refined_BCt Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cvxgrp/multilevel_factor_model/mfmodel/mlr_matmul.py
code served (permissive licence) · get_code("ef521c44c1904120")
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, 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

# Analyze the function to understand the requirements:
# - B: numpy array, shape (num_samples, num_blocks_C * C.shape[1])
# - lk_B: numpy array of indices, size <= lk_C.size, last element in B.shape
# - C: numpy array, shape (num_rows_C, num_features)
# - lk_C: numpy array of indices, size determines num_blocks_C, last element in C.shape

# The function:
# - Accesses lk_B.size and lk_C.size
# - Accesses B.shape and C.shape
# - Accesses lk_C[block_C] and lk_C[block_C + 1]
# - Performs matrix multiplication: B @ C[r1:r2].T
# - Creates output of shape (C.shape[0], B.shape[0])

# Let's construct valid arguments:
# num_blocks_C = lk_C.size - 1
# We need lk_B[-1] in B.shape and lk_C[-1] in C.shape

# Example setup:
num_blocks_C = 2
C_cols = 3  # C.shape[1], also lk_C[-1]
B_rows = 4  # B.shape[0]
C_rows = 5  # C.shape[0], also lk_C[-1] should be in C.shape

# lk_C represents block boundaries for C's rows
# If we have 2 blocks with 5 total rows: [0, 2, 5] for example
lk_C = np.array([0, 2, 5], dtype=np.int64)  # size = 3, so num_blocks_C = 2, last element = 5

# C.shape should have 5 (lk_C[-1]) as one dimension
C = np.random.randn(5, 3)  # shape (5, 3), lk_C[-1] = 5 is in C.shape

# B.shape[1] should be num_blocks_C * C.shape[1] = 2 * 3 = 6
# B.shape[0] should be B_rows = 4
B = np.random.randn(4, 6)  # shape (4, 6)

# lk_B: size <= lk_C.size (3), last element in B.shape
# B.shape = (4, 6), so lk_B[-1] must be 4 or 6
# Let's make it reference the column dimension or row dimension
# The assertion checks: lk_B[-1] in B.shape
# We can use lk_B with last element = 4 (B.shape[0]) or 6 (B.shape[1])
lk_B = np.array([0, 2, 4], dtype=np.int64)  # size = 3 <= 3, last element = 4 in B.shape

ARGS = {
    "B": B,
    "lk_B": lk_B,
    "C": C,
    "lk_C": lk_C,
}
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, 4) — shape (5, 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
mult_blockdiag_refined_CtB Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cvxgrp/multilevel_factor_model/mfmodel/mlr_matmul.py
code served (permissive licence) · get_code("5aad5be17baa3de7")
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 (7, 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

# Analyze the function requirements:
# C: 2D array, shape (r_C, some_dim), indexed by rows [r1:r2]
# lk_C: 1D array, where lk_C[-1] must be in C.shape
# B: 2D array, indexed by rows [r1:r2], B.shape[1] is used
# lk_B: 1D array, where lk_B[-1] must be in B.shape
# Constraint: lk_C.size <= lk_B.size and lk_B[-1] in B.shape and lk_C[-1] in C.shape

# Create small block structure:
# lk_B defines block boundaries, so lk_B.size - 1 = num_blocks_B
# Let's say we have 2 blocks in B, so lk_B.size = 3
# lk_B values should go from 0 to some row index in B

# Set up dimensions:
# B has 6 rows (so lk_B can go 0->3->6)
# C has 7 columns (arbitrary, but different from B's rows)
# lk_B.size = 3 means 2 blocks
# lk_C.size can be at most 3 (constraint: lk_C.size <= lk_B.size)

B = np.array([[1.0, 2.0], 
              [3.0, 4.0],
              [5.0, 6.0],
              [7.0, 8.0],
              [9.0, 10.0],
              [11.0, 12.0]], dtype=np.float64)  # shape (6, 2)

C = np.array([[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
              [8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0],
              [15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0],
              [22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0],
              [29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0],
              [36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0]], dtype=np.float64)  # shape (6, 7)

# lk_B defines block boundaries: blocks are [0:3] and [3:6]
lk_B = np.array([0, 3, 6], dtype=np.int64)  # size = 3, last element 6 is in B.shape
# lk_C can be smaller or equal size, and lk_C[-1] must be in C.shape (7)
lk_C = np.array([0, 3, 7], dtype=np.int64)  # size = 3, last element 7 is in C.shape

ARGS = {
    "C": C,
    "lk_C": lk_C,
    "B": B,
    "lk_B": lk_B,
}
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 (7, 4) — shape (7, 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
mult_blockdiag_refined_CtB_vh Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cvxgrp/multilevel_factor_model/mfmodel/inverse.py
code served (permissive licence) · get_code("dda08af0aa8b1a20")
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, 6) 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

# Analyze the function:
# - C: shape (... x r_C), used as C[block_B * B.shape[0]:(block_B + 1) * B.shape[0]].T
#   This means C has shape (num_blocks_B * B.shape[0] x r_C)
# - lk_C: numpy array, used with .size and lk_C[-1], checked against C.shape
# - B: shape (r_B x ...), used as B[:, r1:r2] and B.shape[1]
#   This means B has shape (r_B x num_blocks_B * r_B)
# - lk_B: numpy array, used with .size and indexing [block_B] and [block_B + 1]
#   Represents block boundaries

# Let's construct small valid inputs:
# num_blocks_B = 2 (so lk_B has size 3)
# r_B = 3
# r_C = 4
# B.shape[0] = 3, so C first dimension = 2 * 3 = 6

num_blocks_B = 2
r_B = 3
r_C = 4
B_rows = r_B

# lk_B: block boundaries for B columns
# If num_blocks_B = 2, we need 3 values: [0, 3, 6]
# This divides B's columns (0:3 and 3:6)
lk_B = np.array([0, 3, 6], dtype=np.int64)

# lk_C: block boundaries for C rows
# Must have size <= lk_B.size (3 <= 3, ok)
# lk_C[-1] must be in C.shape
# C will have shape (6, 4), so lk_C[-1] should be 6
lk_C = np.array([0, 6], dtype=np.int64)

# C: shape (6, 4) - vertical blockdiagonal
# Rows correspond to num_blocks_B * B.shape[0] = 2 * 3 = 6
# Cols correspond to r_C = 4
C = np.random.randn(6, 4)

# B: shape (3, 6) - horizontal blockdiagonal
# Rows correspond to r_B = 3
# Cols correspond to num_blocks_B * r_B = 2 * 3 = 6
B = np.random.randn(3, 6)

ARGS = {
    "C": C,
    "lk_C": lk_C,
    "B": B,
    "lk_B": lk_B,
}
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 (4, 6) — shape (4, 6) 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
fast_EM_intermediate_matrices Not yet run
unverified (harvested, no recorded run)
cvxgrp/multilevel_factor_model/mfmodel/fast_em_algorithm.py
code served (permissive licence) · get_code("2cfe05d7bb11a40c")
How it ran

no invocation recorded.

fast_EM_intermediate_matrices_base Not yet run
unverified (harvested, no recorded run)
cvxgrp/multilevel_factor_model/mfmodel/fast_em_algorithm.py
code served (permissive licence) · get_code("c1dbdfef767b82d5")
How it ran

no invocation recorded.

fit Not yet run
unverified (harvested, no recorded run)
cvxgrp/multilevel_factor_model/mfmodel/fast_em_algorithm.py
code served (permissive licence) · get_code("97c969723353df2a")
How it ran

no invocation recorded.

mult_blockdiag_refined_AB Not yet run
unverified (harvested, no recorded run)
cvxgrp/multilevel_factor_model/mfmodel/inverse.py
code served (permissive licence) · get_code("d9b225109527d824")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 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.

FunctionAlso present inEarliest-datedOthers named
mult_blockdiag_refined_BCt 1 other paper
1 dated earlier
2310.19214 (2023-10)
Factor Fitting, Rank Allocation, and Partitioning in Multilevel Low Rank Matrices
mult_blockdiag_refined_CtB 1 other paper
1 dated earlier
2310.19214 (2023-10)
Factor Fitting, Rank Allocation, and Partitioning in Multilevel Low Rank Matrices

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

We examine a special case of the multilevel factor model, with covariance given by multilevel low rank (MLR) matrix~\cite{parshakova2023factor}. We develop a novel, fast implementation of the expectation-maximization algorithm, tailored for multilevel factor models, to maximize the likelihood of the observed data. This method accommodates any hierarchical structure and maintains linear time and storage complexities per iteration. This is achieved through a new efficient technique for computing the inverse of the positive definite MLR matrix. We show that the inverse of positive definite MLR matrix is also an MLR matrix with the same sparsity in factors, and we use the recursive Sherman-Morrison-Woodbury matrix identity to obtain the factors of the inverse. Additionally, we present an algorithm that computes the Cholesky factorization of an expanded matrix with linear time and space complexities, yielding the covariance matrix as its Schur complement. This paper is accompanied by an open-source package that implements the proposed methods.

For agents

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

get_harvested_code_for_paper("2409.12067")
get_code_for_paper("2409.12067")
have("2409.12067")

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

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

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

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

Connect an agent — have() is free.