# How to detect churn from many different time series

## Setup

I have a dataset where ~3k unique customers can buy any of ~15k unique products, over a three year time span.

I'd like to use a technique that would let me learn when we haven't heard from a customer in a particularly long time - but what constitutes a "long" amount of time can vary by customer. If we have a customer that orders every 6 months, I want to reach out to this customer at a different frequency than a customer that orders every 6 days.

Some example data can be seen using this code:

structure(list(CustID = c("d7a2356c7bc05701ebebdac289a27d5c",
"db2c9173e54e84a4ea8a48914f622e8b", "5603f761c2a726246d23dd69b068d99e",
"29050a45d8968449767fee1c43012a85", "0171bb4e73b7835f2f4aee97f147886c",
"bedd251c7cd9338266f98a14b666076b", "d9d8499b4221a1ec4f2718943be4cc6f",
"0d152293532a816f49d6c8a809b9f701"), InvcDate = c("2016-09-16",
"2016-04-04", "2015-12-02", "2014-05-09", "2015-03-19", "2016-09-29",
"2013-11-29", "2014-12-31", "2015-03-10", "2014-03-04"), ItemID = c("aec7ed262d79914d57b0230cfa1b5231",
"f2d436d3770d249f2b5cc4e985b20077", "51f6fc6be10a9512947fc4515240571a",
"cc68de05ab6e66e01d35f9ff357fb7dc", "7472b660319d213c046fe448e52bc994",
"caa7454653b81e8371ee78691d74828a", "449b73764d1e09dec0eba7d7249a3c56",
"0ef3ea8997bf8ead20d4c0ddc512e75d"), QtySold = c(1, 1, 1, 1,
3, 3, 10, 1, 1, 3)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-10L), .Names = c("CustID", "InvcDate", "ItemID", "QtySold"))


## Some Ideas

One idea I had was to cluster these customers by their frequency of contact - maybe by looking at the lag at which autocorrelation peaks, and so now I have several segments of customers - my daily, weekly, biweekly, 3-monthly, etc customers. Then I can learn when someone is falling out of their cohort's cadence.

Another idea I had was to try to turn the problem into a simpler one - instead of considering QtySold as an integer, consider it as a 1 or 0 - you either bought on this day or didn't, and then try to look for anomalously long strings of 0s from particular customers.

Any pointers here would be helpful - software like Salesforce that does this, papers to read, blog posts, etc. Thanks.