Collaborative filtering algorithm study notes

(Notes summed up by watching the advanced Hadoop of MOOC: http://www.imooc.com/learn/890 )

1. Cosine similarity



Other Similarity Types

1. Chebyshev distance 2. Euclidean distance 3. Pearson coefficient 4. Manhattan distance 5. Jaccard distance

2. Item-based collaborative filtering algorithm ItemCF

Algorithm idea: Recommend items to users that are similar to items they liked before

1. User behavior and weight

example:

Users: A, B, C

Products: 1,2,3,4,5,6

Behavior: 1 point for click, 3 points for search, 5 points for collection, 10 points for payment

Build a list of user actions:

User Item Behavior

A 1 click

C 3 Favorites

B 2 Search

B 5 Search

B 6 Favorites

A 2 Payment

C 3 Payment

C 4 Favorites

C 1 Favorites

A 1 click

A 6 Favorites

A 4 Search

Each row indicates that a user has acted on a certain item once.

2. Algorithm implementation steps

step1: Calculate the rating matrix of users and items according to the user behavior list

   

step2: Calculate the similarity matrix between items and items

for example:


Constructed into two vectors: (2,0,5) and (10,3,0)


所以物品1与物品2的相似度为0.36,其他同理,最终得出物品与物品的相似度矩阵


step3:相似度矩阵*评分矩阵=推荐列表

(注意:因为矩阵的相乘区分左右,所以相似度矩阵与评分矩阵的顺序不能变


最终将推荐矩阵与评分矩阵相比较,将用户看过的电影置为0。


最终选取值最大的推荐给用户

A-5      B-4      C-2

三. 基于用户的协同过滤算法UserCF

算法思想:给用户推荐和他兴趣相似的其他用户喜欢的物品

例子:数据样本与基于物品的一样

算法实现步骤

step1:根据用户行为列表计算用户,物品的评分矩阵


基于物品的CF与基于用户的CF的区别是:

基于物品的CF的行号是物品,列号是用户

基于用户的CF的行号是用户,列号是物品

step2:计算用户与用户的相似度矩阵


step3:相似度矩阵*评分矩阵=推荐列表



将用户产生过行为的物品的分值置0,得出最终的推荐列表


四. 基于内容的协同过滤算

算法思想:给用户推荐和他之前喜欢的物品在内容上相似的其他物品。

对物品进行特征建模Item Profile


1表示电影具有某特征,0表示电影不具有某特征

算法实现步骤

step1:构建Item Profile矩阵


step2:构建Item User评分矩阵


step3:Item User*Item Profile=User Profile



最后得出的矩阵表示用户对某种标签的感兴趣程度。

可以看出U1用户对特征(4)和(7)最感兴趣,其权重均为6。

step4:对Item Profile和User Profile求余弦相似度










Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324604131&siteId=291194637