协同过滤推荐算法(java原生JDK实现-附源码地址)

一、项目需求

1.    需求链接

https://tianchi.aliyun.com/getStart/information.htm?raceId=231522

2.    需求内容

竞赛题目

在真实的业务场景下,我们往往需要对所有商品的一个子集构建个性化推荐模型。在完成这件任务的过程中,我们不仅需要利用用户在这个商品子集上的行为数据,往往还需要利用更丰富的用户行为数据。定义如下的符号:
U——
用户集合
I——
商品全集
P——
商品子集, I
D——
用户对商品全集的行为数据集合
那么我们的目标是利用D来构造U中用户对P中商品的推荐模型。

数据说明

本场比赛提供20000用户的完整行为数据以及百万级的商品信息。竞赛数据包含两个部分。

第一部分是用户在商品全集上的移动端行为数据(D,表名为tianchi_fresh_comp_train_user_2w,包含如下字段:

字段

字段说明

提取说明

user_id

用户标识

抽样&字段脱敏

item_id

商品标识

字段脱敏

behavior_type

用户对商品的行为类型

包括浏览、收藏、加购物车、购买,对应取值分别是1234

user_geohash

用户位置的空间标识,可以为空

由经纬度通过保密的算法生成

item_category

商品分类标识

字段脱敏

time

行为时间

精确到小时级别

第二个部分是商品子集(P,表名为tianchi_fresh_comp_train_item_2w,包含如下字段: 

 字段

字段说明

提取说明

 item_id

 商品标识

 抽样&字段脱敏

 item_ geohash

 商品位置的空间标识,可以为空

 由经纬度通过保密的算法生成

 item_category 

 商品分类标识

 字段脱敏

训练数据包含了抽样出来的一定量用户在一个月时间(11.18~12.18)之内的移动端行为数据(D),评分数据是这些用户在这个一个月之后的一天(12.19)对商品子集(P)的购买数据。参赛者要使用训练数据建立推荐模型,并输出用户在接下来一天对商品子集购买行为的预测结果。 

评分数据格式
具体计算公式如下:参赛者完成用户对商品子集的购买预测之后,需要将结果放入指定格式的数据表(非分区表)中,要求结果表名为:tianchi_mobile_recommendation_predict.csv,且以utf-8格式编码;包含user_iditem_id两列(均为string类型),要求去除重复。例如:


 

评估指标

比赛采用经典的精确度(precision)、召回率(recall)F1值作为评估指标。具体计算公式如下:


其中PredictionSet为算法预测的购买数据集合,ReferenceSet为真实的答案购买数据集合。我们以F1值作为最终的唯一评测标准。

二、协同过滤推荐算法原理及实现流程

1.    基于用户的协同过滤推荐算法

基于用户的协同过滤推荐算法通过寻找与目标用户具有相似评分的邻居用户,通过查找邻居用户喜欢的项目,推测目标用户也具有相同的喜好。基于用户的协同过滤推荐算法基本思想是:根据用户-项目评分矩阵查找当前用户的最近邻居,利用最近邻居的评分来预测当前用户对项目的预测值,将评分最高的N个项目推荐给用户,其中的项目可理解为系统处理的商品。其算法流程图如下图1所示。


图1基于用户的协同过滤推荐算法流程

基于用户的协同过滤推荐算法流程为:

1).构建用户项目评分矩阵

R={ , …… },T:m×n的用户评分矩阵,其中r={ , ,……, }为用户 的评分向量, 代表用户 对项目 的评分。

2).计算用户相似度

基于用户的协同过滤推荐算法,需查找与目标用户相似的用户。衡量用户之间的相似性需要计算每个用户的评分与其他用户评分的相似度,即评分矩阵中的用户评分记录。每个用户对项目的评分可以看作是一个n维的评分向量。使用评分向量计算目标用户 与其他用户 之间的相似度sim(i,j),通常计算用户相似度的方法有三种:余弦相似度、修正的余弦相似度和皮尔森相关系数。

3).构建最近邻居集

最近邻居集Neighor(u)中包含的是与目标用户具有相同爱好的其他用户。为选取邻居用户,我们首先计算目标用户u与其他用户v的相似度sim(u,v),再选择相似度最大的k个用户。用户相似度可理解为用户之间的信任值或推荐权重。通常,sim(u,v)∈[1,1]。用户相似度为1表示两个用户互相的推荐权重很大。如果为-1,表示两个用户的由于兴趣相差很大,因此互相的推荐权重很小。

4).预测评分计算

用户a 对项目i的预测评分p(a,i)为邻居用户对该项目评分的加权评分值。显然,不同用户对于目标用户的影响程度不同,所以在计算预测评分时,不同用户有不同的权重。计算时,我们选择用户相似度作为用户的权重因子,计算公式如下:

   

      基于用户的协同过滤推荐算法实现步骤为:

1).实时统计user对item的打分,从而生成user-item表(即构建用户-项目评分矩阵);

2).计算各个user之间的相似度,从而生成user-user的得分表,并进行排序;

3).对每一user的item集合排序;

4).针对预推荐的user,在user-user的得分表中选择与该用户最相似的N个用户,并在user-item表中选择这N个用户中已排序好的item集合中的topM;

5).此时的N*M个商品即为该用户推荐的商品集。

2.    基于项目的协同过滤推荐算法

基于项目的协同过滤推荐算法依据用户-项目评分矩阵通过计算项目之间的评分相似性来衡量项目评分相似性,找到与目标项目最相似的n个项目作为最近邻居集。然后通过对目标项目的相似邻居赋予一定的权重来预测当前项目的评分,再将得到的最终预测评分按序排列,将评分最高的N个项目推荐给当前用户,其中的项目可理解为系统处理的商品。其算法流程如下图2所示。


图2基于项目的协同过滤推荐算法流程

基于项目的协同过滤推荐算法流程为:

首先,读取目标用户的评分记录集合 ;然后计算项目i与 中其他项目的相似度,选取k个最近邻居;根据评分相似度计算公式计算候选集中所有项目的预测评分;最后选取预测评分最高的N个项目推荐给用户。

基于项目的协同过滤推荐算法预测评分与其他用户评分的加权评分值相关,不同的历史评分项目与当前项目i的相关度有差异,所以在进行计算时,不同的项目有不同的权重。评分预测函数p(u,i),以项目相似度作为项目的权重因子,得到的评分公式如下:


基于项目的协同过滤推荐算法实现步骤为:

1).实时统计user对item的打分,从而生成user-item表(即构建用户-项目评分矩阵);

2).计算各个item之间的相似度,从而生成item-item的得分表,并进行排序;

3).对每一user的item集合排序;

4).针对预推荐的user,在该用户已选择的item集合中,根据item-item表选择与已选item最相似的N个item;

5).此时的N个商品即为该用户推荐的商品集。

3.    基于用户的协同过滤推荐算法与基于项目的协同过滤推荐算法比较

基于用户的协同过滤推荐算法:

可以帮助用户发现新的商品,但需要较复杂的在线计算,需要处理新用户的问题。

基于项目的协同过滤推荐算法:

准确性好,表现稳定可控,便于离线计算,但推荐结果的多样性会差一些,一般不会带给用户惊喜性。

三、    项目实现

针对移动推荐,我们选择使用基于用户的协同过滤推荐算法来进行实现。

1.    数据模型及其实体类

用户行为数据:(user.csv)

user_id,item_id,behavior_type,user_geohash,item_category,time

10001082,285259775,1,97lk14c,4076,2014-12-08 18

10001082,4368907,1,,5503,2014-12-12 12

10001082,4368907,1,,5503,2014-12-12 12

10001082,53616768,1,,9762,2014-12-02 15

10001082,151466952,1,,5232,2014-12-12 11

10001082,53616768,4,,9762,2014-12-02 15

10001082,290088061,1,,5503,2014-12-12 12

10001082,298397524,1,,10894,2014-12-12 12

10001082,32104252,1,,6513,2014-12-12 12

10001082,323339743,1,,10894,2014-12-1212

商品信息:(item.csv)

item_id,item_geohash,item_category

100002303,,3368

100003592,,7995

100006838,,12630

100008089,,7791

100012750,,9614

100014072,,1032

100014463,,9023

100019387,,3064

100023812,,6700

package entity;public class Item {private String itemId;private String itemGeoHash;private String itemCategory;public String getItemId() {return itemId;}public void setItemId(String itemId) {this.itemId = itemId;}public String getItemGeoHash() {return itemGeoHash;}public void setItemGeoHash(String itemGeoHash) {this.itemGeoHash = itemGeoHash;}public String getItemCategory() {return itemCategory;}public void setItemCategory(String itemCategory) {this.itemCategory = itemCategory;}@Overridepublic String toString() {return "item [itemId=" + itemId + ", itemGeoHash=" + itemGeoHash+ ", itemCategory=" + itemCategory + "]";}}
package entity;public class Score implements Comparable<Score> {private String userId;      // 用户标识private String itemId;      // 商品标识private double score;public String getUserId() {return userId;}public void setUserId(String userId) {this.userId = userId;}public String getItemId() {return itemId;}public void setItemId(String itemId) {this.itemId = itemId;}public double getScore() {return score;}public void setScore(double score) {this.score = score;}@Overridepublic String toString() {return "Score [userId=" + userId + ", itemId=" + itemId + ", score="+ score + "]";}@Overridepublic int compareTo(Score o) {if ((this.score - o.score) < 0) {return 1;}else if ((this.score - o.score) > 0) {return -1;}else {return 0;}}}
package entity;public class User implements Comparable<User> {private String userId;      // 用户标识private String itemId;      // 商品标识private int behaviorType;   // 用户对商品的行为类型,可以为空,包括浏览、收藏、加购物车、购买,对应取值分别是1、2、3、4.private String userGeoHash; // 用户位置的空间标识private String itemCategory;// 商品分类标识private String time;        // 行为时间private int count;private double weight;      // 权重public String getUserId() {return userId;}public void setUserId(String userId) {this.userId = userId;}public String getItemId() {return itemId;}public void setItemId(String itemId) {this.itemId = itemId;}public int getBehaviorType() {return behaviorType;}public void setBehaviorType(int behaviorType) {this.behaviorType = behaviorType;}public String getUserGeoHash() {return userGeoHash;}public void setUserGeoHash(String userGeoHash) {this.userGeoHash = userGeoHash;}public String getItemCategory() {return itemCategory;}public void setItemCategory(String itemCategory) {this.itemCategory = itemCategory;}public String getTime() {return time;}public void setTime(String time) {this.time = time;}@Overridepublic String toString() {return "User [userId=" + userId + ", itemId=" + itemId+ ", behaviorType=" + behaviorType + ", count=" + count + "]";}public int getCount() {return count;}public void setCount(int count) {this.count = count;}public double getWeight() {return weight;}public void setWeight(double weight) {this.weight = weight;}@Overridepublic int compareTo(User o) {return (int)((-1) * (this.weight - o.weight));}}

2.    工具类

文件处理工具:

package util;import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;import entity.Item;
import entity.Score;
import entity.User;public class FileTool {public static FileReader fr=null;public static BufferedReader br=null;public static String line=null;public static FileOutputStream fos1 = null,fos2 = null,fos3 = null;public static PrintStream ps1 = null,ps2 = null,ps3 = null;public static int count = 0;/** * 初始化写文件器(单一指针)* */public static void initWriter1(String writePath) {try {fos1 = new FileOutputStream(writePath);ps1 = new PrintStream(fos1);} catch (FileNotFoundException e) {e.printStackTrace();}}/** * 关闭文件器(单一指针)* */public static void closeRedaer() {try {br.close();fr.close();} catch (IOException e) {e.printStackTrace();}}/** * 关闭文件器(单一指针)* */public static void closeWriter1() {try {ps1.close();fos1.close();} catch (IOException e) {e.printStackTrace();}}/** * 初始化写文件器(双指针)* */public static void initWriter2(String writePath1,String writePath2) {try {fos1 = new FileOutputStream(writePath1);ps1 = new PrintStream(fos1);fos2 = new FileOutputStream(writePath2);ps2 = new PrintStream(fos2);} catch (FileNotFoundException e) {e.printStackTrace();}}/** * 关闭文件器(双指针)* */public static void closeWriter2() {try {ps1.close();fos1.close();ps2.close();fos2.close();} catch (IOException e) {e.printStackTrace();}}/** * 初始化写文件器(三指针)* */public static void initWriter3(String writePath1,String writePath2,String writePath3) {try {fos1 = new FileOutputStream(writePath1);ps1 = new PrintStream(fos1);fos2 = new FileOutputStream(writePath2);ps2 = new PrintStream(fos2);fos3 = new FileOutputStream(writePath3);ps3 = new PrintStream(fos3);} catch (FileNotFoundException e) {e.printStackTrace();}}/** * 关闭文件器(三指针)* */public static void closeWriter3() {try {ps1.close();fos1.close();ps2.close();fos2.close();ps3.close();fos3.close();} catch (IOException e) {e.printStackTrace();}}public static List readFileOne(String path,boolean isTitle,String token,String pattern) throws Exception {List<Object> ret = new ArrayList<Object>();fr = new FileReader(path);br = new BufferedReader(fr);int count = 0,i = 0;if (isTitle) {line = br.readLine();count++;}while((line = br.readLine()) != null){String[] strArr = line.split(token);switch (pattern) {case "item":ret.add(ParseTool.parseItem(strArr));break;case "user":ret.add(ParseTool.parseUser(strArr));break;case "score":ret.add(ParseTool.parseScore(strArr));default:ret.add(line);break;}count++;if (count/100000 == 1) {i++;System.out.println(100000*i);count = 0;}}closeRedaer();return ret;}public static void makeSampleData(String inputPath,boolean isTitle,String outputPath,int threshold) throws Exception {fr = new FileReader(inputPath);br = new BufferedReader(fr);initWriter1(outputPath);if (isTitle) {line = br.readLine();}int count = 0;while((line = br.readLine()) != null){ps1.println(line);count++;if (count == threshold) {break;}}closeRedaer();}public static List<String> traverseFolder(String dir) {File file = new File(dir);String[] fileList = null;if (file.exists()) {fileList = file.list();}List<String> list = new ArrayList<String>();for(String path : fileList){list.add(path);}return list;}public static Map<String, List<Score>> loadScoreMap(String path,boolean isTitle,String token) throws Exception {fr = new FileReader(path);br = new BufferedReader(fr);if (isTitle) {line = br.readLine();}Map<String, List<Score>> scoreMap = new HashMap<String, List<Score>>();while((line = br.readLine()) != null){String[] arr = line.split(token);Score score = ParseTool.parseScore(arr);List<Score> temp = new ArrayList<Score>();if (scoreMap.containsKey(score.getUserId())) {temp = scoreMap.get(score.getUserId());}temp.add(score);scoreMap.put(score.getUserId(), temp);}closeRedaer();return scoreMap;}public static Map<String, List<String>> loadPredictData(String path,boolean isTitle,String token) throws Exception {fr = new FileReader(path);br = new BufferedReader(fr);if (isTitle) {line = br.readLine();}Map<String, List<String>> map = new HashMap<String, List<String>>();while((line = br.readLine()) != null){String[] arr = line.split(token);String userId = arr[0];String itemId = arr[1];List<String> temp = new ArrayList<String>();if (map.containsKey(userId)) {temp = map.get(userId);}temp.add(itemId);map.put(userId, temp);count++;}closeRedaer();return map;}public static Map<String, List<String>> loadTestData(Map<String, List<String>> predictMap, String dir, boolean isTitle, String token) throws Exception {List<String> fileList = traverseFolder(dir);Set<String> predictKeySet = predictMap.keySet();Map<String, List<String>> testMap = new HashMap<String, List<String>>();for(String predictKey : predictKeySet){if (fileList.contains(predictKey)) {List<String> itemList = loadTestData(dir + predictKey, isTitle, token);testMap.put(predictKey, itemList);}}return testMap;}public static List<String> loadTestData(String path, boolean isTitle, String token) throws Exception {fr = new FileReader(path);br = new BufferedReader(fr);if (isTitle) {line = br.readLine();}List<String> list = new ArrayList<String>();Set<String> set = new HashSet<String>();while((line = br.readLine()) != null){String[] arr = line.split(token);set.add(arr[1]);count++;}closeRedaer();for(String item : set){list.add(item);}return list;}public static Map<String, Double> loadUser_ItemData(String path,boolean isTitle,String token) throws Exception {fr = new FileReader(path);br = new BufferedReader(fr);if (isTitle) {line = br.readLine();}Map<String, Double> map = new HashMap<String, Double>();while((line = br.readLine()) != null){String[] arr = line.split(token);String itemId = arr[1];double score = Double.valueOf(arr[2]);if(map.containsKey(itemId)){double temp = map.get(itemId);if (temp > score) {score = temp;}}map.put(itemId, score);}closeRedaer();return map;}public static Map<String, Set<String>> loadTestUser(String path,boolean isTitle,String token) throws Exception {fr = new FileReader(path);br = new BufferedReader(fr);int count = 0,i = 0;if (isTitle) {line = br.readLine();count++;}Map<String, Set<String>> map = new HashMap<String, Set<String>>();while((line = br.readLine()) != null){String[] arr = line.split(token);String userId = arr[0];String itemId = arr[1];Set<String> set = new HashSet<String>();if (map.containsKey(userId)) {set = map.get(userId);set.add(itemId);}map.put(userId, set);count++;if (count/100000 == 1) {i++;System.out.println(100000*i);count = 0;}}closeRedaer();return map;}}

解析工具:

package util;import entity.Item;
import entity.Score;
import entity.User;public class ParseTool {public static boolean isNumber(String str) {int i,n;n = str.length();for(i = 0;i < n;i++){if (!Character.isDigit(str.charAt(i))) {return false;}}return true;}public static Item parseItem(String[] contents) {Item item = new Item();if (contents[0] != null && !contents[0].isEmpty()) {item.setItemId(contents[0].trim());}if (contents[1] != null && !contents[1].isEmpty()) {item.setItemGeoHash(contents[1].trim());}if (contents[2] != null && !contents[2].isEmpty()) {item.setItemCategory(contents[2].trim());}return item;}public static User parseUser(String[] contents) {User user = new User();int n = contents.length;if (contents[0] != null && !contents[0].isEmpty()) {user.setUserId(contents[0].trim());}if (contents[1] != null && !contents[1].isEmpty()) {user.setItemId(contents[1].trim());}/*// 2.调用CountFileTest需放开,其它需注释if (contents[2] != null && !contents[2].isEmpty()) {user.setBehaviorType(Integer.valueOf(contents[2].trim()));}// 2.调用CountFileTest需放开,其它需注释if (contents[n-1] != null && !contents[n-1].isEmpty()) {user.setCount(Integer.valueOf(contents[n-1].trim()));}*/// 3.调用PredictTest需放开,其它需注释if (contents[n-1] != null && !contents[n-1].isEmpty()) {user.setWeight(Double.valueOf(contents[n-1].trim()));}/*// 1.调用SpliteFileAndMakeScoreTable需放开,其它需注释if (contents[3] != null && !contents[3].isEmpty()) {user.setUserGeoHash(contents[3].trim());}if (contents[4] != null && !contents[4].isEmpty()) {user.setItemCategory(contents[4].trim());}if (contents[5] != null && !contents[5].isEmpty()) {user.setTime(contents[5].trim());}*/return user;}public static Score parseScore(String[] contents) {Score score = new Score();if (contents[0] != null && !contents[0].isEmpty()) {score.setUserId(contents[0].trim());}if (contents[1] != null && !contents[1].isEmpty()) {score.setItemId(contents[1].trim());}if (contents[2] != null && !contents[2].isEmpty()) {score.setScore(Double.parseDouble(contents[2].trim()));}return score;}
}

3.    数据处理模块:

package service;import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;import util.FileTool;
import entity.Item;
import entity.Score;
import entity.User;public class DataProcess {public static final double[] w = {0,10,20,30}; public static void output(Map<String, Map<String, List<User>>> userMap,String outputPath) {for(Entry<String, Map<String, List<User>>> entry : userMap.entrySet()){FileTool.initWriter1(outputPath + entry.getKey());Map<String, List<User>> temp = entry.getValue();for(Entry<String, List<User>> tempEntry : temp.entrySet()){List<User> users = tempEntry.getValue();int count = users.size();for(User user : users){FileTool.ps1.print(user.getUserId() + "\t");FileTool.ps1.print(user.getItemId() + "\t");FileTool.ps1.print(user.getBehaviorType() + "\t");//FileTool.ps1.print(user.getUserGeoHash() + "\t");//FileTool.ps1.print(user.getItemCategory() + "\t");//FileTool.ps1.print(user.getTime() + "\t");FileTool.ps1.print(count + "\n");}}}FileTool.closeWriter1();}public static void output(Map<String, Map<String, Double>> scoreTable, String outputPath, Set<String> userSet, Set<String> itemSet, String token) {FileTool.initWriter1(outputPath);for(String itemId: itemSet){FileTool.ps1.print(token + itemId);}FileTool.ps1.println();for(String userId : userSet){FileTool.ps1.print(userId + token);Map<String, Double> itemMap = scoreTable.get(userId);for(String itemId: itemSet){if(itemMap.containsKey(itemId)){FileTool.ps1.print(itemMap.get(itemId));}else {//FileTool.ps1.print(0);}FileTool.ps1.print(token);}FileTool.ps1.print("\n");}}public static void outputUser(List<User> userList) {for(User user : userList){FileTool.ps1.println(user.getUserId() + "\t" + user.getItemId() + "\t" + user.getWeight());}}public static void outputScore(List<Score> scoreList) {for(Score score : scoreList){FileTool.ps1.println(score.getUserId() + "\t" + score.getItemId() + "\t" + score.getScore());}}public static void outputRecommendList(Map<String, Set<String>> map) {for(Entry<String, Set<String>> entry : map.entrySet()){String userId = entry.getKey();Set<String> itemSet = entry.getValue();for(String itemId : itemSet){FileTool.ps1.println(userId + "," + itemId);}}}public static void output(Map<String, Set<String>> map) {for(Entry<String, Set<String>> entry : map.entrySet()){String userId = entry.getKey();Set<String> set = entry.getValue();for(String itemId : set){FileTool.ps1.println(userId + "\t" + itemId);}}}public static Map<String, Map<String, List<User>>> mapByUser(List<User> userList,Set<String> userSet,Set<String> itemSet) {Map<String, Map<String, List<User>>> userMap = new HashMap<>();for(User user: userList){Map<String, List<User>> tempMap = new HashMap<String, List<User>>();List<User> tempList = new ArrayList<User>();if (!userMap.containsKey(user.getUserId())) {}else {tempMap = userMap.get(user.getUserId());if (!tempMap.containsKey(user.getItemId())) {}else {tempList = tempMap.get(user.getItemId());}}tempList.add(user);tempMap.put(user.getItemId(), tempList);userMap.put(user.getUserId(), tempMap);userSet.add(user.getUserId());itemSet.add(user.getItemId());}return userMap;}public static Map<String, Map<String, Double>> makeScoreTable(Map<String, Map<String, List<User>>> userMap) {Map<String, Map<String, Double>> scoreTable = new HashMap<String, Map<String,Double>>();for(Entry<String, Map<String, List<User>>> userEntry : userMap.entrySet()){Map<String, List<User>> itemMap = userEntry.getValue();String userId = userEntry.getKey();Map<String, Double> itemScoreMap = new HashMap<String, Double>();for(Entry<String, List<User>> itemEntry : itemMap.entrySet()){String itemId = itemEntry.getKey();List<User> users = itemEntry.getValue();double weight = 0.0;int maxType = 0;for(User user : users){if (user.getBehaviorType() > maxType) {maxType = user.getBehaviorType();}}int count = users.size();if (maxType != 0) {weight += w[maxType-1];}weight += count;itemScoreMap.put(itemId, weight);}scoreTable.put(userId, itemScoreMap);}return scoreTable;}public static double calculateWeight(int behaviorType, int count) {double weight = w[behaviorType-1] + count;return weight;}public static List<User> reduceUserByItem(List<User> userList) {List<User> list = new ArrayList<User>();Map<String, User> userMap = new LinkedHashMap<String, User>();for(User user : userList){String itemId = user.getItemId();if (!userMap.containsKey(itemId)) {double weight = calculateWeight(user.getBehaviorType(), user.getCount());user.setWeight(weight);userMap.put(itemId, user);list.add(user);}else {User temp = userMap.get(itemId);if (temp.getBehaviorType() < user.getBehaviorType()) {double weight = calculateWeight(user.getBehaviorType(), user.getCount());user.setWeight(weight);userMap.put(itemId, user);list.add(user);}}}userMap.clear();return list;}public static void sortScoreMap(Map<String, List<Score>> scoreMap) {Set<String> userSet = scoreMap.keySet();for(String userId : userSet){List<Score> temp = scoreMap.get(userId);Collections.sort(temp);scoreMap.put(userId, temp);}}public static Map<String, Set<String>> predict(Map<String, List<Score>> scoreMap, List<String> fileNameList, String userDir,int topNUser,int topNItem) throws Exception {Map<String, Set<String>> recommendList = new HashMap<String, Set<String>>();for(Entry<String, List<Score>> entry : scoreMap.entrySet()){String userId1 = entry.getKey();List<Score> list = entry.getValue();int countUser = 0;Set<String> predictItemSet = new LinkedHashSet<String>();for(Score score : list){String userId2 = score.getItemId();if(fileNameList.contains(userId2)){List<User> userList = FileTool.readFileOne(userDir + userId2, false, "\t", "user");int countItem = 0;for(User user : userList){predictItemSet.add(user.getItemId());countItem++;if (countItem == topNItem) {break;}}countUser++;}if (countUser == topNUser) {break;}}recommendList.put(userId1, predictItemSet);}return recommendList;}public static void prediction(Map<String, List<String>> predictMap,int predictN, Map<String, List<String>> referenceMap, int refN) {int count = 0;for(Entry<String, List<String>> predictEntity : predictMap.entrySet()){String userId = predictEntity.getKey();if (referenceMap.containsKey(userId)) {List<String> predictList = predictEntity.getValue();for(String itemId : predictList){if (referenceMap.get(userId).contains(itemId)) {count++;}}}}double precision = (1.0 * count / predictN) * 100;double recall = (1.0 * count / refN) * 100;double f1 = (2 * precision * recall)/(precision + recall);System.out.println("precision="+precision+",recall="+recall+",f1="+f1);}}

4.    计算模块

package service;import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;import entity.Score;
import util.FileTool;public class CalculateSimilarity {public static double EuclidDist(Map<String, Double> userMap1,Map<String, Double> userMap2, Set<String> userSet,Set<String> itemSet) {double sum = 0;for (String itemId : itemSet) {double score1 = 0.0;double score2 = 0.0;if (userMap1.containsKey(itemId) && userMap2.containsKey(itemId)) {score1 = userMap1.get(itemId);score2 = userMap2.get(itemId);} else if (userMap1.containsKey(itemId)) {score1 = userMap1.get(itemId);} else if (userMap2.containsKey(itemId)) {score2 = userMap2.get(itemId);}double temp = Math.pow((score1 - score2), 2);sum += temp;}sum = Math.sqrt(sum);return sum;}public static double CosineDist(Map<String, Double> userMap1,Map<String, Double> userMap2, Set<String> userSet,Set<String> itemSet) {double dist = 0;double numerator = 0; // 分子double denominator1 = 0; // 分母double denominator2 = 0; // 分母for (String itemId : itemSet) {double score1 = 0.0;double score2 = 0.0;if (userMap1.containsKey(itemId) && userMap2.containsKey(itemId)) {numerator++;score1 = userMap1.get(itemId);score2 = userMap2.get(itemId);} else if (userMap1.containsKey(itemId)) {score1 = userMap1.get(itemId);} else if (userMap2.containsKey(itemId)) {score2 = userMap2.get(itemId);}denominator1 += Math.pow(score1, 2);denominator2 += Math.pow(score2, 2);}dist = ((1.0 * numerator) / (Math.sqrt(denominator1) * Math.sqrt(denominator2)));return dist;}public static double execute(Map<String, Double> userMap1,Map<String, Double> userMap2,Set<String> userSet,Set<String> itemSet) {double dist = EuclidDist(userMap1, userMap2, userSet, itemSet);double userScore = 1.0 / (1.0 + dist);// double userScore = CosineDist(userMap1, userMap2, userSet, itemSet);return userScore;}public static void execute(String userId,Map<String, Map<String, Double>> scoreTable,Set<String> userSet, Set<String> itemSet) {for (Entry<String, Map<String, Double>> userEntry : scoreTable.entrySet()) {String userId2 = userEntry.getKey();Map<String, Double> userMap2 = userEntry.getValue();double dist = EuclidDist(scoreTable.get(userId), userMap2, userSet, itemSet);double userScore = 1.0 / (1.0 + dist);// double userScore = CosineDist(userMap1, userMap2, userSet, itemSet);FileTool.ps1.println(userId + "\t" + userId2 + "\t" + userScore);}}public static void execute(Map<String, Map<String, Double>> scoreTable,Set<String> userSet, Set<String> itemSet) {List<Score> similarList = new ArrayList<Score>();for (Entry<String, Map<String, Double>> userEntry1 : scoreTable.entrySet()) {String userId = userEntry1.getKey();execute(userId, scoreTable, userSet, itemSet);}}}

5.    脚本

生成userset和itemset:

package script;import java.util.HashSet;
import java.util.List;
import java.util.Set;import entity.User;
import util.FileTool;public class MakeSet {public static void main(String[] args) throws Exception {String inputDir = args[0];String outputDir = args[1];Set<String> userSet = new HashSet<String>();Set<String> itemSet = new HashSet<String>();List<String> pathList = FileTool.traverseFolder(inputDir);for(String path : pathList){String inputPath = inputDir + path;List<User> list = FileTool.readFileOne(inputPath, false, "\t", "user");for(User user : list){userSet.add(user.getUserId());itemSet.add(user.getItemId());}}FileTool.initWriter1(outputDir+"userSet");for(String userId : userSet){FileTool.ps1.println(userId);}FileTool.closeWriter1();FileTool.initWriter1(outputDir+"itemSet");for(String itemId : itemSet){FileTool.ps1.println(itemId);}FileTool.closeWriter1();}}

map文件构建user-item评分矩阵并计算user间的相似度生成user-user的得分表:

package script;import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;import entity.Item;
import entity.Score;
import entity.User;
import service.CalculateSimilarity;
import service.DataProcess;
import util.FileTool;public class SpliteFileAndMakeScoreTable {public static void main(String[] args) throws Exception {//String inputDir = "data/fresh_comp_offline/";//String outputDir = "data/fresh_comp_offline/sample/";//String inputDir = "data/fresh_comp_offline/sample/";//String outputDir = "data/fresh_comp_offline/sample/out/";String inputDir = args[0];String outputDir = args[1];//String userPath = inputDir + "tianchi_fresh_comp_train_user.csv";String userPath = inputDir + args[2];String outputPath = args[3];//String outputPath = outputDir + "user.csv";//FileTool.makeSampleData(userPath, true, outputPath, 10000);//List<Object> itemList = FileTool.readFileOne(itemPath, true, ",", "item");//List<User> userList = FileTool.readFileOne(userPath, false, ",", "user");List<User> userList = FileTool.readFileOne(userPath, false, ",", "user");Set<String> userSet = new HashSet<String>();Set<String> itemSet = new HashSet<String>();Map<String, Map<String, List<User>>> userMap = DataProcess.mapByUser(userList,userSet,itemSet);userList.clear();DataProcess.output(userMap, outputDir);//生成userToItem的打分表Map<String, Map<String, Double>> scoreTable = DataProcess.makeScoreTable(userMap);//DataProcess.output(scoreTable, outputDir + "scoreTable.csv" , userSet, itemSet, ",");userMap.clear();FileTool.initWriter1(outputPath);CalculateSimilarity.execute(scoreTable, userSet, itemSet);FileTool.closeWriter1();}}

reduce文件:

package script;import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;import entity.User;
import service.DataProcess;
import util.FileTool;public class ReduceFileTest {public static void main(String[] args) throws Exception {//String inputDir = "data/fresh_comp_offline/";//String outputDir = "data/fresh_comp_offline/sample/";//String inputDir = "data/fresh_comp_offline/sample/";//String outputDir = "data/fresh_comp_offline/sample/out/";String inputDir = args[0];String outputDir = args[1];//String userPath = inputDir + "tianchi_fresh_comp_train_user.csv";//String itemPath = inputDir + args[2];//String userPath = inputDir + args[3];List<String> pathList = FileTool.traverseFolder(inputDir);for(String path : pathList){List<User> userList = FileTool.readFileOne(inputDir+path, false, "\t", "user");List<User> list = DataProcess.reduceUserByItem(userList);userList.clear();FileTool.initWriter1(outputDir + path);Collections.sort(list);DataProcess.outputUser(list);FileTool.closeWriter1();list.clear();}}
}

为用户进行推荐,生成预测列表:

package script;import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;import service.DataProcess;
import util.FileTool;
import entity.Score;public class PredictTest {public static void main(String[] args) throws Exception {//String inputDir = "data/fresh_comp_offline/";//String outputDir = "data/fresh_comp_offline/sample/";//String inputDir = "data/fresh_comp_offline/sample/";//String outputDir = "data/fresh_comp_offline/sample/out/";String inputDir = args[0];String outputDir = args[1];//String userPath = inputDir + "tianchi_fresh_comp_train_user.csv";String inputPath = inputDir + args[2];String outputPath = inputDir + args[3];String userDir = args[4];Map<String, List<Score>> scoreMap = FileTool.loadScoreMap(inputPath, false, "\t");DataProcess.sortScoreMap(scoreMap);List<String> fileNameList = FileTool.traverseFolder(userDir);//我选择推荐该user的最相似的5个user的前5个itemMap<String, Set<String>> predictMap = DataProcess.predict(scoreMap, fileNameList, userDir, 5, 5);FileTool.initWriter1(outputPath);DataProcess.outputRecommendList(predictMap);FileTool.closeWriter1();scoreMap.clear();}
}

计算准确率、召回率、F测度值:

package script;import java.util.List;
import java.util.Map;import service.DataProcess;
import util.FileTool;public class MatchTest2 {public static void main(String[] args) throws Exception {String inputDir = args[0];String inputPath1 = inputDir + args[1];String userDir = args[2];Map<String, List<String>> predictMap = FileTool.loadPredictData(inputPath1, false, ",");int predictN = FileTool.count;System.out.println(predictN);FileTool.count = 0;Map<String, List<String>> referenceMap = FileTool.loadTestData(predictMap, userDir, false, "\t");int referenceN = FileTool.count;System.out.println(referenceN);DataProcess.prediction(predictMap, predictN, referenceMap, referenceN);}}

以上为核心代码,大家可以参考项目源代码地址:

http://download.csdn.net/download/u013473512/10141066

https://github.com/Emmitte/recommendSystem















查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. Java实现堆排序问题(变治法)

    问题描述 用基于变治法的堆排序算法对任意一组给定的数据进行排序 2.1 堆排序原理简介 堆可以定义为一颗二叉树,树的节点中包含键(每个节点是一个键),并且满足下面两个条件: (1)树的形状要求——这颗二叉树是基本完备的(或者简称为完成二叉树),这意味着,树的每一层…...

    2024/4/20 18:34:38
  2. 十大最佳Android游戏下载平台

    转载:十大最佳Android游戏下载平台 Android游戏的快速发展,让人感叹,后生可畏,不知道做为Android用户的您,是从哪里开始下载Android游戏的,甚至说你的手机第一张壁纸有事从哪儿下载的。不要认为只有《愤怒的小鸟》才是最精品的游戏。eoe帮您汇总了十大最佳游戏下载的平台…...

    2024/4/20 18:34:37
  3. android Preference之android:dependency

    http://blog.csdn.net/hustpzb/article/details/6884782 在开发软件设置界面的时候,我们可以采用android系统提供的PreferenceActivity来实现,下面给出一个简单的例子: 1.Activity代码如下:[java] view plaincopyprint?public class ConfigActivity extends PreferenceAc…...

    2024/5/2 16:00:17
  4. 一种按权重分配的Java算法

    现有一需求,就是假设有若干任务执行者执行一定数目的任务,并且任务的分配需按一定的权重比来进行。任务的分配是随机的,分配完毕后需要为每条任务打上执行者的标签(即被谁执行。)分配算法不难,但是用java写起来还是蛮巧妙的~ 觉得很有意思,遂记之。 算法设计: 1)总的任…...

    2024/4/22 16:49:52
  5. 性能测试必备监控技能windows篇

    转载于:https://www.jianshu.com/p/7a4babd894bd前言在手头没有专门的第三方监控时,该怎么监控服务指标呢?本篇就windows下监控进行分享,也是我们在进行性能测试时,必须掌握的。下面我们就windows下常用的三种监视工具进行说明:任务管理器资源监视器性能监视器 在[开始] …...

    2024/5/8 14:03:38
  6. 排序算法6——堆排序

    堆排序简介 二叉堆简介 堆排序 总结堆排序简介堆排序可以看作是简单选择排序的一种的改进方法,平均复杂度为 \(O(n\log n)\),因此应用场合较多。其原理同简单选择排序相似:将数据分为已排序和未排序的两部分,并且不断的从未排序数据中选取最大(或最小)数据加入到已排序集合…...

    2024/4/21 8:14:01
  7. 十大最佳外国Android游戏下载平台

    [Android 应用]十大最佳外国Android游戏下载平台 Android游戏的快速发展,让人感叹,后生可畏,不知道做为Android用户的您,是从哪里开始下载Android游戏的,甚至说你的手机第一张壁纸有事从哪儿下载的。不要认为只有《愤怒的小鸟》才是最精品的游戏。我们帮您汇总了十大最佳游…...

    2024/4/21 8:14:01
  8. JVM-11虚拟机性能监控与故障处理工具之【JDK的可视化工具-JConsole】

    文章目录思维导图概述JConsole: Java监视与管理平台启动jconsole内存监控示例VM ARGS代码JConsole监控展示及说明扩展问题没有指定-Xmn,如何确定新生代和Eden的大小为何老年代的柱状图信息仍显示峰值状态,如何调整代码回收该区域线程监控示例活锁等待示例死锁等待示例 思维导图…...

    2024/4/23 23:35:42
  9. Android小技巧-SharedPreferences实现设置界面

    SharedPreferences的一个用途是实现设置界面,虽然现在的许大家都用它来存储基本的键值对。 #1.设置xml /res/xml/preferences.xml<PreferenceScreenxmlns:android="http://schemas.android.com/apk/res/android"><PreferenceCategoryandroid:title="G…...

    2024/5/8 15:34:18
  10. [Java算法]--生成全局唯一的Id(IdGen)

    全局唯一ID生成器浅析 我们在开发中,有时非常需要一个全局唯一的ID值,不管是业务需求,还是为了以后可能的分表需求,全局唯一值都非常有用,本篇大象就来讲讲这个实现并对ID生成器性能进行一下测试。 大象所讲的这个全局唯一ID生成器,其实是Twitter公开的一个算法,源码…...

    2024/4/21 8:13:57
  11. java.lang.SecurityException: Permission Denial: starting Intent 原来是这样

    安卓系统升级到7.0后,本人设计的app照相机打不开了。因为Android6.0以后时相机摄像头权限改成了动态权限申请。修改相应代码参考https://blog.csdn.net/lone1ycode/article/details/79833842模拟器可以打开相机,但是下载到真机后,点击相机闪退。ide是AndroidStudio,logcat抛…...

    2024/4/20 15:59:50
  12. 全能系统监控工具dstat

    在linux上有top、free、iostat、vmstat、netstat等诸多监控系统各项性能的工具,如top,可以实时监控到系统负载、内存等使用情况,iostat能监控系统I/O情况,而vmstat可以得到关于进程、内存、内存分页、堵塞IO、traps及CPU活动的信息(以上一个工具的部分介绍参考我的另外一篇…...

    2024/5/8 12:06:56
  13. 【经典排序算法】(一)--- 比较类排序(冒泡排序,快速排序 ,简单插入排序,希尔排序,简单选择排序,堆排序,归并排序)

    【经典排序算法】(一)--- 比较类排序(冒泡排序,快速排序 ,简单插入排序,希尔排序,简单选择排序,堆排序,归并排序概述算法复杂度相关概念一. 交换排序1. 冒泡排序2. 快速排序二. 插入排序1. 简单插入排序2. 希尔排序三. 选择排序1. 简单选择排序2. 堆排序四. 归并排序1…...

    2024/4/21 8:13:54
  14. 轮盘赌算法的java实现算例

    轮盘赌介绍算法实现package test;public class Test {public static double[] multiPros;public static void main(String[] args) {multiPros = new double[4];multiPros[0] = 0.14;multiPros[1] = 0.49;multiPros[2] = 0.06;multiPros[3] = 0.31;for (int i = 0; i < 10; …...

    2024/4/21 8:13:53
  15. 人工鱼群算法超详细解析附带JAVA代码

    01 前言本着学习的心态,还是想把这个算法写一写,给大家科普一下的吧。02 人工鱼群算法2.1 定义人工鱼群算法为山东大学副教授李晓磊2002年从鱼找寻食物的现象中表现的种种移动寻觅特点中得到启发而阐述的仿生学优化方案。在一片水域中,鱼往往能自行或尾随其他鱼找到营养物质…...

    2024/4/20 20:43:02
  16. android7.0 settings问题汇总

    一、android cannot cast from preference to switchpreference 解决办法: 导包错误,应导入: import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.DropDownPreference; import android.support.v7.preference.ListPreference; …...

    2024/4/22 17:51:19
  17. Android中preference的使用(二)

    继上篇文章 Android中preference的使用(一) ,在这篇文章中主要是学习下preference中各个节点的属性。PrefeneceActivity都提供了哪几种元素可供使用。点击Add按钮,在打开的新窗口中可以看到以下几项:1. CheckBoxPreference:CheckBox选择项,对应的值的ture或flase。如图:2.…...

    2024/4/21 8:13:50
  18. 算法导论--堆排序

    堆排序的时间复杂度为nlg(n),堆排序还有一个重要的用途在优先队列上!下面是最大堆排序的实现算法: #include <stdio.h> int A[]={7,15,26,1,14,3,16,64,6,57}; int Heap_Size=sizeof(A)/4-1; void Max_Heapify(int *A,int i); //修复最大堆 void Build_Max…...

    2024/4/20 15:35:11
  19. linux网络流量实时监控工具之iptraf

    IPTraf是一个网络监控工具,功能比nload更强大,可以监控所有的流量,IP流量,按协议分的流量,还可以设置过滤器等. 对监控网络来说,这个更适合也更强大,但在总的流量显示上,没nload直观和方便yum方式安装yum install -y iptraf使用直接运行 iptraf后有一个如下的菜单提示,然后进入…...

    2024/4/20 18:34:44
  20. 排序算法猴子排序java算法代码实现

    <h1>猴子排序</h1>原理:现有一组未排序数据和相同数量的方格,然后依次随机地取出数据随机地放入方格中,直到把方格放满即止。之所以又被称为猴子排序,我的猜测是因为。将这种随机的特性利用猴子来形容,毕竟猴子并不懂数的大小,让猴子选择和放置数据肯定就是随…...

    2024/4/20 18:34:43

最新文章

  1. 【经验总结】Vue2中的全局变量(store

    需求场景 需要在vue中存储一个可变的&#xff0c;可读写的全局变量在不同的js、页面中均可调用和读写 技术&#xff1a;使用vue的store 用法总结 一、定义变量 1、找到vue的/src/store路径&#xff0c;在modules文件夹下创建文件&#xff08;这里便于测试创建demo.js&…...

    2024/5/8 15:35:04
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/5/7 10:36:02
  3. 自我介绍的HTML 页面(入门)

    一.前情提要 1.主要是代码示例&#xff0c;具体内容需自己填充 2.代码后是详解 二.代码实例和解析 代码 <!DOCTYPE html> <html lang"zh-CN"> <head> <meta charset"UTF-8"> <title>自我介绍页面</title>…...

    2024/5/5 7:22:10
  4. K8S容器空间不足问题分析和解决

    如上图&#xff0c;今天测试环境的K8S平台出现了一个问题&#xff0c;其中的一个容器报错&#xff1a;Free disk space below threshold. Available: 3223552 bytes (threshold: 10485760B)&#xff0c;意思服务器硬盘空间不够了。这个问题怎么产生的&#xff0c;又怎么解决的呢…...

    2024/5/4 14:52:56
  5. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/5/8 6:01:22
  6. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/5/7 9:45:25
  7. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/5/4 23:54:56
  8. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/5/7 14:25:14
  9. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/5/4 23:54:56
  10. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/5/4 23:55:05
  11. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/5/4 23:54:56
  12. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/5/7 11:36:39
  13. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/5/4 23:54:56
  14. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/5/6 1:40:42
  15. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/5/4 23:54:56
  16. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/5/4 23:55:17
  17. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/5/7 9:26:26
  18. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/5/4 23:54:56
  19. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/4 23:55:06
  20. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/5/5 8:13:33
  21. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/5/4 23:55:16
  22. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/5/4 23:54:58
  23. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/5/6 21:42:42
  24. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/5/4 23:54:56
  25. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  26. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  27. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  28. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  29. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  30. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  31. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  32. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  33. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  34. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  35. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  36. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  37. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  38. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  39. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  40. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  41. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  42. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  43. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  44. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57