# 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实现+源代码+文档说明
共5个文件
png:2个
md:1个
ipynb:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 19 浏览量
2024-06-03
14:20:20
上传
评论
收藏 268KB ZIP 举报
温馨提示
- 不懂运行,下载完可以私聊问,可远程教学 该资源内项目源码是个人的毕设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! <项目介绍> 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 --------
资源推荐
资源详情
资源评论
收起资源包目录
Collaborative-Filtering-Tensorflow-master.zip (5个子文件)
Collaborative-Filtering-Tensorflow-master
assets
eva-equal.png 177KB
eva-dist.png 145KB
RecommendSystem.ipynb 19KB
.gitignore 40B
README.md 3KB
共 5 条
- 1
资源评论
机器学习的喵
- 粉丝: 1716
- 资源: 2009
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- JAVA的SpringBoot快速开发平台源码数据库 MySQL源码类型 WebForm
- java校园跑腿综合服务网平台小程序源码带部署搭建教程数据库 MySQL源码类型 WebForm
- 时间序列-白银-1分数据
- C#VS2015进销存管理系统源码数据库 SQL2008源码类型 WebForm
- java企业报表管理系统源码数据库 MySQL源码类型 WebForm
- 软考题库试题及其解析.docx
- (全新整理)中国同一带一路国家海关进出口数据(1994-2022年)
- java医院数据分析管理系统源码数据库 MySQL源码类型 WebForm
- 59e81b49-3120-4f21-a2b7-bc440de0bd88_0.jpeg
- 新数学课件和教学设计.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功