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

Flexible constrained sampling with guarantees for pattern mining

Vladimir Dzyuba, Matthijs van Leeuwen, Luc De Raedt · DOI

Abstract

Pattern sampling has been proposed as a potential solution to the infamous pattern explosion. Instead of enumerating all patterns that satisfy the constraints, individual patterns are sampled proportional to a given quality measure. Several sampling algorithms have been proposed, but each of them has its limitations when it comes to 1) flexibility in terms of quality measures and constraints that can be used, and/or 2) guarantees with respect to sampling accuracy. We therefore present Flexics, the first flexible pattern sampler that supports a broad class of quality measures and constraints, while providing strong guarantees regarding sampling accuracy. To achieve this, we leverage the perspective on pattern mining as a constraint satisfaction problem and build upon the latest advances in sampling solutions in SAT as well as existing pattern mining algorithms. Furthermore, the proposed algorithm is applicable to a variety of pattern languages, which allows us to introduce and tackle the novel task of sampling sets of patterns. We introduce and empirically evaluate two variants of Flexics: 1) a generic variant that addresses the well-known itemset sampling task and the novel pattern set sampling task as well as a wide range of expressive constraints within these tasks, and 2) a specialized variant that exploits existing frequent itemset techniques to achieve substantial speed-ups. Experiments show that Flexics is both accurate and efficient, making it a useful tool for pattern-based data exploration.

The Challenge of Pattern Explosion

In data mining, we often look for "patterns" (like sets of items frequently bought together). However, we face the pattern explosion: even a small dataset can contain an astronomical number of valid patterns, making it impossible to look at them all. Traditional solutions either try to find the "top-k" patterns (which often lack diversity) or use "constrained mining" (which might return too few or too many results).

A newer approach is pattern sampling, where we pick patterns randomly with a probability proportional to their "interestingness." However, as shown in the comparison below, existing samplers have historically been either too rigid—supporting only specific measures like frequency—or lacked mathematical proof that the samples they produce actually follow the intended distribution.

Comparison of Flexics with existing pattern samplers across key features.

Methods: Bridging Data Mining and SAT Solvers

The authors introduce Flexics, the first pattern sampling algorithm that combines extreme flexibility with rigorous theoretical guarantees. Flexics is built on two main pillars:

  1. Pattern Mining as CSP: They frame pattern mining as a Constraint Satisfaction Problem (CSP). This allows them to use a "constraint oracle"—essentially a search engine that finds patterns satisfying specific rules. This formulation allows for the expression of diverse constraints such as coverage, closedness, and minimum length (see Figure 2).
  2. XOR-based Hashing: To sample without enumerating everything, Flexics uses a technique called WeightGen. It adds random XOR constraints to the problem, which mathematically "slices" the space of all possible patterns into smaller "cells." By estimating the total weight of these cells and picking a pattern from a random one, the algorithm provides a provable guarantee: the probability of picking a pattern is within a known, narrow range of its true quality.
Constraint Programming (CP) formulations for common pattern mining constraints.

The paper introduces two versions of the algorithm:

  • GFlexics (Generic): A "Swiss Army Knife" version that uses a declarative constraint programming solver (cp4im). It can handle almost any constraint.
  • EFlexics (Efficient): A specialized version built on the Eclat algorithm, optimized for speed in frequent itemset mining.

Key Insights and Results

The authors evaluated Flexics on a variety of standard benchmarks, ranging from small datasets like heart to large-scale datasets like accidents, which contains over 5.37 billion frequent patterns.

  • Accuracy: Using Jensen-Shannon (JS) divergence, the authors showed that Flexics' empirical distribution is nearly identical to the ideal target distribution. For 90% of patterns, the sampling error was less than a factor of 2.
  • Scalability: EFlexics successfully sampled from the accidents dataset in about 10 seconds per sample, whereas a baseline ideal sampler would take significantly longer just to count the patterns.
  • Sampling Sets, Not Just Items: One of the most powerful insights is that Flexics can sample sets of patterns (e.g., "tilings"). This is much harder than sampling individual items because the "interestingness" depends on how the patterns in the set interact (e.g., they shouldn't overlap). Flexics handles this by simply treating the set as a "composite" pattern in the CSP.
  • The "Anytime" Advantage: Unlike traditional miners that make you wait until the end of a long search, Flexics is an "anytime" algorithm. You can start getting high-quality, diverse samples almost immediately.

Limitations and Future Work

Despite its strengths, Flexics has limitations. The algorithm assumes a "bounded tilt"—meaning the most interesting pattern isn't infinitely more interesting than the least interesting one. If the quality measure has a very high tilt (like $\chi^2$), the algorithm becomes inefficient. Additionally, on extremely sparse datasets with a huge number of items (like kosarak), the XOR constraints become computationally expensive to propagate.

Future work may involve specializing XOR propagation for specific types of constraints, such as anti-monotonicity, to further boost performance in these challenging scenarios.

Summary updated

BibTeX
@article{dzyuba2016flexible,
  author = {Vladimir Dzyuba and Matthijs van Leeuwen and Luc De Raedt},
  title = {{Flexible constrained sampling with guarantees for pattern mining}},
  journal = {Data Min. Knowl. Discov.},
  year = {2016},
  doi = {10.1007/s10618-017-0501-6},
}
Figure