Starting from the LHS feature space , this project automatically constructs a multi-level grid structure, performs RHS distribution clustering within each local region , and—through incremental expansion, quality evaluation, boundary backtracking, and cooperative optimization —discovers stable, interpretable, and generalizable LHS→RHS mapping patterns (region-based rules) .
In many real-world data scenarios:
-
A single global model struggles to explain local patterns
-
RHS distributions can vary significantly across different LHS regions
(unimodal / multimodal / noisy)
-
Directly clustering RHS ignores the structure of the LHS space
-
Directly partitioning LHS does not guarantee RHS stability
The core idea of this project is:
Using the spatial structure of LHS as the backbone, and RHS distribution consistency as the constraint, to progressively identify LHS regions where RHS exhibits stable and meaningful structures.
This is not a black-box predictive model, but an interpretable pattern discovery and rule construction system .
The overall workflow can be summarized in one sentence:
Partition LHS first, validate RHS next; model locally, expand incrementally; detect boundaries, then co-optimize them.
The system emphasizes the following principles:
- Structure-first : build the spatial structure of the LHS space (grids / intervals)
- Local modeling : model RHS independently within each grid cell
- Incremental evaluation : evaluate only newly added samples during expansion
- Interpretable boundaries : explicitly identify where stability breaks down
- Reusable outputs : produce structured grid packs instead of one-off models
-
Recursively partition the multi-dimensional LHS feature space
(KD-Tree / Quadtree-style splitting)
-
Construct multi-level, multi-resolution LHS grids (cells)
-
Record sample counts per cell and enforce minimum sample thresholds
Goal : build a structured grid backbone that covers the entire LHS space.
- Evaluate RHS distribution consistency within each leaf cell:
- Class entropy / dominant class ratio
- Variance / peak shape / dispersion
- Filter out cells with unstable RHS distributions or insufficient samples
- Retain cells that meet stability thresholds as Base Cells
Goal : focus modeling efforts only on LHS regions worth analyzing.
- Perform lightweight clustering of RHS within each base cell:
- GMM / HDBSCAN / MeanShift
- For 1D RHS: KDE or peak-count analysis
- Record clustering structure and quality metrics:
- Number of clusters (k)
- Centers / covariance
- Silhouette score, BIC / AIC
- Minimum inter-cluster distance (e.g., Mahalanobis distance)
Goal : obtain a structural description of RHS distributions within each local LHS region.
- Starting from base cells, expand incrementally along one or more LHS dimensions
- Evaluate only newly added samples :
- Whether they can be absorbed by existing RHS clusters
- Nearest-center assignment / responsibility / density compatibility
- Compute key metrics:
- Known-cluster absorption rate α
- Unmatched ratio (1 − α)
- High-uncertainty ratio β
- Global quality changes (ΔSilhouette, ΔBIC, Δinter-cluster distance)
Principle :
Trigger local structural updates only when differences are significant , avoiding full re-clustering.
- Record event sequences during expansion:
- reinforce / shift / split / merge / new / noise
- Backtrack over a historical window to detect:
- Unimodal → multimodal transitions
- Significant quality degradation or improvement
- Identify the step with structural change as the optimal LHS boundary
- Mark high-uncertainty regions (boundary bands)
Goal : explicitly define the effective range of stable patterns.
- Construct a narrow boundary band around candidate boundaries
- Perform coordinate-descent-style refinement along LHS dimensions:
-
Rapidly realign RHS within the current interval
(K-means / weighted K-means / Gravity K-means)
-
Evaluate the objective function:
-
J=Purity+α⋅Silhouette−β⋅Leakage−γ⋅ComplexityJ = \text{Purity}
- \alpha \cdot \text{Silhouette}
- \beta \cdot \text{Leakage}
- \gamma \cdot \text{Complexity}J=Purity+α⋅Silhouette−β⋅Leakage−γ⋅Complexity
- Accept boundary shifts if J improves; otherwise revert
- Iterate across dimensions until convergence or iteration limits
Outputs :
- Refined LHS boundaries
- Updated RHS clustering parameters
PatternGridMapper/ ├─ backend/ │ └─ src/ │ ├─ data/ │ │ ├─ raw/ # Raw datasets (e.g., wine_quality) │ │ └─ processed/ # Preprocessed data + metadata │ ├─ preprocessors/ # Dataset preprocessing logic │ ├─ grid_partition/ # LHS grid / interval construction │ ├─ evaluation/ # RHS clustering evaluation and judgment │ ├─ region_expansion/ # Incremental LHS region expansion │ ├─ grid_pipeline/ # End-to-end clustering & boundary pipeline │ ├─ data_io/ # File I/O utilities │ └─ output/ │ └─ grid_packs/ # Final structured pattern artifacts │ ├─ cells/ # RHS clustering results per grid cell │ ├─ flat_index.jsonl # Flat index for fast lookup │ └─ packs_summary.json # Global summary ├─ tests/ ├─ frontend/ # Visualization / interaction (reserved) ├─ README_en.md ├─ README_cn.md └─ requirements.txt
The final outputs of this project are not model weights , but:
- Grid Packs : structured LHS→RHS regional patterns
- Each cell contains:
- LHS interval definition
- RHS clustering structure
- Quality metrics
- Boundary and uncertainty information
These artifacts support:
- Rule interpretation
- Pattern retrieval
- Transfer analysis
- Downstream embedding / graph construction / LLM-based abstraction
- Interpretable pattern discovery (Pattern Mining)
- Region-based rule extraction (Rule Discovery)
- Local modeling under complex distributions
- Feature space segmentation and analysis
- Structured knowledge construction (Tree + Grid + Graph)
PatternGridMapper is a structured rule mining system that uses LHS spatial structure as the backbone and RHS distribution stability as the constraint , and—through incremental expansion and boundary co-optimization —automatically discovers interpretable, region-based patterns .