数字营销实训算法第四轮修改

master
@t2652009480 7 months ago
parent fdf83ed20b
commit fcd2c83048

@ -191,13 +191,13 @@ public class StuDigitalMarketingModelController {
List<String> strings = convertToDelimitedStringList(deduplicatedDataList); List<String> strings = convertToDelimitedStringList(deduplicatedDataList);
//初始化事务数据库、项目集、候选集再进行剪枝 //初始化事务数据库、项目集、候选集再进行剪枝
Apriori.init(strings,support); Apriori.init(strings,confidence);
//迭代求出最终的候选频繁集 //迭代求出最终的候选频繁集
Apriori.iteration(Apriori.C,Apriori.L,support); Apriori.iteration(Apriori.C,Apriori.L,confidence);
//根据最终的关联集,根据公式计算出各个关联事件 //根据最终的关联集,根据公式计算出各个关联事件
List<AssociationRulesDTO> connection = Apriori.connection(confidence); List<AssociationRulesDTO> connection = Apriori.connection(support);
return new ResultEntity(HttpStatus.OK,"成功",connection); return new ResultEntity(HttpStatus.OK,"成功",connection);

@ -57,7 +57,7 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
List<String> list=stuTableNameMapper.getTableName(userId); List<String> list=stuTableNameMapper.getTableName(userId);
if(list.isEmpty()){ //设置默认值 if(list.isEmpty()){ //设置默认值
String[] arr={"客户细分数据表","销售预测数据表","购物车数据表","用户评论表"}; String[] arr={"客户细分数据表","销售预测数据表","购物车数据表"};
StuTableName stuTableName=new StuTableName(); StuTableName stuTableName=new StuTableName();
for (int i = 0; i < arr.length; i++) { for (int i = 0; i < arr.length; i++) {
@ -306,7 +306,7 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
if(tableName.equals(Constant.KEHUXISHUJU)){ if(tableName.equals(Constant.KEHUXISHUJU)){
// list=indicatorsMapper.getYHSXB(); // list=indicatorsMapper.getYHSXB();
list.add("id"); // list.add("id");
list.add("gender"); list.add("gender");
list.add("age"); list.add("age");
list.add("annual_income"); list.add("annual_income");

@ -162,13 +162,13 @@ public class Apriori {
} }
str = C.toString(); str = C.toString();
// System.out.println("候选"+t+"项集C: \n"+C); System.out.println("候选"+t+"项集C: \n"+C);
// 二、剪枝步 // 二、剪枝步
pruning(C, L,min_support); pruning(C, L,min_support);
// System.out.println("频繁"+t+"项集L: \n"+L+"\n"); System.out.println("频繁"+t+"项集L: \n"+L+"\n");
str = L.toString(); str = L.toString();
//System.out.println("==="); System.out.println("===");
L_ALL.putAll(L); L_ALL.putAll(L);
} }
return L_temp; return L_temp;
@ -252,7 +252,7 @@ public class Apriori {
if (confident > min_confident) {// 如果事件的置信度大于最小置信度 if (confident > min_confident) {// 如果事件的置信度大于最小置信度
//封装对象返回 //封装对象返回
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.00");
AssociationRulesDTO associationRulesDTO=new AssociationRulesDTO(); AssociationRulesDTO associationRulesDTO=new AssociationRulesDTO();
associationRulesDTO.setCorrelation(item_pre); associationRulesDTO.setCorrelation(item_pre);
associationRulesDTO.setAssociated(item_post); associationRulesDTO.setAssociated(item_post);

Loading…
Cancel
Save