← Latest papers
💻 computer science

When and What Will Customers Buy Next? A Dual-Task Deep Learning Framework for Repurchase Prediction in E-Commerce

This study proposes a dual-task deep learning framework based on LSTM that simultaneously predicts customer repurchase timing and next-product selection, demonstrating superior performance over existing models on large-scale e-commerce data and offering a practical AI agent system for automated marketing optimization.

Original authors: Gia Bao Huynh, Thi Thuy Hanh Nguyen

Published 2026-07-29
📖 5 min read🧠 Deep dive

Original authors: Gia Bao Huynh, Thi Thuy Hanh Nguyen

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Crystal Ball of Shopping

Imagine you are walking through a massive, endless digital mall where millions of people are buying things every second. In the world of data science, this is the realm of e-commerce, a place where businesses are constantly trying to answer two tricky questions: "Will this customer come back?" and "If they do, what will they buy?" For a long time, scientists and business owners have tried to predict this using old-school math, looking at past habits like a detective reviewing a file. They knew that if someone bought a lot recently, they might buy again soon. But there was a catch: most of these methods were like looking at a photo of a person and guessing their future, ignoring the fact that people are moving, changing, and acting in a sequence over time.

To understand this new study, you need to know about a special kind of computer brain called Deep Learning, specifically a type called LSTM (Long Short-Term Memory). Think of a normal computer program as a student who forgets everything from yesterday's lesson by the time today's class starts. An LSTM is like a super-student who has a perfect memory of the last few days of lessons, allowing it to see patterns in a story rather than just isolated facts. This study uses that super-memory to watch a customer's shopping history like a movie, trying to predict the very next scene: exactly when they will return and what item they will grab off the shelf.

The Two-Headed Oracle

The researchers, Gia Bao Huynh and Thi Thuy Hanh Nguyen, built a "two-headed" computer model to solve a problem that most other models ignore. Usually, AI tries to guess just one thing: "Will they buy?" or "What will they buy?" This new model is different because it tries to answer both questions at the same time, like a fortune teller who tells you not just what will happen, but when it will happen. They fed their model a massive dataset of over 540,000 transactions from a real online store, involving thousands of different products.

The model learned by watching how customers moved through time. It looked at the last five things a customer bought, how much they spent, and how long they waited between purchases. Then, it made two predictions simultaneously. First, it guessed the number of days until the next purchase. Second, it guessed the specific product code of the next item. The goal was to see if teaching the computer to do both jobs at once would make it smarter than if it tried to do them separately.

The Results: A Mix of Magic and Reality

When the researchers tested their "two-headed" model, the results were a fascinating mix of incredible accuracy and some very specific quirks of human shopping behavior.

The Time Prediction:
The model was surprisingly good at guessing when people would return. It predicted the time until the next purchase with an average error of just 1.62 days. This means if the model said a customer would return in 5 days, it was usually off by less than two days. Even more impressive, for more than half of the customers, the model was spot on, with an error of 0 days. However, the researchers found a strange twist in the data: about 75% of the time, customers were buying multiple things on the exact same day. Because of this, the model sometimes struggled with the rare customers who waited a long time (like 30 days or more) to buy again. While the model was great at the common, quick returns, these rare, long waits made the overall "statistical score" (R²) look a bit negative, not because the model was bad, but because the data was so full of same-day shoppers that it threw off the math for the long waiters.

The Product Prediction:
When it came to guessing what a customer would buy next, the model faced a much harder challenge. The store had 3,655 different products. If you were just guessing randomly, your chance of picking the right item would be tiny—about 0.027% for the top guess. But the model didn't guess randomly. It managed to get the right product in its top guess 2.35% of the time. Even more exciting, if you let the model give you its top 5 guesses, it was right 9.17% of the time. To put that in perspective, this was 67 times better than just rolling a dice to guess. It proved that the model had learned real patterns, like knowing that if you buy a phone, you might soon buy a case, rather than just guessing blindly.

Why This Matters

The authors suggest that this "two-headed" approach is better than older methods because it learns from the whole story of a customer's shopping history, not just a snapshot. They also proposed a cool idea for the future: an AI agent. Imagine a robot assistant that doesn't just predict what you want, but automatically sends you a coupon or a reminder at the exact moment you are likely to buy, without a human needing to click a button. This could save companies money and help them keep customers happy by being there exactly when needed.

While the model isn't perfect—especially for those rare customers who wait months to buy again—it shows that by using deep learning to look at both time and product together, businesses can get a much clearer picture of their customers' habits. It turns a chaotic stream of transactions into a readable story, helping shops know not just who is coming back, but exactly what they are going to buy next.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →