whb 7 months ago
commit ac89b7e774

@ -80,7 +80,7 @@ public class Constant {
public static final String YHDLHYB = "用户登录活跃表";
public static final String YHXFNLB = "用户消费能力表";
public static final String YHXWB = "用户行为表";
public static final String YHPLB = "用户评论表";
public static final String YHPLB = "用户商品评论数据";
public static final String CONTEXT_OCR = "文章图片如下2024年我国发展改革领域\n" +

@ -157,10 +157,15 @@ public class StuDigitalMarketingModelController {
@AnonymousAccess
public ResultEntity clusterAnalysisResult(@RequestBody ClusterScatterPlotDTO clusterScatterPlotDTO) {
Integer t = clusterScatterPlotDTO.getT();
Integer k = clusterScatterPlotDTO.getK();
List<Map<String, Object>> deduplicatedDataList = clusterScatterPlotDTO.getDeduplicatedDataList();
if(k>deduplicatedDataList.size()){
return new ResultEntity(HttpStatus.ACCEPTED,"簇数K值不能大于数据条数");
}
List<String> strings = convertToDelimitedStringList(deduplicatedDataList);
//初始化数据
@ -171,10 +176,10 @@ public class StuDigitalMarketingModelController {
ArrayList<ArrayList<Float>> centerList = randomList(k, arrayLists);
//开始迭代
ArrayList<ArrayList<ArrayList<Float>>> kmeans = kmeans(k, t, centerList);
KmeansDTO kmeansDTO = kmeans(k, t, centerList);
return new ResultEntity(HttpStatus.OK,kmeans);
return new ResultEntity(HttpStatus.OK,kmeansDTO);
}

@ -0,0 +1,17 @@
package com.sztzjy.marketing.entity.dto;
import lombok.Data;
import java.util.ArrayList;
/**
* @author tz
* @date 2024/8/28 9:09
*/
@Data
public class KmeansDTO {
private ArrayList<ArrayList<ArrayList<Float>>> clusters;
private Integer iterations;
}

@ -158,9 +158,9 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
// 创建词汇表
Map<String, Integer> wordCount = new HashMap<>();
// 读取停用词
Set<String> stopwords = this.loadStopwords("/usr/local/tianzeProject/digitalMarketing/jarAndDockerFile/停用词.txt");
// Set<String> stopwords = this.loadStopwords("/usr/local/tianzeProject/digitalMarketing/jarAndDockerFile/停用词.txt");
// Set<String> stopwords = this.loadStopwords("D:\\project\\digital_marketing\\src\\main\\resources\\停用词.txt");
Set<String> stopwords = this.loadStopwords("D:\\project\\digital_marketing\\src\\main\\resources\\words\\停用词.txt");
// 统计词频
int count = 0;
@ -329,8 +329,6 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
// list=indicatorsMapper.getYHXFNLB();
if(algorithmName.equals("关联规则挖掘")){
list.add("consumer_goods");
} else {
list.add("id");
}
}
@ -393,7 +391,7 @@ public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingM
table="stu_user_shopping_cart";
}
else if(analyzeDataDTO.getTableName().equals(Constant.YHPLB)){ //查询用户评论
else if(analyzeDataDTO.getTableName().equals(Constant.YHPLB)){ //查询用户商品评论数据
table="stu_user_comment";
}else {

@ -268,6 +268,10 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin
}
}
if(count>100){
count=100;
}
this.HashTrainingFractionalStatistics(userId, count, info);
}
}
@ -611,6 +615,9 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin
}
if(stuScoreDetails.getLearningProjects().equals(Constant.SYBG_TCHMODULE)){
if(stuScoreDetails.getScoreProject()==null){
stuScoreDetails.setScoreProject(0.0);
}
BigDecimal mul = bigDecimalUtils.mul(stuScoreDetails.getScoreProject().toString(), tchModuleWeight.getReportWeight().toString());
stuUser.setTestReportSocre(mul);
}

@ -1,5 +1,6 @@
package com.sztzjy.marketing.util.algorithm;
import com.sztzjy.marketing.entity.dto.KmeansDTO;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
@ -167,7 +168,7 @@ public class KMeansResult {
}
//最终聚类结果
public static ArrayList<ArrayList<ArrayList<Float>>> kmeans(int k,Integer t,ArrayList<ArrayList<Float>> centroids) {
public static KmeansDTO kmeans(int k, Integer t, ArrayList<ArrayList<Float>> centroids) {
ArrayList<ArrayList<ArrayList<Float>>> clusters = new ArrayList<>(k);
for (int i = 0; i < k; i++) {
clusters.add(new ArrayList<>());
@ -205,7 +206,11 @@ public class KMeansResult {
// for (int i = 0; i < k; i++) {
// System.out.println("簇 " + i + ": " + clusters.get(i));
// }
return clusters;
KmeansDTO kmeansDTO=new KmeansDTO();
kmeansDTO.setClusters(clusters);
kmeansDTO.setIterations(iterations);
return kmeansDTO;
}
//计算一个簇的质心

@ -227,7 +227,7 @@
<foreach collection="fieldList" item="field" separator=",">
${field}
</foreach>
FROM ${table} where user_id=#{userId} and module=#{tableName} limit 0,1000
FROM ${table} where user_id=#{userId} and module=#{tableName} limit 0,100
</select>

Loading…
Cancel
Save