# Model based Collaborative Filtering implemented with Tensorflow
Main recommend system algorithms are listed below.
## 1. Collaborative filtering
### based on neighbors
- based on user
- based on item
idea: find the top similar user/item, recommend what they related with weight(similarity)
### **based on models**
**what this repo implementes**
idea: user/item matrix decomposition, with **feature dim**
## Content based recommend algorithm
With all item features know, find the relationship bewteen user and features, based on user's behavior history.
Different from neighbor based collaborative filtering algorithm. Content based recommend algorithm **take user behavior history into consideration**, while neighbor based collaborative filtering algorithm ignore this.
## Hybrid algorithm
Combine collaborative filtering and content based recommend algorithm, diminishes the shortage of each algorithm. It works like making recommend from each algorithm, and combine them with weights.
# 2. Implementation
## Preprocessing
load the MovieLens 100K Dataset, parse, devide into train/validation dataset, transform to a USER\_NUM \* MOVIE\_NUM matrix with train dataset, ie `train_matrix` in code.
## Tensor Initialization
Set up `tf_train_matrix`, `tf_user_features`, `tf_item_features` tensor, which could be understood as:
```
tf_train_matrix = tf_user_features * tf_item_features.T
```
## Loss Definition
In one word, `train_loss`, which is the training objective, is defined as,
```
train_loss = 0.1 * train_diff_loss + 0.1 * train_user_loss + 0.1 * train_item_loss
```
`train_user_loss` and `train_item_loss` are the regulation terms, root/sum/square of the tf\_user\_features and tf\_item\_features, which prevents overfitting.
`train_diff_loss` is the root squared error of `tf_train_matrix` and `tf_user_features * tf_item_features.T`. You might notice that tf_train_matrix doesn't cover all, since it
s quite common(even mostly) that some users didn't see some movies. So These blanks are fill with the average rating of this movie. If nobody see this movie, rating it 3.
Their weights are all equal, 0.1, which is empirical and observation. Why not all 1, because I want loss smaller which makes me feel good. Big loss is always scary, isn't it?
## Evaluation
### Average Abs Error
`train_avg_dist` and `val_avg_dist` means the average abs rating error between prediction and ground truth.
### Accuracy
`train_equal_num`, `train_equal_ratio`, `val_equal_num`, `val_equal_ratio` stands for the right prediction num and it's ratio of train/test dataset.
## Training
It won't take too much time. I set a lot of scalars to watch in Tensorboard during training. Names of scalars need well organized to utilize the group scalar in Tensorboard.
## Result
The best accuracy is 33.59%, the best average abs error is 0.9294 before overfitting, which means 1/3 prediction are right, and average prediction is 1 rating distance from ground truth, seems to be acceptable in suggestion area.
<img src='./assets/eva-dist.png'>
<img src='./assets/eva-equal.png'>
没有合适的资源?快使用搜索试试~ 我知道了~
基于模型的协同过滤算法的纯TensorFlow实现.zip
共5个文件
png:2个
md:1个
ipynb:1个
需积分: 5 0 下载量 42 浏览量
2024-05-19
21:56:10
上传
评论
收藏 267KB ZIP 举报
温馨提示
协同过滤算法(Collaborative Filtering)是一种经典的推荐算法,其基本原理是“协同大家的反馈、评价和意见,一起对海量的信息进行过滤,从中筛选出用户可能感兴趣的信息”。它主要依赖于用户和物品之间的行为关系进行推荐。 协同过滤算法主要分为两类: 基于物品的协同过滤算法:给用户推荐与他之前喜欢的物品相似的物品。 基于用户的协同过滤算法:给用户推荐与他兴趣相似的用户喜欢的物品。 协同过滤算法的优点包括: 无需事先对商品或用户进行分类或标注,适用于各种类型的数据。 算法简单易懂,容易实现和部署。 推荐结果准确性较高,能够为用户提供个性化的推荐服务。 然而,协同过滤算法也存在一些缺点: 对数据量和数据质量要求较高,需要大量的历史数据和较高的数据质量。 容易受到“冷启动”问题的影响,即对新用户或新商品的推荐效果较差。 存在“同质化”问题,即推荐结果容易出现重复或相似的情况。 协同过滤算法在多个场景中有广泛的应用,如电商推荐系统、社交网络推荐和视频推荐系统等。在这些场景中,协同过滤算法可以根据用户的历史行为数据,推荐与用户兴趣相似的商品、用户或内容,从而提高用户的购买转化率、活跃度和社交体验。 未来,协同过滤算法的发展方向可能是结合其他推荐算法形成混合推荐系统,以充分发挥各算法的优势。
资源推荐
资源详情
资源评论
收起资源包目录
Model based Collaborative Filtering implemented with Tensorflow, 基于模型的协同过滤算法的纯TensorFlow实现.zip (5个子文件)
content
assets
eva-equal.png 177KB
eva-dist.png 145KB
RecommendSystem.ipynb 19KB
.gitignore 40B
README.md 3KB
共 5 条
- 1
资源评论
生瓜蛋子
- 粉丝: 3925
- 资源: 7441
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 年终奖发放表及个税统计表(模板).xls
- 企业年终奖发放统计表格(各大部门).xlsx
- 年终奖金相关表格(个税计算器、计算方法、相关政策).xlsx
- 年收入测算标准版(月薪、年终奖).xlsx
- 工资年终奖优化公式(终极版).xls
- 员工年终奖发放表及发放标准.xls
- 某集团有限公司企业标准:薪酬管理制度(范本) .doc
- 公司饭堂管理规定.docx
- 公司食堂菜谱.doc
- 公司食堂管理办法.doc
- 公司食堂管理制度.doc
- 公司食堂管理制度(最新).doc
- 公司员工食堂管理规定办法.doc
- 公司员工食堂管理制度.doc
- 基于51单片机空气净化器控制系统设计报告
- 动漫排名数据集,最受欢迎的动漫数据,top10000动画数据集
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功