# 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 下载量 46 浏览量
2024-05-19
21:56:10
上传
评论
收藏 267KB ZIP 举报
温馨提示
协同过滤算法(Collaborative Filtering)是一种经典的推荐算法,其基本原理是“协同大家的反馈、评价和意见,一起对海量的信息进行过滤,从中筛选出用户可能感兴趣的信息”。它主要依赖于用户和物品之间的行为关系进行推荐。 协同过滤算法主要分为两类: 基于物品的协同过滤算法:给用户推荐与他之前喜欢的物品相似的物品。 基于用户的协同过滤算法:给用户推荐与他兴趣相似的用户喜欢的物品。 协同过滤算法的优点包括: 无需事先对商品或用户进行分类或标注,适用于各种类型的数据。 算法简单易懂,容易实现和部署。 推荐结果准确性较高,能够为用户提供个性化的推荐服务。 然而,协同过滤算法也存在一些缺点: 对数据量和数据质量要求较高,需要大量的历史数据和较高的数据质量。 容易受到“冷启动”问题的影响,即对新用户或新商品的推荐效果较差。 存在“同质化”问题,即推荐结果容易出现重复或相似的情况。 协同过滤算法在多个场景中有广泛的应用,如电商推荐系统、社交网络推荐和视频推荐系统等。在这些场景中,协同过滤算法可以根据用户的历史行为数据,推荐与用户兴趣相似的商品、用户或内容,从而提高用户的购买转化率、活跃度和社交体验。 未来,协同过滤算法的发展方向可能是结合其他推荐算法形成混合推荐系统,以充分发挥各算法的优势。
资源推荐
资源详情
资源评论


























收起资源包目录








共 5 条
- 1
资源评论


生瓜蛋子
- 粉丝: 3984
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 小游戏五子棋JAVA程序设计.doc
- 综合项目管理大知识标准体系.docx
- 江苏省建设厅项目管理表样本.doc
- 系统集成项目管理工程师考试题库系统集成技术试题汇中样本.doc
- 上半年信息系统项目管理师参考答案及解析.doc
- 物联网期末设计.doc
- 运筹学图与网络分析.ppt
- 如何做好软件系统演示.ppt
- 基于RRTConnect算法的双履带起重机路径规划研究论文.doc
- 网络工程专业大学生职业生涯规划书范文字.doc
- 开放型计算机网络实验室建设路径研究获奖科研报告论文.docx
- 愿望网站策划案.doc
- 网络传播概论全书整本书电子教案教学教程.pptx
- 网络设备调试员(高级)实践操作题.doc
- 数控编程的工艺处理ppt课件.ppt
- (完整版)螺纹连接计算(附Excel计算).doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
