Which product is an RPT candidate?
For every Collection product, every week: "is it worth making again?" How the label is defined, the rule, logistic regression and LightGBM, and the cost of a false alarm and of a miss.
Repeat Order (RPT) · 4 / 6
This spring-summer Banu’s rule placed RPTs on 103 products. Of those, 64 were not hits; their real demand did not exceed one and a half times the plan. That is the mistake everyone can see: an RPT placed on a product that did not take off, sitting in the warehouse. This article opens up the question behind that number: how do you decide whether a product is an RPT candidate? By the end we will see that the rule’s really expensive mistake is on the side nobody sees.
In the previous article we answered “how much more would it have sold if there had been more?” Candidacy uses the answer to that question, but it is not the same question. A product can be selling well and still not be a candidate: if, when the repeat stock arrives, there is no time left to sell it.
Scope
The question is asked only of Collection products. NOS and Basic products are replenished continuously anyway. A season’s Collection at Lumoda is 210 options. For each of them there is a decision row on the second, third, fourth, fifth and sixth Monday after launch; one row for every option that has not had an RPT yet. At most 1,050 rows in a season.
Each row is built from what is known on that Monday morning: the product’s sales up to that morning, its demand filled in at the decision date as in the previous article, and the chain’s stock that morning.
The label: the hardest part
Building a classifier is easy. Defining what it classifies is hard. “Is the product a hit?” is not a good label; for a hit that is spotted late, an RPT is already worthless. The definition we use is this:
Had an RPT been placed this Monday, would at least half the MOQ of the stock arriving at the end of the lead time have sold at full price?
The order quantity is the larger of the MOQ and the quantity recommended by the sum we build in the next article. The lead time is that of the product’s own supplier. The threshold is “half the MOQ” because if we cannot sell even half the smallest order we can give the supplier at full price, that order has in effect been made for markdown.
We work this label out afterwards for past seasons. There is a trap here: if the label is worked out from real demand, it cannot be built in the field, because in the field we do not know real demand. So we worked the label out twice:
- (i) from real demand: the product’s own sales + unmet demand. It exists only in synthetic data.
- (ii) from demand filled in with Lost Sales’ method. Past seasons’ stockout days are filled in with Simple, using the data available on the exam season’s first launch morning. Any chain can work this out from its own data.
The models are trained with (ii) and tested with (i). In the training rows of the spring-summer model, the two labels give the same result in 95.5% of rows; the chance-corrected measure of agreement, Cohen’s kappa, is 0.866. In the autumn-winter model’s rows, 95.1% and 0.858. Where they part, the direction is clear: (ii) is more generous. In 145 of the 3,502 rows only (ii) says “yes”, in 11 only (i). Filled-in demand overstates the truth a little on some products; in the Lost Sales series, too, Simple wrote the loss a little high. The label you can build in the field does not coincide exactly with the label that knows the truth, but on a yes-or-no question it is close enough.
Candidates are not rare
Of the spring-summer season’s 1,050 decision rows, 334 are positive: 31.8%. In autumn-winter, 218, or 20.8%. Being a candidate is not rare; in spring-summer one row in three is a “yes”, in autumn-winter one in five. What is hard is seeing early which one is the “yes”.
Look at where the positives cluster. In the four past seasons the spring-summer model was trained on, with label (ii), positive / rows:
| Origin | h=2 | h=3 | h=4 | h=5 | h=6 |
|---|---|---|---|---|---|
| Domestic | 210 / 358 | 201 / 358 | 105 / 280 | 43 / 205 | 12 / 140 |
| Egypt | 38 / 106 | 38 / 106 | 25 / 89 | 13 / 73 | 4 / 54 |
| Far East | 55 / 376 | 34 / 376 | 17 / 351 | 7 / 327 | 0 / 303 |
The number of rows falls as the weeks go by, because an option that gets an RPT drops off the list in the following weeks. Two things read clearly. For domestic products the window for being a candidate is wide in weeks two and three, narrows in week four and has all but closed by week six. A product from the Far East can be a candidate too, but only early: 55 of 376 rows on the second Monday, none on the sixth. A lead time of twelve to fifteen weeks leaves a share of the curve only to an order placed early.
Banu’s rule first looks at a product on the third Monday. For a domestic product the window is still open that day. For the Far East the most productive week has already gone.
Features
For each row, from what is known on that Monday morning:
- The weekly rate of demand filled in at the decision date, as a ratio of the initial buy
- The previous article’s d estimate and the FRR estimate, as ratios of the initial buy
- The chain STRSTR; the percentage of the stock a store received that has sold. In fashion retail the figure that matters is the part sold at full price. (the only thing Banu’s rule looks at)
- The share of stores in stock, the share of stores with broken sizes, and cover (how many weeks the stock on hand will last)
- The decision week, and weeks left to markdown
- The supplier’s RPT lead time, and whether it is in the Far East
- The share of full-price demand left after arrival, from the life cycle curve
- Estimated extra demand, as a ratio of the initial buy
- MOQ ÷ estimated extra demand: the supplier’s smallest order, against how much of the demand that cannot be met will come after arrival
Three models
Banu’s rule (STR ≥ 55%, between the third and the sixth Monday), logistic regression and LightGBM. For the spring-summer season the models were trained on the 3,502 rows of the four seasons that closed before it, with 802 positives; they never saw the exam season.
| Model | Alarms | Correct | False alarms | Missed | Precision | Recall |
|---|---|---|---|---|---|---|
| Banu’s rule | 267 | 162 | 105 | 172 | 60.7% | 48.5% |
| Logistic regression | 390 | 292 | 98 | 42 | 74.9% | 87.4% |
| LightGBM | 382 | 300 | 82 | 34 | 78.5% | 89.8% |
Banu’s rule does not shout much. When it does, it is mostly right: 162 of its 267 alarms are correct. Its real problem is keeping quiet: it finds fewer than half of the 334 rows it should catch. It never sees the second Monday’s positives, because it first looks at a product on the third Monday. The models raise more alarms than the rule and still get fewer wrong; they find close to nine out of ten positives.
This may seem to contradict the number at the start: the rule placed 64 of its 103 RPTs on products that were not hits. They are separate questions. Being a hit means real demand exceeding one and a half times the plan. Being worth an RPT means at least half the MOQ of the incoming stock selling at full price. A product that beats the plan by a little but is still selling when the RPT arrives does not count as a hit, yet it deserves the RPT. By the label, the rule’s alarms are mostly right. Its real mistake is the 172 rows it misses.
The miss rate also looks higher than in the first article. There the rule missed a third of the hits; here, more than half the positive rows. The measure is different: at row level, the second Mondays the rule never looks at are counted too, and so are the positive weeks before the week in which the rule later caught the product.
Row counts are not the money itself. We can read the same exam in TRY: each false alarm is the profit lost, in hindsight, by an order that should not have been placed; each missed row is the profit not made by an order that should have been.
| Model | Cost of false alarms | Cost of misses |
|---|---|---|
| Banu’s rule | TRY 6,182,207 | TRY 205,808,206 |
| Logistic regression | TRY 14,825,493 | TRY 10,405,622 |
| LightGBM | TRY 17,038,283 | TRY 6,440,643 |
The rule’s false alarms are cheap: TRY 6.2 million. What it misses costs TRY 205.8 million. The models’ false alarms cost two to three times the rule’s, but what they miss costs TRY 10.4 and 6.4 million.
These amounts are added up row by row; when the same product is missed in consecutive weeks, its cost is written down again each week. That is why the rule’s cost of misses comes out bigger than a perfect classifier’s whole profit. The table shows the direction of the mistakes, not their size. The true measure of the money is the first-alarm table below: there the rule leaves a quarter of the perfect classifier’s profit behind.
Assume an option gets at most one RPT in a season, and that each model places the order at its first alarm for an option. The profit the RPTs bring in by the end of the season:
| Model | Options with a first alarm | Profit |
|---|---|---|
| Banu’s rule | 103 | TRY 100,600,229 |
| Logistic regression | 110 | TRY 130,700,734 |
| LightGBM | 101 | TRY 129,519,127 |
| Perfect classifier | 79 | TRY 134,774,625 |
With the order quantity worked out properly, Banu’s rule makes money too: it takes 74.6% of the profit a perfect classifier would bring in, about three-quarters. The models take almost all of it: logistic regression 97.0%, LightGBM 96.1%. The difference lies in the products the rule misses.
The same exam in the autumn-winter season gives the same picture: the rule with 44.6% precision and 50.9% recall, logistic regression with 61.4% and 91.3%, LightGBM with 61.8% and 95.0%. On first-alarm profit the rule takes 69.0% of the perfect classifier’s, logistic regression 82.0%, LightGBM 80.0%. That season’s model was trained on 2,604 rows from three closed seasons, with 623 positives. Three closed seasons are enough to build a model.
What does the model look at?
The logistic regression coefficients in the spring-summer model, after the features have been scaled, the top six from largest to smallest:
| Feature | Coefficient |
|---|---|
| Supplier’s RPT lead time | −2.98 |
| Weeks to markdown | 2.08 |
| Full-price demand share left after arrival | −1.15 |
| Stock cover | −1.02 |
| Decision week | −0.97 |
| MOQ ÷ estimated extra demand | −0.90 |
A warning before reading this table. The top three features come from the same calendar: the full-price share left after arrival is almost a function of the supplier’s RPT lead time, the decision week and the weeks to markdown. With features like these, reading the sign of a single coefficient on its own misleads. The share left showing as negative does not mean “the bigger the share left, the less likely it is to be a candidate”. The three have to be read as one block: when the stock arrives, is there time left to sell it?
That block is the heaviest part of the table. The longer the lead time, the lower the probability of being a candidate; the more weeks to markdown, the higher. Stock cover, and the ratio of the supplier’s smallest batch to the demand left, say the same thing with less weight: if there is a lot of stock on hand, or the MOQ is large against the demand left, the probability falls. The STR that Banu’s rule looks at is the thirteenth of fourteen features; its coefficient is 0.13, less than a twentieth of the largest.
That changes the definition of a candidate. “Is it selling?” matters, but it is not decisive. What decides is whether the stock will find time to sell when it arrives.
Coming from the Far East carries a small weight as a separate feature, and its sign changes with the season: +0.42 in the spring-summer model, −0.02 in the autumn-winter one. The Far East’s disadvantage is already in the lead time column.
Which one?
LightGBM is a little more precise; on profit the two are neck and neck. In the games in the following articles the “recommend” arm was run with LightGBM; the same games were also run with logistic regression, and the two models placed almost the same orders. In spring-summer LightGBM placed RPTs on 77 options and logistic regression on 79; 76 were common to both. The difference in profit between the two models is less than 2% of their profit (in the sixth article).
If it were me, I would pick logistic regression. LightGBM is ahead by a small margin on classification, logistic regression on first-alarm profit. The gap is not big enough to be worth giving up explainability for. Logistic regression gives a buyer the answer to “why is this product a candidate?” in a single table. The thesis of the Replenishment series holds here too: complexity has to earn its place by measurement.
A warning
The exam rows were taken from a game in which no RPT was ever placed. In reality, the moment a product gets an RPT, the stock position in the following weeks changes, and that product no longer shows up on the candidate list. There is one more thing: whether a product is a candidate depends on how much is ordered. The label uses the next article’s quantity sum. Candidacy and quantity are told as separate questions, but they are two faces of the same sum.
What is hard in your data
This article’s exam was sat with label (i), and (i) knows the real demand. In your chain there is only (ii). You can train the model with it, but you also have to test with it; you are writing both the question and the answer key from the same estimate. At Lumoda we saw the two labels give the same result in nineteen rows out of twenty. In your data you cannot measure that ratio. All you know is that it depends on how accurately you fill in the stockout days.
Then there is how visible the cost is. The rule’s most expensive mistake is the miss, and a missed RPT shows up in no report. An RPT placed on a product that did not take off sits in the warehouse, for everyone to see. The cost of an RPT never placed disappears with the customer who found the rail empty. That is why rules on the shop floor tend to be tuned to the mistake people can see, which means being cautious without anyone noticing.
In the next article we build the quantity sum: how much, and when?