1
$\begingroup$

I want to train a model on transaction data to predict whether a customer will buy the product in the next 90 days.

  1. I observed seasonality in the data, i.e. during certain months of the year, sale increases.
  2. Similarly, customers repeat the purchase in certain intervals. for example, for product A the purchase is repeated usually around 24 months. Whereas for product B, the purchase is repeated usually around 18 months.

How do I capture these complex patterns in the data? For seasonality, I want to create Month1, Month2,.., Month11 Boolean variables. I'm not sure how I capture the second scenario? Can someone suggest useful features for this and how these features help capture these patterns?. I'm planning to use Xgboost as the algorithm.

$\endgroup$

1 Answer 1

1
$\begingroup$

To capture those patterns correctly, you should use the right time scale so that XG Boost (or any other algorithm) can find out the pattern easily.

In your case, the month is a good time scale, and the month should be a separate feature. For instance, use feature A: day, feature B: month, feature C: year, and not feature A:year-month-day. In this way, the algorithm should be able to find that every December (feature B = 12), sales increase.

In addition to that, using relative values (ex: +1200 sales from the previous month) instead of absolute ones (ex: November=1000, December = 2200) could be better, because your algorithm will focus on data dynamics, rather than positions (positions = more difficult to get patterns).

Note: integer values could be better than booleans, as you can have some sequential dynamics. For instance, 2pm < hour < 5pm have lower sales.

$\endgroup$
3
  • $\begingroup$ Thanks for the reply How do I capture the second scenario in the question? $\endgroup$
    – NAS_2339
    Jul 11, 2022 at 6:28
  • $\begingroup$ Can you elaborate on the "algorithm will focus on data dynamics, rather than positions ", What exactly do you mean by that? $\endgroup$
    – NAS_2339
    Jul 11, 2022 at 6:30
  • $\begingroup$ It’s about using the variations from one day or month to another (+6%, -3%, etc.). Patterns are easier to detect in such a case. $\endgroup$ Jul 11, 2022 at 14:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.