“People who watched this also watched” algorithm

后端 未结 5 872
攒了一身酷
攒了一身酷 2021-02-14 03:45

I am trying to code an algorithm that acts a bit like Amazon\'s \"People who bought this also bought\".

The difference between the two is that mine is just counting the

5条回答
  •  花落未央
    2021-02-14 04:18

    You are not going to need any (any!) +1s.

    What you do need is a history. In case of "customers who bought X also bought Y" it's a history of purchases. In case of "customers who saw X also were interested in Y" it's a history of who saw what.

    As soon as you have a history, you're ready for making sense of your data. Here, you'll need to adjust your mind to the nearest neighbour problem. What you need is the nearest neighbours for X. The coordinates are users, the values are 0 and 1 depending on whether a user saw/bought an item.

    The easiest way to calculate the distance is just sum of squared deltas; it can be easily calculated once an hour for example (as soon as you have plenty of views, distances will stop changing too often), and after that you'll always have a table of distances handy.

    The examples for this approach can be found (in Python) in Programming Collective Intelligence published by O'Reilly

提交回复
热议问题