# Predict customer action from previous buying history

I'm trying to predict what service a customer wants when he comes to our office from his previous transactions history. I have 7 years transactions data(3 crore txns) and good amount of customers are frequent ones.Each service is personal to each customers.

sample data

[
{
"customerId":"1xxxx",
"txns":[
{
"serviceId":"12ds23",
"date":"2016-08-03T08:43:33Z"
},
{
"serviceId":"1dsd89",
"date":"2016-09-03T08:43:33Z"
},
{
"serviceId":"1dbbb89",
"date":"2016-10-03T09:43:33Z"
}
]

},{
"customerId":"2xxxx",
"txns":[
{
"serviceId":"dds2dfsd",
"date":"2016-08-03T08:43:33Z"
},
{
"serviceId":"dsdsdsdf",
"date":"2016-09-03T08:43:33Z"
},
{
"serviceId":"sdfbb9",
"date":"2017-10-03T09:43:33Z"
},
...
...
]

},
...
..
..
]


Can someone please advice which Machine learning technique or statistical approach would be best in this case.

I can think of a Decision tree classification/Logistic regression model taking date(month,day,day of week) as features for predicting the service he wants as Class labels

• Do you also have a dataset of what customers asked when they walked in your office? Feb 18 '17 at 19:51
• Yes. They will ask for a particular service Feb 19 '17 at 9:14

You can have a variety of solutions, starting from very simple to a more complex and beneficial ones.

I suggest that you'll start with the simple solutions, jain much of the benefit and continue by need.

Note that though the problem can be treated as a supervised learning problem, it is a multi label problem (a customer can be interested in many services). Therefore, decision tree or logistic regression is not suitable (unless you have a handful of services and you try to predict if the user would like a service, for each service).

The classical method to provide such recommendations are "People that like X, also liked Y". Though very simple, at time 50% of Amazon's revenues where due to that.

You should make the recommandation more sepcific by considering the lift - Harri Potter is very popular and many people like it. However, it isn't the most sutabile recommandation for someone reading browsing books.

You can take such a item-to-item recommendation and use all user history by aggregating using Naive Bayes or similar methods. You can take care of temporality and dates by giving more eight to recent data.

The next step is moving to recommendation system. You can find on the web some implementation. The winner in the Netflix challenge used matrix factorization algorithm, so this direction is very popular for recommendation systems.

• Hi dan. That was really helpfull. Each customer will have unique services. I dnt want to recommend a service based on other users or item-item based recomendation. What i am trying to do is predict what service customer will choose next time given the date as input feature. I have enough data to identiy the pattern. Am i making any sense ? Feb 19 '17 at 9:29
• In case that the services are unique you should find some aggregation in order to deduce. Can you group the services? If so you can use the same logic by working like in "People that likes services from these groups also liked ..."
– DaL
Feb 19 '17 at 9:44
• Why are the services unique? Is it inherent from their nature? Why don't you want to use the history of other users?
– DaL
Feb 19 '17 at 9:45
• yes they are inherent in nature. Also the service choosed by a customer will be very specific to that user. As of now i have a decesion tree model which takes in username and date as input feature and predicts the servicd id with 70% accuracy. But i dnt is this the right way to look at this problem Feb 19 '17 at 12:25
• What features do you use for the service classification? By the way, 70% might be high. What is the benchmark?
– DaL
Feb 19 '17 at 14:36