Compare commits

..

10 Commits

Author SHA1 Message Date
taishan
cd21b384d3 update README.md.
readme

Signed-off-by: taishan <liuyapeng@bdtd.com>
2024-01-31 00:40:51 +00:00
taishan
514346075d update README.md.
reame

Signed-off-by: taishan <liuyapeng@bdtd.com>
2024-01-31 00:39:40 +00:00
taishan
923a0ea5ae update README.md.
readme 完善

Signed-off-by: taishan <liuyapeng@bdtd.com>
2023-04-08 09:42:51 +00:00
tarzan
87f96e06f7 Merge remote-tracking branch 'origin/master' 2023-04-04 14:56:03 +08:00
tarzan
e648b7823f 代码优化 2023-04-04 14:55:49 +08:00
taishan
43ee53bc69 update README.md.
Signed-off-by: taishan <liuyapeng@bdtd.com>
2023-03-31 10:13:26 +00:00
tarzan
43c55193c9 bug修改 2023-03-27 17:41:10 +08:00
tarzan
b4bd7e305a bug修改 2023-03-27 09:14:37 +08:00
tarzan
2ab736a59e git 忽略 2023-03-13 10:50:09 +08:00
tarzan
7ccd3f9daa git 忽略 2023-03-13 10:49:26 +08:00
8 changed files with 51 additions and 31 deletions

2
.gitignore vendored
View File

@@ -23,4 +23,4 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea
.idea/

8
.idea/.gitignore generated vendored
View File

@@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -1,10 +1,21 @@
# JAVA推荐系统-基于用户和物品协同过滤的电影推荐
#### 系统原理
该系统使用java编写的基于用户的协同过滤算法UserCF和基于物品此应用中指电影的协同过滤(ItemtemCF
利用统计学的相关系数经常皮尔森pearson相关系数计算相关系数来实现千人千面的推荐系统。
## 我的博客
1. **JAVA OPC UA专栏**[https://blog.csdn.net/weixin_40986713/category_12356608.html](https://blog.csdn.net/weixin_40986713/category_12356608.html)
2. **AI绘画 | Stable diffusion**[https://blog.csdn.net/weixin_40986713/category_12481790.html](https://blog.csdn.net/weixin_40986713/category_12481790.html)
3. **java高级技术专栏**[https://blog.csdn.net/weixin_40986713/category_10796066.html](https://blog.csdn.net/weixin_40986713/category_10796066.html)
4. **java Selenium自动化爬虫**[https://blog.csdn.net/weixin_40986713/category_12165790.html](https://blog.csdn.net/weixin_40986713/category_12165790.html)
5. **java 推荐算法专栏**[https://blog.csdn.net/weixin_40986713/category_12268014.html](https://blog.csdn.net/weixin_40986713/category_12268014.html)
6. **Java视频图像处理专栏**[https://blog.csdn.net/weixin_40986713/category_11109931.html](https://blog.csdn.net/weixin_40986713/category_11109931.html)
#### 协同过滤算法
协同过滤推荐算法是诞生最早,并且较为著名的推荐算法。主要的功能是预测和推荐。协同过滤(Collaborative Filtering,简写CF)是推荐系统最重要得思想之一,其思想是根据用户之前得喜好以及其他兴趣相近得用户得选择来给用户推荐物品(基于对用户历史行为数据的挖掘发现用户的喜好偏向,并预测用户可能喜好的产品进行推荐),一般仅仅基于用户的行为数据(评价,购买,下载等),而不依赖于物品的任何附加信息(物品自身特征)或者用户的任何附加信息(年龄,性别等)。其思想总的来说就是:人以类聚,物以群分。
目前应用比较广泛的协同过滤算法是基于邻域的方法,而这种方法主要有两种算法:
@@ -162,17 +173,16 @@ Spring boot单项目
3.项目中用到的文件数据集ml-100k 在 src / main / resources目录下
#### 技术交流&问题反馈
刚刚整理的代码还有很多不足之处,如有问题请联系我
联系QQ:1334512682
微信号vxhqqh
#### 我的博客
[洛阳泰山](https://blog.csdn.net/weixin_40986713)
#### 推荐阅读
[推荐算法专栏](https://blog.csdn.net/weixin_40986713/category_12268014.html?spm=1001.2014.3001.5482)
#### 常见问题
[点击查看](https://gitee.com/taisan/recommend_system/issues?assignee_id=&author_id=&branch=&collaborator_ids=&issue_search=&label_ids=&label_text=&milestone_id=&priority=&private_issue=&program_id=&project_id=taisan%2Frecommend_system&project_type=&scope=&single_label_id=&single_label_text=&sort=&state=closed&target_project=)

View File

@@ -6,17 +6,25 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.List;
/**
* @author tarzan
*/
@SpringBootApplication
public class RecommendSystemApplication {
public static void main(String[] args) {
//SpringApplication.run(RecommendSystemApplication.class, args);
System.out.println("------基于用户协同过滤推荐---------------下列电影");
List<ItemDTO> itemList= Recommend.userCfRecommend(2);
List<ItemDTO> itemList= Recommend.userCfRecommend(1);
itemList.forEach(e-> System.out.println(e.getName()));
System.out.println("------基于物品协同过滤推荐---------------下列电影");
List<ItemDTO> itemList1= Recommend.itemCfRecommend(2);
List<ItemDTO> itemList1= Recommend.itemCfRecommend(1);
itemList1.forEach(e-> System.out.println(e.getName()));
}
}

View File

@@ -33,8 +33,8 @@ public class CoreMath {
//关系系数
double coefficient = relateDist(v,userItems,type);
//关系距离
double distance=Math.abs(coefficient);
distMap.put(k,distance);
// double distance=Math.abs(coefficient);
distMap.put(k,coefficient);
}
});
return distMap;
@@ -50,8 +50,8 @@ public class CoreMath {
* @return double
*/
private static double relateDist(List<RelateDTO> xList, List<RelateDTO> yList,int type) {
List<Integer> xs= Lists.newArrayList();
List<Integer> ys= Lists.newArrayList();
List<Double> xs= Lists.newArrayList();
List<Double> ys= Lists.newArrayList();
xList.forEach(x->{
yList.forEach(y->{
if(type==0){
@@ -79,7 +79,7 @@ public class CoreMath {
* @author tarzan
* @date 2020年07月31日 17:03:20
*/
public static double getRelate(List<Integer> xs, List<Integer> ys){
public static double getRelate(List<Double> xs, List<Double> ys){
int n=xs.size();
//至少有两个元素
if (n<2) {

View File

@@ -21,7 +21,7 @@ public class RelateDTO {
/** 物品id */
private Integer itemId;
/** 指数 */
private Integer index;
private Double index;
}

View File

@@ -21,6 +21,9 @@ public class FileDataSource {
public static String folderPath;
static {
folderPath= Objects.requireNonNull(FileDataSource.class.getResource("/ml-100k")).getPath();
}
/**
@@ -31,7 +34,6 @@ public class FileDataSource {
* @date 2020年07月31日 16:53:40
*/
public static List<RelateDTO> getData() {
folderPath= Objects.requireNonNull(FileDataSource.class.getResource("/ml-100k")).getPath();
List<RelateDTO> relateList = Lists.newArrayList();
try {
FileInputStream out = new FileInputStream(folderPath+"\\u.data");
@@ -43,7 +45,7 @@ public class FileDataSource {
String[] ht = newline.split(" ");
Integer userId = Integer.parseInt(ht[0]);
Integer movieId = Integer.parseInt(ht[1]);
Integer rating = Integer.parseInt(ht[2]);
Double rating = Double.parseDouble(ht[2]);
RelateDTO dto = new RelateDTO(userId, movieId, rating);
relateList.add(dto);
}
@@ -61,7 +63,6 @@ public class FileDataSource {
* @date 2020年07月31日 16:54:51
*/
public static List<UserDTO> getUserData() {
folderPath= Objects.requireNonNull(FileDataSource.class.getResource("/ml-100k")).getPath();
List<UserDTO> userList = Lists.newArrayList();
try {
FileInputStream out = new FileInputStream(folderPath+"\\u.user");
@@ -94,7 +95,6 @@ public class FileDataSource {
* @date 2020年07月31日 16:54:22
*/
public static List<ItemDTO> getItemData() {
folderPath= Objects.requireNonNull(FileDataSource.class.getResource("/ml-100k")).getPath();
List<ItemDTO> itemList = Lists.newArrayList();
try {
FileInputStream out = new FileInputStream(folderPath+"\\u.item");

View File

@@ -0,0 +1,10 @@
1 1 1 847117005
1 2 10 847642142
1 3 1 847641896
2 1 2 847642008
2 3 2 847641956
3 1 3 847641956
3 3 3 847642073
4 1 4 847642105
4 2 1 847116751
4 3 5 847116787