Association rule learning has a fair bit of material based around the correlation of products purchased on the same order/at the same time. However I'd like to discover if there is a method for identifying such a relationship between products that are ordered near each other, but not together.

Say for example a customer purchases a pencil in week one, but later purchases an eraser in week two. Then a year later they do the same thing. But then also apply this across all customers who show similar behaviour. I would then aim to combine this with the correlation coefficient of products purchased in an order together.

I considered giving each of the dates before or after a purchase a diminishing weight (1/n days) and then comparing the aggregate date value of the customer purchase date history with a product A against product B. But this seems like a fairly drawn out method.

Just looking for a process to achieve this, but python hints would also help.

Thanks in advance.


1 Answer 1


Association rule mining is nearly always done with the apriori or eclat algorithms. There are a few papers which have utilized these in the time series context. This paper details a thorough implementation, though this is done with relation to identifying gene patterns, rather than customer purchases. The idea is still the same though, only there is slightly less complexity in your case. Unfortunately, this does not give a detailed Python implementation.

Depending on your situation (this is unlikely to be applicable from your description, but I list this just in case...), it may be useful to break from association rules and cluster your data instead, provided you have enough of it to treat it as continuous. A Python implementation of this is featured in this article.

Good luck!


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.