I'm trying to build a propensity model for whether or not a customer will buy a second product. I was given data that looks like this:

| Age | Income | DaysSince1stPurchase | Bought2ndProduct |

|:---- |:------:| -----:| -----:|

| 25 | 50k | 60 | No |

| 33 | 70k | 75 | Yes |

| 45 | 100k | 80 | Yes |

The problem I have is that I'm not sure how to structure the DaysSince1stPurchase column. It did not make sense to me that the column was just (today's date) - (date of 1st purchase) for everyone. So I decided to change it to DaysSince1stPurchase for everyone who has not bought a 2nd product and DaysFrom1stPurchaseto2ndPurchase (the date of 2nd purchase) - (date of 1st purchase) for everyone who has bought a 2nd product. That'd be something like this:

| 25 | 50k | 60 | No |

| 33 | 70k | 24 | Yes |

| 45 | 100k | 15 | Yes |

This made sense to me because now the data has information on how long it took for certain customers to buy a 2nd product. However, now I'm not sure what I could call this column, it'd be something like: if bought2ndproduct -> days until 2nd purchase, else -> days since 1st purchase. I'm not sure if this is the correct way to go about it, like can you even have a column of training data be dependent on the label we're trying to predict? Something feels off to me but it could just be that I'm inexperienced. Any ideas or feedback would be greatly appreciated.


1 Answer 1


This is your problem :

can you even have a column of training data be dependent on the label we're trying to predict?

It might seems a bit weird but I would take the problem differently. The first question you want to answer (if I understand correctly) is the following : You have a set consisting of customers that yet didn't purchase their 2nd product. And you want to know which ones are the most likely to come back and buy something.

The customers that already bought their 2nd product are not relevant since you don't have to predict on them anymore.

What I would do is the following :

  • Go back in the past, 1 month ago, I had this list of clients that yet havn't bought their 2nd product.
  • Compute the dates for all of these clients that didn't buy at this time.
  • Back to the present : Now, which of these customers came back and purchased something. With the information you got now, you can label your dataset.

That way you are 100% consistent with the situation you try to predict. You build your inputs without any knowledge of the output, and then you label it. Note that your labels also depends on the 2nd date you choose as today.


  • Consistent with the situation you are trying to predict.
  • This is a huge data augmentation since you can choose any date to compute.


  • This might lead to imbalance of classes in your dataset since you eliminate the clients that came back to buy something as soon as they buy. This can be adressed by adding class weights to the loss function.
  • You may overfit your model on Age and Income if your dataset is not big enough since you will go over these values multiple times. Adding a little bit of noise to these values can solve this problem.
  • Need to code the dataset generator that takes the 'go back in time' and 'today' values as parameters.

This may be overkilling tho, if you don't want to go over all the trouble, you may want to make a statistical analysis of your data without creating a model to predict.

Hope this is understandable, feel free to ask any questions. This is the way I would do it and it may be a bit twisted, there may exist an easier path.

  • $\begingroup$ Wow I would've never thought to approach it this way and now that you've told me, it does make a ton of sense. (I knew the structure of the data felt off!) The dataset I was given contains definitive Yes, definitive No, and maybes (yet to purchase 2nd product). Yes's have a 2nd purchase date, No's and maybes do not. Curious to know if you have experience with this approach and if so, were the results good? Thanks a bunch! $\endgroup$
    – BlueSkyz
    Commented Oct 4, 2023 at 12:23
  • $\begingroup$ @BlueSkyz Well if your dataset has definitive No, then I guess you only use the maybes (in past) to create the inputs, and then No, Yes (and potentially maybe) to create your labels. But I don't have much experience dealing with this kind of data (computer vision engineer speaking here), so no idea what the results would look like. You way want to have a look at articles like this one that are quite similar to your case. $\endgroup$
    – Ubikuity
    Commented Oct 5, 2023 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.