algorithm Link to heading
- user collaborative filtering / user CF
- item collaborative filtering / item CF
我们选取 item cf 来做.
细节 Link to heading
- build co-occurrence matrix
- build rating matrix
- matrix computation to get predicted result
item cf alg Link to heading
- 什么时候用 item cf, 什么时候用 user cf.
当 user 数量远大于 item 数量的时候, 用 item cf. 当 item 数量远大于 user 数量或者 item 经常改变的时候, 要用 user cf.
- 怎么来表示两个不同物品间的 relationship?
用 user 的 rating histroy 来表示两个物品的 relationship. 如果一个 user 有同时 rate 两个不用的物品, 那么这两个物品是 related.
可能有点违背常识, 但是因为 user 的数量要远大于 item 的数量, 单一 user 的打分并不能代表最终两个物品是不是真的相关联. 也许最后两个物品只有1%的 user 同时评价过, 99%的 user 没有同时评价. 那么两个物品是不相关的.
- co-occurrence matrix
The similarity values between items are measured by observing all the users who have rated both the items.
| user | Item1 | Item2 | Item3 | Item4 | Item5 |
|---|---|---|---|---|---|
| A | 1 | 1 | 1 | ||
| B | 1 | 1 | 1 | ||
| C | 1 | 1 | 1 | ||
| D | 1 | 1 |
this rating table could convert to co-occurrence matrix below
| Item1 | Item2 | Item3 | Item4 | Item5
——|——-|——-|——-|——-|—— Item1 | 2 | 2 | 1 | 1 | 0 Item2 | 2 | 4 | 2 | 2 | 1 Item3 | 1 | 2 | 2 | 0 | 1 Item4 | 1 | 2 | 0 | 2 | 0 Item5 | 0 | 1 | 1 | 0 | 1
归一化处理 co-occurrence matrix, 每行进行归一化处理
normalized co-occurrence matrix X rating matrix = result matrix
implementation Link to heading
- 怎么生成co-occurrence matrix
- divide data for same user_id
- do count
- merge data for same user_id