Answers.Body: <p>What interests us in this problem are only the intervals for 1 person. Lets say that we want to train a neural network on recognizing the simple pattern in date differences. This would mean that we could train the neural network on series of purchase histories of multiple people. That means that one possible input is the previous intervals: in your case the previous 2 intervals (10 days, 15 days). That is a very small number and it will be hard to recognise a pattern for 3 consecutive purchases, but lets disregard that. After all, you can always experiment with different input sizes. </p>
  
  <p>For training, you can take multiple customers, where of all of them you know when 4 purchases took place. You calculate the intervals, thus for each customer you get 3 intervals. As input you give the network 2, you let the network predict the 3rd one, and then you let the network learn off its mistake (you can do that because you know what the 3rd one was in reality, that's how you train the network).</p>
  
  <p>Provided that the network isn't too complex or too simple (by that I mean that a hidden layer could be necessary, and you need to give it sufficient neurons) than the network might give a decent approximation. The only problem is, as Manuel Rodriguez said, that the network would indeed only learn to make predictions based on the corectness of its previous ones on a large group of people. Perfect predictions thus won't be possible, but you can minimize the error by making your dataset and input larger, so the network has more information to work on.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T10:04:57.210Z
Answers.LastActivityDate: 2019-03-05T10:04:57.210Z
Answers.UserDisplayName: DaddyMike
Answers.Body: <h1>An 'AI'* is only as smart as the information you give it</h1>
  <p>You've got to add your own knowledge of the situation into this. Currently we have a transaction id which only really tells us that there is a transaction, a card number (identifying a user, I assume) and a date.</p>
  <p>The date can probably tell you most - what day of the week was it? What season (most sales experience some seasonality)? What time of day?</p>
  <p>Comparing several dates can then tell you things like the average gap - deviation on that average.</p>
  <p>You can use machine learning models to tell you how good these variables are at predicting the next visit day but you have to create these variables first, the model won't know about seasonality or its effect on sales of ice cream, umbrellas or winter jumpers so you have to use your knowledge of your customer base to pass the right variables to the model.</p>
  <p>You might also want to consider the product purchased - if you can see that information - someone who buys a pint of milk or a loaf of bread will probably return for the same goods on a weekly basis (or whenever they run out) but someone who bought a set of screw drivers and returned for a hammer a week later is unlikely to return for the same goods.</p>
  <p>The vast majority of work done for most predictive systems is in creating your variables and providing something to train on which will hold the pertinent information.</p>
  <p>*I'm assuming here that you're working with a machine learning model</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T15:17:36.823Z
Answers.LastActivityDate: 2019-03-05T20:55:25.323Z
Answers.LastEditDate: 2020-06-17T09:57:20.710Z
Answers.UserDisplayName: Lio Elbammalf
Body: <p>Suppose we have a data set consists of columns</p>
  
  <blockquote>
    <p>TransactionId, CardNo, TransactionDate</p>
  </blockquote>
  
  <p>then how can we calculate the customer purchase interval (means if customer A purchased on Jan 1st and after 10 days he again purchased, and then he again purchased after 15 days.) and how to predict the next visit of customer A by analyzing the purchasing intervals of customer A.</p>
  
  <p>Any help will be appreciated.</p>
  
Tags: <python><forecasting>
Title: predict customer visit
UserDisplayName: Akhil Alexander
ThreadText: # predict customer visit
  
  (Asked by: username_0 on 2019-02-01)
  
  Suppose we have a data set consists of columns
  
  > TransactionId, CardNo, TransactionDate
  
  then how can we calculate the customer purchase interval (means if customer A purchased on Jan 1st and after 10 days he again purchased, and then he again purchased after 15 days.) and how to predict the next visit of customer A by analyzing the purchasing intervals of customer A.
  
  Any help will be appreciated.
  
  **Tags:** python, forecasting
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-03-05. Score: 2
  
  What interests us in this problem are only the intervals for 1 person. Lets say that we want to train a neural network on recognizing the simple pattern in date differences. This would mean that we could train the neural network on series of purchase histories of multiple people. That means that one possible input is the previous intervals: in your case the previous 2 intervals (10 days, 15 days). That is a very small number and it will be hard to recognise a pattern for 3 consecutive purchases, but lets disregard that. After all, you can always experiment with different input sizes.
  
  For training, you can take multiple customers, where of all of them you know when 4 purchases took place. You calculate the intervals, thus for each customer you get 3 intervals. As input you give the network 2, you let the network predict the 3rd one, and then you let the network learn off its mistake (you can do that because you know what the 3rd one was in reality, that's how you train the network).
  
  Provided that the network isn't too complex or too simple (by that I mean that a hidden layer could be necessary, and you need to give it sufficient neurons) than the network might give a decent approximation. The only problem is, as Manuel Rodriguez said, that the network would indeed only learn to make predictions based on the corectness of its previous ones on a large group of people. Perfect predictions thus won't be possible, but you can minimize the error by making your dataset and input larger, so the network has more information to work on.
  
  
  ---
  
  ### Answer by username_2 on 2019-03-05. Score: 2
  
  # An 'AI'\* is only as smart as the information you give it
  
  You've got to add your own knowledge of the situation into this. Currently we have a transaction id which only really tells us that there is a transaction, a card number (identifying a user, I assume) and a date.
  
  The date can probably tell you most - what day of the week was it? What season (most sales experience some seasonality)? What time of day?
  
  Comparing several dates can then tell you things like the average gap - deviation on that average.
  
  You can use machine learning models to tell you how good these variables are at predicting the next visit day but you have to create these variables first, the model won't know about seasonality or its effect on sales of ice cream, umbrellas or winter jumpers so you have to use your knowledge of your customer base to pass the right variables to the model.
  
  You might also want to consider the product purchased - if you can see that information - someone who buys a pint of milk or a loaf of bread will probably return for the same goods on a weekly basis (or whenever they run out) but someone who bought a set of screw drivers and returned for a hammer a week later is unlikely to return for the same goods.
  
  The vast majority of work done for most predictive systems is in creating your variables and providing something to train on which will hold the pertinent information.
  
  \*I'm assuming here that you're working with a machine learning model
  
  
  ---
  
  