Algorithms for Generalized Clusterwise Linear Regression

Young Woong Park, Yan Jiang, Diego Klabjan, Loren Williams · DOI

Abstract

This paper addresses the challenge of grouping entities based on the similarity of their underlying regression models, a problem known as Clusterwise Linear Regression (CLR). While traditional CLR assumes a single observation per entity, this work introduces Generalized CLR, where each entity (such as a retail product) is associated with multiple observations. We prove that Generalized CLR is NP-hard and propose several algorithmic strategies—including an exact Column Generation approach and a high-performing Genetic Algorithm-Lloyd hybrid—to solve it. Our results demonstrate that simultaneous clustering and regression significantly outperform traditional two-stage methods in retail forecasting applications.

Introduction

In many data-driven fields, the goal is to group similar entities to improve predictive accuracy or interpretability. Standard clustering techniques, such as K-means, typically group entities based on physical or feature-based distance. However, in many contexts, we are more interested in "behavioral" similarity—how well different entities fit the same functional relationship.

Generalized Clusterwise Linear Regression (CLR) provides a framework for this task. A primary application is retail forecasting, where a retailer needs to group Stock Keeping Units (SKUs) that react similarly to seasonal effects or promotional activities. The challenge lies in the "intertwined" nature of the problem: the optimal clusters cannot be determined without knowing the regression coefficients, and the coefficients cannot be calculated without knowing the cluster assignments.

Problem Definition and Complexity

The authors identify a significant gap in existing literature: traditional CLR models assume each entity contributes only one observation to the dataset. In real-world scenarios, an entity like an SKU possesses a full time series of sales data. Generalized CLR extends the model to accommodate these multiple observations per entity.

Mathematically, the goal is to partition $N$ entities into $K$ clusters to minimize the total Sum of Squared Errors (SSE) across all linear regressions. The authors formally prove that Generalized CLR is NP-hard, justifying the use of sophisticated optimization and heuristic techniques rather than simple iterative solvers for large-scale problems.

Algorithmic Strategies

To address the computational complexity of Generalized CLR, the paper proposes four primary approaches:

  1. Exact Column Generation (CG): This optimization method decomposes the problem into a Master Problem (selecting the best clusters) and a Pricing Problem (identifying new candidate clusters). The authors demonstrate that even the Pricing Problem itself is NP-complete.
  2. GA-Lloyd Hybrid: This metaheuristic combines a Genetic Algorithm (GA) with an adapted version of Lloyd’s algorithm. The GA explores the global search space of regression coefficients, while the Lloyd’s component performs local refinement by reassigning entities to the regression model that yields the lowest error.
  3. CG Heuristic: To make the exact method tractable for larger datasets, this heuristic groups entities into small "atoms" before applying the optimization framework.
  4. Baselines: The proposed methods are compared against a standard Two-stage approach (clustering by sales patterns first, then running regressions) and a modified Späth algorithm (an iterative exchange heuristic).

Experimental Evaluation

The algorithms were tested on both synthetic and real-world datasets:

  • Retail Data: Sales and promotional data from a major supermarket chain, specifically focusing on the "Cream" (66 SKUs) and "Medicine" (337 SKUs) categories.
  • Synthetic Data: Instances designed to mimic retail patterns, including price discounts and weekly seasonality, used to test the algorithms' ability to recover known "target" solutions.

Key Results

  • Superiority of Simultaneity: The most significant finding is that performing clustering and regression simultaneously (CLR) is vastly superior to the common industry practice of two-stage clustering. The GA-Lloyd algorithm showed a substantial improvement—up to 20% or more—in SSE compared to the two-stage baseline.
  • Accuracy and Scalability: For small instances (up to 20 SKUs), the GA-Lloyd algorithm maintained an optimality gap of less than 2%. While the exact Column Generation method could solve small problems to optimality in approximately 3 hours, it failed to converge for larger sets (66 SKUs) within a 10-hour limit, highlighting the practical necessity of the GA-Lloyd heuristic.
  • Interpretability: When applied to the "Medicine" category, the GA-Lloyd algorithm identified three distinct seasonal patterns: a U-shaped curve (winter-selling products), an inverted V-shape (summer-selling products), and a flat line (stable, year-round products).

Conclusion

Generalized Clusterwise Linear Regression offers a powerful framework for identifying latent behavioral patterns in multi-observation datasets. While the problem is computationally demanding, the GA-Lloyd hybrid provides a robust and efficient solution for large-scale retail applications. Future research will focus on developing methods to automatically determine the optimal number of clusters ($K$) and exploring "soft" cluster assignments where entities can belong to multiple groups with varying probabilities.

Summary updated

BibTeX
@article{park2017algorithms,
  author = {Young Woong Park and Yan Jiang and Diego Klabjan and Loren Williams},
  title = {{Algorithms for Generalized Clusterwise Linear Regression}},
  journal = {INFORMS J. Comput.},
  year = {2017},
  doi = {10.1287/ijoc.2016.0729},
}
Figure