Skip to content

Clustering, density estimation, and anomaly detection · Graph and community clustering · UCL033 · Algorithm

Correlation clustering

Reconcile pairwise evidence that objects should be together or apart, without fixing the number of clusters. Useful for entity resolution, record linkage, and signed-network partitioning when similarity judgments may…

Explained here Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

Documented in the Academy only. There's no Set up button.

Availability
Explained here
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Reconcile pairwise evidence that objects should be together or apart, without fixing the number of clusters. Useful for entity resolution, record linkage, and signed-network partitioning when similarity judgments may conflict.

Question / hypotheses

Which partition or latent block structure best explains the supplied graph relationships? This entry defines an estimation or optimization objective, not an intrinsic null/alternative hypothesis test.

Architecture / computational structure

Signed weighted edges and a globally transitive partition optimized for disagreements.

Assumptions

The general problem is hard; approximation guarantees depend on graph completeness, weight structure, and objective variant. Pairwise similarity from a learned model may import supervised bias into an otherwise unsupervised partition stage.

Formula / computational definition

Minimize disagreements ∑(i,j)∈E+wij1(zi≠zj)+∑(i,j)∈E−wij1(zi=zj)\sum_{(i,j)\in E^+}w_{ij}\mathbf1(z_i\ne z_j)+\sum_{(i,j)\in E^-}w_{ij}\mathbf1(z_i=z_j). Positive edges favor joining; negative edges favor separation. The partition must satisfy transitivity even when input pairwise judgments do not.

Parameters and notation

Learned or fitted quantities: Cluster assignments satisfying partition transitivity. User-set hyperparameters/design choices: Specify sign thresholds, confidence weights, missing-edge treatment, and optimization method. Tune these against the stated objective and stability/validation criteria; do not select settings on the final evaluation set.

Fitting, fine-tuning, and adaptation

Neural fine-tuning is not applicable. Refit after material edge or weight changes and compare several initializations. Warm-starting a partition can help computation but may preserve an obsolete solution; use the same graph construction when comparing versions.

How to use and calibrate

Report weighted disagreement and error by edge type, plus stability to uncertain signs. In entity resolution, inspect both false merges and false splits; a low aggregate cost can hide serious rare errors.

Example application

Reconcile conflicting pairwise record-linkage decisions. Define the reference population, measurement units, and success criterion before fitting; investigate whether discovered groups or alerts reflect the intended phenomenon.

Interpretation / pitfalls

Watch out

The reported result is conditional on the representation and objective. A stable partition can reflect nuisance structure such as batch, collection site, or missingness. Confirm the interpretation in original variables and an independent sample.

Python and R code examples

For small examples, enumerate partitions or formulate a custom integer program with triangle constraints. Larger cases require a documented approximation implementation. The paired example only scores a supplied partition and does not claim to solve the optimization.

Component: Signed-graph disagreement cost. Python: executed successfully; R: not executed (Rscript unavailable). These small fixtures establish the arithmetic operation, not full-method accuracy or reproduction of paper results.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — Signed-graph disagreement cost. · needs numpy

import numpy as np
edges=np.array([[0,1],[0,2],[1,2]]); sign=np.array([1,-1,1]); z=np.array([0,0,1])
same=z[edges[:,0]]==z[edges[:,1]]
result=np.sum(((sign==1)&~same)|((sign==-1)&same))
print(result)
R

Component demo, not a trained model — Signed-graph disagreement cost.

edges=rbind(c(1,2),c(1,3),c(2,3)); sign=c(1,-1,1); z=c(1,1,2)
same=z[edges[,1]]==z[edges[,2]]; result=sum((sign==1 & !same)|(sign==-1 & same))
print(result)

Sources

From the CodeSplash reference, entry UCL033.