SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2208.01724 · ICML · 2022

A Tighter Analysis of Spectral Clustering, and Beyond *

Peter Macgregor

arXiv · PDF · Open in the Atlas

Code that ran

2 of 2 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-22; 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/2208.01724.json · badge: /api/ran/2208.01724.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
pmacg/spectral-clustering-meta-graphs canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
get_bsd_num_cluster Ran
ran, honoured the contract we drafted
pmacg/spectral-clustering-meta-graphs/experiments.py
code served (permissive licence) · get_code("0ae09a1dcc88468f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) 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 scipy as sp
import numpy
import tempfile
import os

# Create a mock BSDS ground truth .mat file
# The function expects a .mat file with a 'groundTruth' field
# groundTruth is a structured array where each element contains segmentation data
# The structure is: groundTruth[0, i][0][0][0] contains the segmentation matrix

# Create temporary file
temp_file = tempfile.NamedTemporaryFile(mode='wb', suffix='.mat', delete=False)
temp_filename = temp_file.name
temp_file.close()

# Create mock ground truth data structure
# We'll create 3 ground truth segmentations with different numbers of segments
num_segmentations = 3

# Create segmentation matrices (small images with segment labels)
seg1 = numpy.array([[1, 1, 2], [1, 2, 2], [3, 3, 3]])  # 3 segments
seg2 = numpy.array([[1, 2, 2], [1, 2, 3], [4, 4, 4]])  # 4 segments
seg3 = numpy.array([[1, 1, 1], [2, 2, 3], [2, 3, 3]])  # 3 segments

# BSDS groundTruth structure is complex - it's a cell array of structs
# Each cell contains a struct with 'Segmentation' field (and others)
# We need to create: groundTruth[0, i][0][0][0] to access the segmentation

# Create the nested structure that BSDS uses
gt_list = []
for seg in [seg1, seg2, seg3]:
    # Create nested structure: each groundTruth element is a cell containing a struct
    # The struct has a 'Segmentation' field at index 0
    inner_struct = numpy.array([(seg,)], dtype=object)
    middle_struct = numpy.array([inner_struct], dtype=object)
    gt_list.append(middle_struct)

# Create the groundTruth array as a 1xN cell array
groundTruth = numpy.empty((1, num_segmentations), dtype=object)
for i, gt in enumerate(gt_list):
    groundTruth[0, i] = gt

# Save to .mat file
sp.io.savemat(temp_filename, {'groundTruth': groundTruth})

ARGS = {
    'gt_filename': temp_filename
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy, scipy — 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
sc_precomputed_eigenvectors Ran
ran; our contract draft was wrong, not the code
pmacg/spectral-clustering-meta-graphs/pysc/sc.py
code served (permissive licence) · get_code("77567d0e18be2b45")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned list. 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

np.random.seed(0)

# Create precomputed eigenvectors
# Let's say we have 10 data points and 5 eigenvectors
num_data_points = 10
total_eigenvectors = 5
eigvecs = np.random.randn(num_data_points, total_eigenvectors)

# Normalize eigenvectors (typical in spectral clustering)
eigvecs = eigvecs / np.linalg.norm(eigvecs, axis=1, keepdims=True)

num_clusters = 3
num_eigenvectors = 4

ARGS = {
    'eigvecs': eigvecs,
    'num_clusters': num_clusters,
    'num_eigenvectors': num_eigenvectors
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list 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

Also present in other papers' code

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

This work studies the classical spectral clustering algorithm which embeds the vertices of some graph G = (V G , E G ) into R k using k eigenvectors of some matrix of G, and applies k-means to partition V G into k clusters. Our first result is a tighter analysis on the performance of spectral clustering, and explains why it works under some much weaker condition than the ones studied in the literature. For the second result, we show that, by applying fewer than k eigenvectors to construct the embedding, spectral clustering is able to produce better output for many practical instances; this result is the first of its kind in spectral clustering. Besides its conceptual and theoretical significance, the practical impact of our work is demonstrated by the empirical analysis on both synthetic and real-world datasets, in which spectral clustering produces comparable or better results with fewer than k eigenvectors.

For agents

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

get_harvested_code_for_paper("2208.01724")
get_code_for_paper("2208.01724")
have("2208.01724")

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

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

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

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

Connect an agent — have() is free.