Correlation between products based on purchases placed around the same date


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.

Lucas Taulealea

Posted 2017-03-16T03:52:59.093

Reputation: 31



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!

Alex Firsov

Posted 2017-03-16T03:52:59.093

Reputation: 131