2
$\begingroup$

I am having a list of 10 different items a user has bought in the past. Each item has been bought multiple times. I would like to find a pattern in which the user buys a particular item and predict what he will be purchasing next.

For example I am running a cloth factory and sell clothes to different retailers. I would like to identify what clothes a particular retailer might be asking me next, based on the history of how the retailer has purchased different clothes.

We cannot use time series as the date of purchases has no equal intervals. Also I feel simply passing the sequence of purchased products ordered by date to a neural network will not be of much help.

Is there any standard algorithm to identity a pattern?

I am having two columns in my data: 1. item_id 2. date_of_purchase

I would like to create a model which will predict top 3 items which the user will be buying again next. Input to my model will be present date. Output should be top 3 items which the user might be interested in buying.

$\endgroup$
1
$\begingroup$

Take a look at association rule learning (https://en.wikipedia.org/wiki/Association_rule_learning). A really common algorithm is the Apriori agorithm. You could use the package apyori, it works great: https://pypi.python.org/pypi/apyori/1.1.1

Generate association rules over all items bought by a user, not in a single transaction/purchase.

$\endgroup$
0
$\begingroup$

You could train a recurrent many-to-many network using GRU/LSTM cells.

input

  1. an item as a one-hot encoding
  2. a date encoded such that there is no discontinuity when switching from day 365 to 1., e.g. the days can be encoded as $(x,y)$-positions on a 1-ring. The year can be added as a third number.

output

  1. a probability vector for the next item bought. Select the top 3 for your question.
  2. (optional) a date in the same encoding as above. It may be useful to predict when the user comes back.

loss

When predicting the date, the loss function must be adapted to reflect the combined input, e.g. $||year_{diff}||_2$ for the year part and e.g. distance on the 1-ring or $||(x,y)_{diff}||_2$ for the $(x,y)$ part.

missing

This network is missing an important part for a real world scenario: Adding new items changes the input size and requires retraining. This can be solved by using embeddings instead of one-hot encoding of the items.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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