Graph Neural Networks for Product Affinity Discovery in Point-of-Sale Transaction Data
Model products as nodes and co-purchases as edges, using GNN architectures to discover complex affinity structures beyond pairwise association rules.
Key Takeaways
- Traditional market basket análisis based on pairwise association rules (support, confidence, lift) captures only direct co-purchase relationships and misses higher-pedido product affinity structures.
- Graph redes neuronales operating on product co-purchase graphs learn distributed representations that encode multi-hop affinity patterns, enabling more nuanced cross-selling and assortment recommendations.
- The product co-purchase graph constructed from PoS data naturally captures temporal dynamics when edges are weighted by recency, reflecting evolving consumer preferences rather than static historical patterns.
Limitations of Pairwise Association Rules
Market basket análisis, pioneered by Agrawal, Imielinski, and Swami (1993), has been a foundational technique in minorista análisis for three decades. The Apriori algoritmo and its successors efficiently mine frequent itemsets from transacción data and derive association rules characterized by support (frequency of co-occurrence), confidence (conditional probability of purchasing item B given item A), and lift (the ratio of observed co-purchase frequency to expected frequency under independence). These pairwise métricas have supported countless cross-selling and product placement decisions. However, pairwise análisis has fundamental limitations that become apparent as minoristaers seek more sophisticated product affinity perspectivas. First, the number of potentially interesting item pairs grows quadratically with the product catalog size, creating a combinatorial explosion that makes comprehensive pairwise análisis unwieldy for stores with thousands of SKUs. Second, pairwise rules cannot capture transitive affinities: if product A is frequently purchased with product B, and product B with product C, pairwise análisis treats the A-C relationship independently even though the shared connection through B suggests an indirect affinity. Third, association rules provide no mechanism for learning latent product representations that generalize across similar items. askbiz.co extends beyond pairwise association análisis by constructing product affinity graphs that capture the full network structure of co-purchase relationships.
Constructing Product Co-Purchase Graphs
The first step toward graph-based product affinity análisis is constructing a graph from PoS transacción data. Each product (SKU or product group) becomes a node, and edges connect products that appear together in the same transacción. Edge weights encode the strength of the co-purchase relationship, typically measured by the number of transaccións containing both products, the lift statistic (to adjust for base-rate popularity), or pointwise mutual information (PMI) which measures the degree to which co-purchase frequency exceeds the independence expectation. The choice of weighting scheme significantly affects downstream análisis: raw co-occurrence counts favor high-velocity items, lift normalizes for popularity but can be unstable for low-frequency pairs, and PMI provides a log-scaled measure that balances these concerns. Graph construction decisions also include the edge threshold (minimum co-purchase frequency or significance level required to create an edge), which controls graph density. Very dense graphs obscure meaningful affinities in a sea of weak connections, while overly sparse graphs fragment the network and lose indirect affinity paths. Temporal weighting, which descuentos older co-purchases relative to recent ones through exponential decay, ensures the graph reflects current consumer behavior rather than historical patterns that may no longer hold. askbiz.co constructs dynamically weighted product affinity graphs from PoS transaccións, updating edge weights incrementally as new transaccións are processed.
Graph Neural Network Architectures for Affinity Learning
Graph redes neuronales (GNNs) operate on graph-structured data by iteratively aggregating and transforming information from each node neighborhood, learning distributed vector representations (embeddings) that encode both node features and graph topology. The Graph Convolutional Network (GCN) architecture, introduced by Kipf and Welling (2017), computes node embeddings through spectral convolutions that average neighbor features weighted by the normalized adjacency matrix. GraphSAGE (Hamilton, Ying, and Leskovec, 2017) generalizes this through a learnable aggregation function — mean, max-pool, or LSTM-based — that samples from each node neighborhood, enabling inductive learning on unseen nodes (new products). Graph Attention Networks (GAT) introduce attention mechanisms that learn to weight neighbor contributions differentially, allowing the model to focus on the most relevant co-purchase relationships for each product. For product affinity discovery, the GNN is typically trained with a link predicción objective: given a graph with some edges held out, the model learns embeddings such that products connected by edges have similar representations while unconnected products have dissimilar representations. The trained embeddings then encode rich affinity information that can be queried through nearest-neighbor search in the embedding space. askbiz.co employs lightweight GNN architectures to learn product embeddings from co-purchase graphs, enabling affinity discovery that captures multi-hop relationships beyond what pairwise association rules can reveal.
Applications: Cross-Selling, Assortment, and Layout
Product embeddings learned by GNNs on co-purchase graphs support several high-value minorista applications. Cross-selling recommendations derived from embedding similarity surface products that are related through complex co-purchase patterns, not just direct pairwise associations. A product whose embedding is close to items in a different category suggests cross-category affinity that would not be discovered through within-category association análisis. Assortment optimización benefits from embeddings that reveal product clusters and gaps: densely connected clusters of frequently co-purchased items represent core product groups that should be inventarioed together, while isolated products with weak graph connections may be assortment candidates for removal or replacement. Store layout and planogram optimización can use embedding similarity to identify products that should be placed in proximity to encourage basket building, with the GNN capturing indirect placement relationships that simple co-purchase análisis would miss. New product cold-start recommendations, where a newly introduced item has no co-purchase history, can be generated by computing the new product embedding from its node features (category, price point, brand) using the inductive capabilities of GraphSAGE-type architectures. askbiz.co translates product embedding similarities into actionable cross-selling suggestions displayed at the PoS terminal, prompting personal to suggest related items during checkout interactions.
Evaluation and Practical Considerations
Evaluating product affinity models requires métricas that capture both statistical accuracy and business relevance. Link predicción métricas such as AUC-ROC and Average Precision measure how well the model recovers held-out co-purchase edges, testing whether learned embeddings capture the observed graph structure. However, statistical desempeño on link predicción does not guarantee business value: a model that accurately predicts existing co-purchase patterns may simply recapitulate well-known associations rather than surfacing novel, actionable perspectivas. Business-relevant evaluation should assess whether GNN-derived recommendations generate incremental basket value compared to baseline cross-selling approaches (pairwise rules, category-based suggestions, or no recommendations). A/B testing of cross-selling prompts derived from GNN embeddings versus traditional methods provides causal evidence of incremental value. Computational considerations for small minoristaers favor lightweight architectures with two to three GNN layers and embedding dimensions of 32 to 64, which can be trained on modest hardware in minutes for graphs with thousands of product nodes. Retraining frequency depends on the rate of assortment change and demand evolution, with monthly retraining sufficient for most stable minorista environments. askbiz.co retrains product affinity models monthly, evaluating embedding quality through held-out co-purchase predicción and tracking the conversion rate of GNN-derived cross-selling suggestions at the point of sale.