Skip to content

Solving the Low and High Seller Bias in a Weekly Sales Forecast

Published:
•16 min read

These two studies follow the validation, hyperparameter and feature set studies on the same LightGBM model, which forecasts weekly sales per item and store with one model per product category x zone. The results are shown relative to the production model, as a difference in points (and, for RMSSE, an index where production is 100), not as absolute values.

Solve Bias Study

Executive Summary

During the last experiments (new training, new hyperparameters, new features), we have demonstrated multiple times that our model, as is, is unable to improve performance on high and low sellers simultaneously. In fact, when pushing the model in the direction of overfitting, we often observed an improved accuracy on low sellers and a worse bias on high sellers, which was due to the model prioritizing the majority class (low sellers) by reducing the forecasts overall.

This work aims to solve this core issue (unbalanced dataset) in 3 ways:

As we observe in the results:

We demonstrate that these methods simultaneously improve the bias and accuracy on all significant cohorts, constituting a complete paradigm shift compared to recent experiments.

Introduction

The current model shows a performance imbalance when it comes to forecasting high sellers vs. low sellers. In particular, it over-forecasts low sellers and under-forecasts high sellers. This behaviour is illustrated below, when plotting the bias curve with respect to each selling class:

Bias of the production model by selling class, scaled so the largest absolute value is 100.

Figure 1. Bias by selling class of the production model, scaled so the largest absolute bias is 100.

In an attempt to mitigate this bias effect, we have investigated 3 different methods and compared the corresponding model performance using new cohorts and new metrics.

Presentation of Methods

Method 1: separate low sellers from high sellers

A first approach to mitigate the strong bias that is observed between low and high sellers consists in building two LightGBM models: 1 model for low sellers and 1 model for high sellers. The idea is to separate high and low selling articles directly in the training dataset. For each training set, a model is trained on the respective data.

The mean of sales quantities over all training history has been used to split the training dataset: a threshold of 1 has been selected (low sellers ”< 1” vs. high sellers ”>= 1”), supposedly splitting the articles in the proportions 20% (high sellers) / 80% (low sellers).

Note, 2 models vs. 1:

Method 2: act on the model’s initialisation

Recall that LightGBM builds trees to compensate for errors from previously generated trees. In other words, LightGBM first initialises all sku/bu forecasts at a specific value. After initialisation, it starts building regression trees to “correct” errors made by this initial guess.

Roughly speaking, we can formulate the generated forecasts from LightGBM as:

LGBM_prediction(sku, bu) = init_score(sku, bu) + learning_rate x SUM[RegressionTreesCorrection(sku, bu, features)]

After digging in the LightGBM documentation, we have noted that the model uses a common starting point for all sku/bu couples, which depends on the objective function. With the RMSE, forecasts are initialised using the mean over all sales targets (training dataset). With the Tweedie loss, forecasts are initialised using the log of the mean over all sales targets (training dataset). This is what LightGBM’s BoostFromScore does for the L2 and Tweedie objectives (source).

Since 80% of articles are sold less than 1 unit per week in the training dataset, the mean over all targets is close to 0. Hence, having an initial guess close to 0 for all articles has multiple consequences:

Toy example: two items start from one common value near zero.

Figure 2. Initialisation in production. A toy example redrawn from the study’s sketch.

Therefore, providing a more appropriate initial guess for all articles (especially for high sellers) would reduce the amount of corrections the model needs to provide for high sellers. This simple initialisation trick could help the model better distinguish between low and high sellers, to bring the bias back closer to 0.

Two simple methods have been tested to estimate the initial guess:

Note: articles with no history have been initialized at 0.

Toy example: each item starts from the mean of its own history.

Figure 3. Initialisation using the mean of sales quantities. A toy example redrawn from the study’s sketch.

Method 3: normalise the data

A third approach consists in normalising the time series of the training dataset. By doing so, the model is fed with standardized signals with respect to each time series’ mean and standard deviation. This has two effects:

Two methods have been investigated:

Both methods handle normalisation by subtracting the mean from the time series values and dividing by their respective standard deviation:

standardized_ts = (ts - mean(ts)) / std(ts)

Note: articles with no history have no normalisation (impossibility).

Toy example: both items standardized by their own mean and standard deviation.

Figure 4. Normalisation using the mean and standard deviation. A toy example redrawn from the study’s sketch.

Experimental Setup

Summary of methods

MethodSuffix
separateseparate
initializationbaseline quantity (init_baseline), mean (init_mean)
normalizationtargets (norm_t), targets and features (norm_tf)

Experiments scope

Two product category x zone perimeters, each with its own cutoff: perimeter A and perimeter B.

Results

The results are displayed compared to reconstructed sales; we observe similar patterns when comparing to sales quantity. All results are computed up to horizon 4.

All experiments

Perimeter A: WAPE, bias and RMSSE of the five methods against production by sales cohort.

Figure 5. Perimeter A: WAPE, bias and volume-weighted RMSSE, relative to production, by weekly sales cohort.

Perimeter B: WAPE, bias and RMSSE of the five methods against production by sales cohort.

Figure 6. Perimeter B, the same comparison.

norm_t and init_baseline do offer better bias, but we believe this to be circumstantial.

We conclude that norm_tf and init_mean achieve the best overall consistency of results over performance and bias. They also are backed by theoretical evidence:

We also note:

Selected experiments

Perimeter A: init_mean and norm_tf against production by item cohort.

Figure 7. Perimeter A: WAPE and bias by new series, key items, seasonal items and start of seasonality, relative to production. The sales cohort results for init_mean and norm_tf are in Figure 5.

Perimeter B: init_mean and norm_tf against production by item cohort.

Figure 8. Perimeter B, the same comparison. The sales cohort results are in Figure 6.

We conclude that:

Dataset Normalization Study

Summary of findings

In our latest study (the solve bias study above), aiming at solving bias and the unbalanced dataset issue (low vs high sellers), we have shown very encouraging results for all methods tested. For the first time, we observe a significant improvement in both bias and accuracy.

Amongst the methods tested, one has shown the most improvement, which is normalization of target and features. In this work, we confirm these results with a wide backtesting of 3 cutoffs for multiple model scopes.

As we observe from the results:

Finally, we demonstrate that this method simultaneously improves the bias and accuracy on all significant cohorts, constituting a complete paradigm shift compared to recent experiments.

Intro and Setup of the Experimentation

Given the significant variability in observed previous results across different cutoffs and model scopes, a comprehensive and diversified backtesting process is required to ensure a proper evaluation of the solution.

Evaluation and analysis:

Results

Metrics

The main takeaways by cutoff are:

Cutoff 1:

Cutoff 2:

Cutoff 3:

Visualization

We compared forecasts of the normalization model and the production model on individual series: the series where normalization achieves its best performance against the production model, neutral ones, and the ones where it achieves its worst. These charts show single products’ weekly sales, so they are not reproduced here.

One of the worst cases is an item that we kept because of our listing rule, although with the most up-to-date data we normally should not have forecast it. There is no stock data, which is why there are almost no sales.

Explainability

Example study

For the examples that displayed the worst performance of normalization, we’ve conducted an explainability analysis of the normalized model, which shows that:

SHAP values for one poorly forecast item.

Figure 9. Contributions to one forecast where the normalized model did worst. SHAP values are in the model’s standardized output units, not an accuracy metric.

Distribution shift

Example of the distribution of the baseline quantity before and after normalization:

Toy histograms of a skewed feature before and after per-item standardization.

Figure 10. A toy example with the shapes of the study’s two histograms, made-up data.

Beeswarm plot
Features impact on the model

After normalization:

Schematic of a feature's effect before and after normalization.

Figure 11. A schematic of the pattern in the study’s dependence plots, without data values.

Conclusion

As we observe from the results:

When there is an improvement, normalization simultaneously improves the bias and accuracy on all significant cohorts, constituting a complete paradigm shift compared to recent experiments.

Next steps

Newsletter subscriptions are not currently available.