NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Constraints as Features

Shmuel Asafi, Daniel Cohen-OrCVPR 2013

Introduction

Clustering is a fundamental unsupervised learning task aimed at discovering inherent groupings in data. In many real-world scenarios, however, a user may possess prior knowledge about which items should or should not be grouped together. This leads to "semi-supervised" clustering, typically defined by two types of pairwise constraints: Must-link (ML), where two points must reside in the same cluster, and Cannot-link (CL), where they must be separated.

While ML constraints are relatively straightforward to implement by reducing distances between points, CL constraints are notoriously difficult. They lack transitivity and often require complex, algorithm-specific optimizations that can lead to instability or poor convergence. In their CVPR 2013 paper, Shmuel Asafi and Daniel Cohen-Or propose a "lateral thinking" solution: instead of modifying the clustering algorithm, they modify the data itself by treating constraints as additional features.

Methodology: Transforming Constraints into Dimensions

The core innovation of this work is the augmentation of the feature space. By adding new dimensions derived from constraints, the authors transform a difficult constrained problem into a standard unconstrained one.

Must-links are handled using a standard distance-shortening approach. The distance between ML pairs is set to a minimum value, and the all-pairs shortest paths are recalculated to maintain the triangle inequality, effectively "gluing" the points together in the manifold.

For every CL constraint between two points $c_1$ and $c_2$, a new dimension is added to the dataset. In this new dimension:

  1. The point $c_1$ is assigned a value of $+1$.
  2. The point $c_2$ is assigned a value of $-1$.
  3. All other points are assigned values between $-1$ and $+1$ based on their connectivity to $c_1$ and $c_2$ on the data manifold.

To determine these intermediate values, the authors utilize Diffusion Maps. This approach measures "walking distance" rather than simple Euclidean distance, ensuring that the influence of the constraint propagates naturally through the data's underlying structure. If a point $A$ is highly connected to $c_1$, it will receive a value close to $+1$, effectively pushing it away from $c_2$ in the augmented space.

The transformation process: adding a dimension for a CL constraint separates clusters in the augmented space.

Final Clustering

Once the original $M$-dimensional space is augmented with $N$ new dimensions (one for each CL constraint), any off-the-shelf clustering algorithm—such as K-means or Spectral Clustering—can be applied to the resulting $(M+N)$-dimensional data. This "algorithm-agnostic" nature is a significant advantage, as it allows practitioners to use well-optimized, standard tools.

Experimental Results

The authors evaluated their "Features" approach against several state-of-the-art constrained clustering methods across diverse datasets:

  • Image Segmentation: Using the Berkeley Segmentation Dataset (BSD), the method was tested on 117 images using super-pixels as data points. In a massive evaluation of over 4,600 runs, the proposed method outperformed competitors like Affinity Propagation and ITML in nearly half of all cases.
  • UCI Benchmarks: Tests on classic datasets (Iris, Wine, Hepatitis, Ionosphere) demonstrated that the method reaches high accuracy with significantly fewer constraints than traditional approaches.

Discussion and Limitations

The "Constraints as Features" approach offers several key insights:

  • Spatial Interpretation: It treats constraints as fundamental spatial coordinates rather than external penalties.
  • Robustness: The use of diffusion distances provides a "soft" influence that is more resilient to noisy or contradictory constraints compared to "hard" constraint methods.
  • Interactivity: The method is well-suited for interactive systems where a user provides feedback incrementally.

However, challenges remain. The primary limitation is scalability; adding one dimension per constraint can lead to a high-dimensional space if thousands of constraints are provided. Additionally, determining the optimal relative weight between the original features and the new constraint-based dimensions is an ongoing area of research. Despite these hurdles, the paper provides a powerful and elegant framework for integrating human knowledge into automated clustering processes.

Summary updated

BibTeX
@inproceedings{asafi2013constraints,
  author = {Shmuel Asafi and Daniel Cohen-Or},
  title = {{Constraints as Features}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2013},
  doi = {10.1109/cvpr.2013.214},
}
Figure