1
$\begingroup$

I'm working on a time series problem and would appreciate advice from the community. My goal is to predict the sales volume ordered per customer, per product family, for the next 2-4-6 weeks. The data is aggregated by customer, product group, and week of the year.

Here’s the approach I’ve taken so far:

  1. I expanded the data to create a full time series for each customer, based on their first and last purchase dates. This resulted in many weeks with 0 sales, which I believe is informative since the absence of orders is valuable information in this context.
  2. I’m working with a complex customer base of over 2500 customers. Some order frequently (e.g., daily), others every few days, and there are seasonal customers who only purchase for a few weeks in the year. When I aggregate data across all customers, the time series appears stationary (based on ACF and PACF plots). However, when I analyze individual customers, there’s a mix of stationary and non-stationary patterns.
  3. I implemented an XGBoost model and achieved an R² score of 0.9, but I suspect these numbers are inflated due to many small predictions for weeks where sales are 0. I’m now experimenting with a 2-step model: first classifying whether a sale will happen, then predicting the sales volume for those positive instances.

Given the variability and complexity of the customer base, I’m unsure about the best modeling approach. Training separate models per customer isn’t feasible given the large number of customers.

My questions:

  1. How should I best handle the mixed patterns of stationary and non-stationary customers? Is there a way to balance this in a single model?
  2. Are there any best practices for handling the 0-sales weeks in time series forecasting without inflating performance metrics like R²?
  3. Does the 2-step classification-regression model sound like a good approach for this problem, or would another method be more suitable for such a varied customer base?

Any advice or suggestions would be greatly appreciated! Thank you in advance.

Edit: From a business perspective, the goal of the project is not just to forecast volume, but to detect churn or declining orders—at the level of individual customers and product families. Customers may stop buying one product group but continue buying others, so focusing on both customer and product is crucial. The business has little visibility into when and how churn happens. My idea was to forecast sales volume and compare it with historical trends. If we observe a declining trend in sales, it would trigger action to reach out to the customer before potential churn fully occurs.

Given the variability and complexity of the customer base, I’m unsure about the best modeling approach.

$\endgroup$

1 Answer 1

1
$\begingroup$

First, it would be useful to understand why you are forecasting, because to be honest, I do not understand why you would work on the granularity you are looking at. If you need to ensure that you have enough product on hand, you almost certainly don't need forecasts on a per-customer level, unless customization is a huge part of your process - much better to forecast aggregate raw materials across all customers and customize as late as possible. And conversely, if you need to customize per customer, do you really provide batches on two-week increments? This may make sense for your 20% largest customers, but the other 80% will probably run in different processes. And if you are forecasting for account management, you again would be working on a quarterly or yearly aggregate basis.

I suspect these numbers are inflated due to many small predictions for weeks where sales are 0

I don't quite understand what you mean by that. Small predictions are exactly what you want in weeks where sales are zero. To be honest, this quote motivated my question about whether you want to reconsider your forecasting granularity, as above.

Maximizing $R^2$ is equivalent to minimizing the MSE, i.e., it rewards unbiased expectation forecasts. Whether this is what you want is another point you should think about, and which should crucially depend on what business process your forecasts are intended to support. If you are forecasting to set safety amounts, an expectation forecast is of very limited use, and a quantile forecast on the appropriate aggregation level is what you need.

Training separate models per customer isn’t feasible given the large number of customers.

Why? 2500 time series are no issue at all for standard time series forecasting tools, like a standard auto-ARIMA tool. (I am not saying this is appropriate for intermittent series. And of course you should not build models by hand via ACF/PAFC entrails reading.) On the other hand, often a "global" model outperforms many "local" models.

I personally would not worry at all about stationarity or non. A decent automatic model will handle these, whether this is auto-ARIMA or some boosting model that leverages lags. Per above, if you can work on more aggregate levels, everything becomes more stationary, even less to worry about.

Your many zeros mean that you have . There are specialized methods for these, like Croston's method for expectation forecasting. The most important part is essentially not to use the MAE as an evaluation metric, unless you are fine with flat zero forecasts.

Your two-step approach may make sense... depending on what exactly you mean by "classifying" weeks. If you work with probabilistic predictions, this is good. If you have "hard" zero-one classifications, your model will be tempted to classify everything as "no demand", and you will get lots of flat zero forecasts. This thread is related.

Finally, I notice that you did not tag your question with . I will take the liberty of doing so. And I would recommend you take a look at our resources thread for that tag: Resources/books for project on forecasting models.


In your edit, you clarify that you are are forecasting to detect likely customer churn. This is crucial. In this case, an expectation forecast is not useful. (If someone typically orders one widget every five weeks, but you don't know when, then your expectation forecast is 0.2. And even five or eight weeks in a row with no orders do not need to be cause for concern.)

Instead, I would go with a low quantile forecast, e.g., a 10% quantile forecast. This is a forecast of a quantity that 90% of customer order should be above. If a customer comes in below this number, it may be cause for concern... or it may simply be a case of normal variability. So this may be a first indication of where to investigate.

However, since many (a long tail?) of your customers often do not order at all for weeks, this 10% quantile forecast may often be a flat zero, and be perfectly correct. Thus I would work with quantile forecasts of cumulative demand over time. Forecast total demand over 2, 4, 6 or more weeks. If a customer's cumulative orders over a period is below the (low) quantile forecast, investigate.

You can tweak the quantile level to find a good tradeoff between detection and effort in investigation. In addition, you could look at whether a customer orders at all, rather than at their total order volume. Finally, make sure you are not training your customers to behave in ways you do not want: if everyone who goes for a while without ordering gets an automatic 20% off their next order, then quite a number of your customers may delay their order exactly to get this.

$\endgroup$
2
  • $\begingroup$ Thank you so much for detailed response. I added edit to the question where I explain the overall goal of the project. I appreciate the resources as well, definitively time series novice here. $\endgroup$
    – szuszfol
    Commented Oct 17 at 13:18
  • $\begingroup$ Ah. Thank you, that clarifies matters. I edited my answer. $\endgroup$ Commented Oct 17 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.