whb 8 months ago
commit fb19497842

@ -56,6 +56,67 @@
<version>2.0.27</version>
</dependency>
<!-- Commons Math 来计算各种统计量-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
</dependency>
<!-- 词频分析-->
<dependency>
<groupId>com.hankcs.hanlp.restful</groupId>
<artifactId>hanlp-restful</artifactId>
<version>0.0.12</version>
</dependency>
<!-- Apriori算法-->
<!-- <dependency>-->
<!-- <groupId>org.paukov</groupId>-->
<!-- <artifactId>combinatoricsLib</artifactId>-->
<!-- <version>1.0</version>-->
<!-- </dependency>-->
<!-- logistic逻辑回归算法-->
<!-- 用于矩阵运算 -->
<dependency>
<groupId>org.ujmp</groupId>
<artifactId>ujmp-core</artifactId>
<version>0.3.0</version>
</dependency>
<!-- 用于显示散点图-->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.hankcs</groupId>
<artifactId>hanlp</artifactId>
<version>portable-1.8.0</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.0</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>

@ -38,6 +38,21 @@ public class Constant {
public static final String COMMENT_EXTRACTION = "评论观点抽取";
public static final String EMOTIONAL_TENDENCIES = "情感倾向分析";
public static final String WORD_FREQUENCY = "词频分析";
public static final String WORD_CLOUD = "词云分析";
public static final String YHSXB = "用户属性表";
public static final String YHDLHYB = "用户登录活跃表";
public static final String YHXFNLB = "用户消费能力表";
public static final String YHXWB = "用户行为表";
public static final String YHPLB = "用户评论表";

@ -28,7 +28,7 @@ import java.util.UUID;
* @author tz
* @date 2024/6/12 10:48
*/
@Api(tags = "大数据")
@Api(tags = "大数据、人工智能实训任务")
@RequestMapping("api/bigData")
@RestController
public class BigDataController {

@ -0,0 +1,181 @@
package com.sztzjy.marketing.controller;
import com.sztzjy.marketing.annotation.AnonymousAccess;
import com.sztzjy.marketing.config.exception.handler.DigitalEconomyxception;
import com.sztzjy.marketing.entity.StuTrainingOperateStepExample;
import com.sztzjy.marketing.entity.StuTrainingOperateStepWithBLOBs;
import com.sztzjy.marketing.entity.dto.AssociationRulesDTO;
import com.sztzjy.marketing.entity.dto.ClusterAnalysisDTO;
import com.sztzjy.marketing.entity.dto.StatisticsDTO;
import com.sztzjy.marketing.service.StuDigitalMarketingModelService;
import com.sztzjy.marketing.util.ResultEntity;
import com.sztzjy.marketing.util.algorithm.Apriori;
import com.sztzjy.marketing.util.algorithm.KMeans;
import com.sztzjy.marketing.util.algorithm.LinearRegression;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import static com.sztzjy.marketing.util.algorithm.KMeans.readIrisData;
/**
* @author tz
* @date 2024/6/13 10:43
*/
@Api(tags = "数字营销模型")
@RequestMapping("api/model")
@RestController
public class StuDigitalMarketingModelController {
@Value("${file.path}")
private String filePath;
@Resource
StuDigitalMarketingModelService modelService;
@ApiOperation("选择指标--下拉框")
@PostMapping("/dropdownBox")
@AnonymousAccess
public ResultEntity dropdownBox(String userId) {
List<String> list=modelService.dropdownBox(userId);
return new ResultEntity(HttpStatus.OK,"成功",list);
}
@ApiOperation("选择指标--查看指标")
@PostMapping("/viewMetrics")
@AnonymousAccess
public ResultEntity viewMetrics(@ApiParam("用户ID") String userId,
@ApiParam("表格名") String tableName) {
List<String> list=modelService.viewMetrics(userId,tableName);
return new ResultEntity(HttpStatus.OK,"成功",list);
}
@ApiOperation("选择指标--分析数据展示")
@PostMapping("/viewAnalyzeData")
@AnonymousAccess
public ResultEntity viewAnalyzeData(@ApiParam("用户ID") String userId,
@ApiParam("表格名") String tableName,
@ApiParam("指标列表") @RequestParam List<String> fieldList) {
return modelService.viewAnalyzeData(userId,tableName,fieldList);
}
@ApiOperation("描述性统计")
@PostMapping("/descriptiveStatistics")
@AnonymousAccess
public ResultEntity descriptiveStatistics(@ApiParam("数据集、需要计算的方式、用户ID")@RequestBody StatisticsDTO statisticsDTO) {
Map<String, List<Double>> map = statisticsDTO.getMap();
List<String> statistic = statisticsDTO.getStatistic();
String userId = statisticsDTO.getUserId();
return modelService.descriptiveStatistics(map,statistic,userId);
}
@ApiOperation("聚类分析")
@PostMapping("/clusterAnalysis")
@AnonymousAccess
public ResultEntity clusterAnalysis(@ApiParam("簇数") Integer k,
@ApiParam("最大迭代次数") Integer t,
@ApiParam("最大迭代次数") String userId,
@RequestParam(required = false) @RequestPart MultipartFile file) {
// //验证文件类型
// if (!file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(".xls") && !file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(".xlsx")) {
// return new ResultEntity(HttpStatus.ACCEPTED, "文件类型有误请上传Excel文件");
// }
List<KMeans.Point> irisData = readIrisData(file);
//获取数据集
KMeans kMeans = new KMeans(k, t, irisData);
List<List<KMeans.Point>> clusters = kMeans.cluster();
//封装成map
//数据集
Map<Integer,List<KMeans.Point>> dataSetMap=new HashMap<>();
for (int i = 0; i < clusters.size(); i++) {
dataSetMap.put(i,clusters.get(i));
}
//质心
Map<Integer,List<KMeans.Point>> centroidMap=new HashMap<>();
List<KMeans.Point> centroids = kMeans.getCentroids();
for (int i = 0; i < centroids.size(); i++) {
centroidMap.put(i, Collections.singletonList(centroids.get(i)));
}
ClusterAnalysisDTO clusterAnalysisDTO=new ClusterAnalysisDTO();
clusterAnalysisDTO.setDataSet(dataSetMap);
clusterAnalysisDTO.setCentroid(centroidMap);
return new ResultEntity(HttpStatus.OK,clusterAnalysisDTO);
}
@ApiOperation("关联规则挖掘")
@PostMapping("/apriori")
@AnonymousAccess
public ResultEntity apriori(@ApiParam("最小支持度阀值") double support,
@ApiParam("最小置信度") double confidence,
@ApiParam("用户ID") String userId,
@RequestParam(required = false) @RequestPart MultipartFile file) {
//初始化事务数据库、项目集、候选集再进行剪枝
Apriori.init(file,support);
//迭代求出最终的候选频繁集
Apriori.iteration(Apriori.C,Apriori.L,support);
//根据最终的关联集,根据公式计算出各个关联事件
List<AssociationRulesDTO> connection = Apriori.connection(confidence);
return new ResultEntity(HttpStatus.OK,"成功",connection);
}
@ApiOperation("回归分析")
@PostMapping("/regressionAnalysis")
@AnonymousAccess
public ResultEntity regressionAnalysis(@ApiParam("自变量X") double[] x,
@ApiParam("因变量Y") double[] y,
@ApiParam("用户ID") String userId) {
// 创建线性回归模型
LinearRegression regression=new LinearRegression();
regression.fit(x,y);
return new ResultEntity(HttpStatus.OK,"成功",regression);
}
@ApiOperation("情感分析/文本挖掘")
@PostMapping("/emotionalAnalysis")
@AnonymousAccess
public ResultEntity emotionalAnalysis(@ApiParam("用户ID") String userId,
@ApiParam("模型类别") String modelType,
@ApiParam("输入内容") String content) throws IOException {
return modelService.emotionalAnalysis(userId,modelType,content);
}
}

@ -0,0 +1,81 @@
package com.sztzjy.marketing.controller;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.restful.HanLPClient;
import com.hankcs.hanlp.seg.common.Term;
import com.sztzjy.marketing.util.algorithm.LogisticRegression;
import com.sztzjy.marketing.util.algorithm.TrainDataSet;
import okhttp3.*;
import java.io.IOException;
import java.util.*;
/**
* @author tz
* @date 2024/6/17 17:38
*/
public class Test {
// static final String content="服务态度很好,环境也不错,就是点歌系统不太好用。";
//
// static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
//
// public static void main(String []args) throws IOException {
// MediaType mediaType = MediaType.parse("application/json");
// RequestBody body = RequestBody.create(mediaType, "{\"text\":\""+content+"\"}");
// Request request = new Request.Builder()
// .url("https://aip.baidubce.com/rpc/2.0/nlp/v2/comment_tag?access_token=24.88968c130db3ca9f266907b5004bec8f.2592000.1721270821.282335-83957582&charset=UTF-8")
// .method("POST", body)
// .addHeader("Content-Type", "application/json")
// .addHeader("Accept", "application/json")
// .build();
// Response response = HTTP_CLIENT.newCall(request).execute();
// System.out.println(response.body().string());
//
// }
// public static void main(String[] args) throws IOException {
//
//
//// HanLPClient HanLP = new HanLPClient("https://www.hanlp.com/hanlp/v21/redirect", "66713f44eaf65b7b456a5dec","zh",20); // auth不填则匿名zh中文mul多语种
//
//
// // 初始化文本
// String text = "据DigiTimes报道在上海疫情趋缓防疫管控开始放松后苹果供应商广达正在逐步恢复其中国工厂的MacBook产品生产。\n" +
// " 据供应链消息人士称生产厂的订单拉动情况正在慢慢转强这会提高MacBook Pro机型的供应量并缩短苹果客户在过去几周所经历的延长交货时间。\n" +
// " 仍有许多苹果笔记本用户在等待3月和4月订购的MacBook Pro机型到货由于苹果的供应问题他们的发货时间被大大推迟了。\n" +
// " 据分析师郭明錤表示广达是高端MacBook Pro的唯一供应商自防疫封控依赖MacBook Pro大部分型号交货时间增加了三到五周\n" +
// " 一些高端定制型号的MacBook Pro配置要到6月底到7月初才能交货";
// // 使用 HanLP 分词
// List<Term> terms = HanLP.segment(text);
// // 创建词汇表
// Map<String, Integer> wordCount = new HashMap<>();
// // 统计词频
//
// // 创建计数器
// int count = 0;
// for (Term term : terms) {
// String word = term.word.trim(); // 去除空格
// if(!word.isEmpty()){
// count++;
// if (wordCount.containsKey(word)) {
// wordCount.put(word, wordCount.get(word) + 1);
// } else {
// wordCount.put(word, 1);
// }
// }
// if (count >= 200) { // 达到200个关键词时结束统计
// break;
// }
// }
// // 将词汇表转换为列表,便于排序
// List<Map.Entry<String, Integer>> wordList = new ArrayList<>(wordCount.entrySet());
// // 按词频排序
// wordList.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
// // 输出结果
// for (Map.Entry<String, Integer> entry : wordList) {
// System.out.println(entry.getKey() + ": " + entry.getValue());
// }
// }
}

@ -0,0 +1,66 @@
package com.sztzjy.marketing.entity;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
/**
*
* @author whb
* stu_table_name
*/
public class StuTableName {
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("用户ID")
private String userId;
@ApiModelProperty("表格名")
private String tableName;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName == null ? null : tableName.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

@ -0,0 +1,520 @@
package com.sztzjy.marketing.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class StuTableNameExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public StuTableNameExample() {
oredCriteria = new ArrayList<>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andUserIdEqualTo(String value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(String value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(String value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(String value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(String value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(String value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLike(String value) {
addCriterion("user_id like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotLike(String value) {
addCriterion("user_id not like", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<String> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<String> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdBetween(String value1, String value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(String value1, String value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andTableNameIsNull() {
addCriterion("table_name is null");
return (Criteria) this;
}
public Criteria andTableNameIsNotNull() {
addCriterion("table_name is not null");
return (Criteria) this;
}
public Criteria andTableNameEqualTo(String value) {
addCriterion("table_name =", value, "tableName");
return (Criteria) this;
}
public Criteria andTableNameNotEqualTo(String value) {
addCriterion("table_name <>", value, "tableName");
return (Criteria) this;
}
public Criteria andTableNameGreaterThan(String value) {
addCriterion("table_name >", value, "tableName");
return (Criteria) this;
}
public Criteria andTableNameGreaterThanOrEqualTo(String value) {
addCriterion("table_name >=", value, "tableName");
return (Criteria) this;
}
public Criteria andTableNameLessThan(String value) {
addCriterion("table_name <", value, "tableName");
return (Criteria) this;
}
public Criteria andTableNameLessThanOrEqualTo(String value) {
addCriterion("table_name <=", value, "tableName");
return (Criteria) this;
}
public Criteria andTableNameLike(String value) {
addCriterion("table_name like", value, "tableName");
return (Criteria) this;
}
public Criteria andTableNameNotLike(String value) {
addCriterion("table_name not like", value, "tableName");
return (Criteria) this;
}
public Criteria andTableNameIn(List<String> values) {
addCriterion("table_name in", values, "tableName");
return (Criteria) this;
}
public Criteria andTableNameNotIn(List<String> values) {
addCriterion("table_name not in", values, "tableName");
return (Criteria) this;
}
public Criteria andTableNameBetween(String value1, String value2) {
addCriterion("table_name between", value1, value2, "tableName");
return (Criteria) this;
}
public Criteria andTableNameNotBetween(String value1, String value2) {
addCriterion("table_name not between", value1, value2, "tableName");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

@ -0,0 +1,188 @@
package com.sztzjy.marketing.entity;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
/**
*
*
* @author whb
* stu_user_behavior
*/
public class StuUserBehavior {
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("用户ID")
private String userId;
@ApiModelProperty("登录名")
private String loginName;
@ApiModelProperty("用户名")
private String userName;
@ApiModelProperty("学号")
private String studentId;
@ApiModelProperty("班级")
private String stuClass;
@ApiModelProperty("专业")
private String major;
@ApiModelProperty("学校")
private String school;
@ApiModelProperty("角色名称")
private String roleName;
@ApiModelProperty("商品名字")
private String goodsName;
@ApiModelProperty("商品类型")
private String goodsType;
@ApiModelProperty("商品小类")
private String goodsSubcategories;
@ApiModelProperty("用户行为类型")
private String userBehaviorType;
@ApiModelProperty("行为日期")
private Date behaviorDate;
@ApiModelProperty("创建时间(注册时间)")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName == null ? null : loginName.trim();
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName == null ? null : userName.trim();
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId == null ? null : studentId.trim();
}
public String getStuClass() {
return stuClass;
}
public void setStuClass(String stuClass) {
this.stuClass = stuClass == null ? null : stuClass.trim();
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major == null ? null : major.trim();
}
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school == null ? null : school.trim();
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName == null ? null : roleName.trim();
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName == null ? null : goodsName.trim();
}
public String getGoodsType() {
return goodsType;
}
public void setGoodsType(String goodsType) {
this.goodsType = goodsType == null ? null : goodsType.trim();
}
public String getGoodsSubcategories() {
return goodsSubcategories;
}
public void setGoodsSubcategories(String goodsSubcategories) {
this.goodsSubcategories = goodsSubcategories == null ? null : goodsSubcategories.trim();
}
public String getUserBehaviorType() {
return userBehaviorType;
}
public void setUserBehaviorType(String userBehaviorType) {
this.userBehaviorType = userBehaviorType == null ? null : userBehaviorType.trim();
}
public Date getBehaviorDate() {
return behaviorDate;
}
public void setBehaviorDate(Date behaviorDate) {
this.behaviorDate = behaviorDate;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

@ -0,0 +1,22 @@
package com.sztzjy.marketing.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author tz
* @date 2024/6/20 8:51
*/
@Data
public class AssociationRulesDTO {
@ApiModelProperty("关联")
private List<String> correlation;
@ApiModelProperty("被关联")
private List<String> associated;
@ApiModelProperty("置信度")
private double confidenceLevel;
}

@ -0,0 +1,18 @@
package com.sztzjy.marketing.entity.dto;
import com.sztzjy.marketing.util.algorithm.KMeans;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author tz
* @date 2024/6/14 10:12
*/
@Data
public class ClusterAnalysisDTO {
private Map<Integer, List<KMeans.Point>> dataSet;
private Map<Integer,List<KMeans.Point>> centroid;
}

@ -0,0 +1,49 @@
package com.sztzjy.marketing.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author tz
* @date 2024/6/21 9:51
*/
@Data
public class DescriptiveStatistics {
@ApiModelProperty("平均数")
private double average;
@ApiModelProperty("中位数")
private double median;
@ApiModelProperty("众数")
private List<Double> mode;
@ApiModelProperty("标准差")
private double standardDeviation;
@ApiModelProperty("方差")
private double variance;
@ApiModelProperty("标准误差")
private double standardError;
@ApiModelProperty("峰度")
private double kurtosis;
@ApiModelProperty("偏度")
private double skewness;
@ApiModelProperty("最大值")
private double max;
@ApiModelProperty("最小值")
private double min;
@ApiModelProperty("求和")
private double summation;
@ApiModelProperty("观测数")
private Integer observations;
}

@ -0,0 +1,14 @@
package com.sztzjy.marketing.entity.dto;
import lombok.Data;
/**
* @author tz
* @date 2024/6/21 10:00
*/
@Data
public class DescriptiveStatisticsDTO {
private String field;
private DescriptiveStatistics statistics;
}

@ -0,0 +1,17 @@
package com.sztzjy.marketing.entity.dto;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author tz
* @date 2024/6/21 10:57
*/
@Data
public class StatisticsDTO {
private Map<String, List<Double>> map;
private List<String> statistic;
private String userId;
}

@ -0,0 +1,14 @@
package com.sztzjy.marketing.entity.dto;
import lombok.Data;
/**
* @author tz
* @date 2024/6/18 16:48
*/
@Data
public class WordFrequencyDTO {
private String keyword;
private Integer frequency;
}

@ -0,0 +1,31 @@
package com.sztzjy.marketing.mapper;
import com.sztzjy.marketing.entity.StuUserAttribute;
import com.sztzjy.marketing.entity.StuUserBehavior;
import com.sztzjy.marketing.entity.StuUserConsumptionAbility;
import com.sztzjy.marketing.entity.StuUserLoginActive;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;/**
* @author tz
* @date 2024/6/21 13:50
*/
@Mapper
public interface StuSelectIndicatorsMapper {
@Select("select COLUMN_NAME from information_schema.COLUMNS where table_name = 'stu_user_login_active'")
List<String> getYHDLHYB();
@Select("select COLUMN_NAME from information_schema.COLUMNS where table_name = 'stu_user_consumption_ability'")
List<String> getYHXFNLB();
@Select("select COLUMN_NAME from information_schema.COLUMNS where table_name = 'stu_user_behavior'")
List<String> getYHPLB();
@Select("select COLUMN_NAME from information_schema.COLUMNS where table_name = 'stu_user_attribute'")
List<String> getYHSXB();
}

@ -0,0 +1,37 @@
package com.sztzjy.marketing.mapper;
import com.sztzjy.marketing.entity.*;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface StuTableNameMapper {
long countByExample(StuTableNameExample example);
int deleteByExample(StuTableNameExample example);
int deleteByPrimaryKey(Integer id);
int insert(StuTableName record);
int insertSelective(StuTableName record);
List<StuTableName> selectByExample(StuTableNameExample example);
StuTableName selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") StuTableName record, @Param("example") StuTableNameExample example);
int updateByExample(@Param("record") StuTableName record, @Param("example") StuTableNameExample example);
int updateByPrimaryKeySelective(StuTableName record);
int updateByPrimaryKey(StuTableName record);
List<String> getTableName(String userId);
List<Map<String,Object>> selectByFields(List<String> fieldList, String table);
}

@ -0,0 +1,32 @@
package com.sztzjy.marketing.mapper;
import com.sztzjy.marketing.entity.StuUserBehavior;
import com.sztzjy.marketing.entity.StuUserBehaviorExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface StuUserBehaviorMapper {
long countByExample(StuUserBehaviorExample example);
int deleteByExample(StuUserBehaviorExample example);
int deleteByPrimaryKey(Integer id);
int insert(StuUserBehavior record);
int insertSelective(StuUserBehavior record);
List<StuUserBehavior> selectByExample(StuUserBehaviorExample example);
StuUserBehavior selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") StuUserBehavior record, @Param("example") StuUserBehaviorExample example);
int updateByExample(@Param("record") StuUserBehavior record, @Param("example") StuUserBehaviorExample example);
int updateByPrimaryKeySelective(StuUserBehavior record);
int updateByPrimaryKey(StuUserBehavior record);
}

@ -0,0 +1,25 @@
package com.sztzjy.marketing.service;
import com.sztzjy.marketing.util.ResultEntity;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author tz
* @date 2024/6/14 11:05
*/
public interface StuDigitalMarketingModelService {
List<String> dropdownBox(String userId);
ResultEntity emotionalAnalysis(String userId, String modelType, String content) throws IOException;
ResultEntity descriptiveStatistics(Map<String, List<Double>> map, List<String> statistic, String userId);
List<String> viewMetrics(String userId, String tableName);
ResultEntity viewAnalyzeData(String userId, String tableName, List<String> fieldList);
}

@ -0,0 +1,288 @@
package com.sztzjy.marketing.service.impl;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.seg.common.Term;
import com.sztzjy.marketing.config.Constant;
import com.sztzjy.marketing.entity.*;
import com.sztzjy.marketing.entity.dto.DescriptiveStatistics;
import com.sztzjy.marketing.entity.dto.DescriptiveStatisticsDTO;
import com.sztzjy.marketing.entity.dto.WordFrequencyDTO;
import com.sztzjy.marketing.mapper.StuSelectIndicatorsMapper;
import com.sztzjy.marketing.mapper.StuTableNameMapper;
import com.sztzjy.marketing.service.StuDigitalMarketingModelService;
import com.sztzjy.marketing.util.ResultEntity;
import com.sztzjy.marketing.util.algorithm.DescriptiveStatisticsUtil;
import okhttp3.*;
import org.checkerframework.checker.units.qual.C;
import org.geolatte.geom.M;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
/**
* @author tz
* @date 2024/6/14 11:05
*/
@Service
public class StuDigitalMarketingModelServiceImpl implements StuDigitalMarketingModelService {
private final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
@Resource
StuTableNameMapper stuTableNameMapper;
@Resource
StuSelectIndicatorsMapper indicatorsMapper;
@Resource
StuTableNameMapper tableNameMapper;
@Override
public List<String> dropdownBox(String userId) {
List<String> list=stuTableNameMapper.getTableName(userId);
if(list.isEmpty()){ //设置默认值
String[] arr={"用户属性表","用户登录活跃表","用户消费能力表","用户行为表","用户评论表"};
StuTableName stuTableName=new StuTableName();
for (int i = 0; i < arr.length; i++) {
Integer uuid = UUID.randomUUID().toString().replaceAll("-", "").hashCode();
uuid = uuid < 0 ? -uuid : uuid;//String.hashCode() 值会为空
stuTableName.setId(uuid);
stuTableName.setTableName(arr[i]);
stuTableName.setUserId(userId);
stuTableName.setCreateTime(new Date());
stuTableNameMapper.insert(stuTableName);
list.add(arr[i]);
}
}
return list;
}
@Override
public ResultEntity emotionalAnalysis(String userId, String modelType, String content) throws IOException {
String commentUrl = "https://aip.baidubce.com/rpc/2.0/nlp/v2/comment_tag?access_token=24.88968c130db3ca9f266907b5004bec8f.2592000.1721270821.282335-83957582&charset=UTF-8";
String emoUrl="https://aip.baidubce.com/rpc/2.0/nlp/v1/sentiment_classify?access_token=24.88968c130db3ca9f266907b5004bec8f.2592000.1721270821.282335-83957582";
MediaType mediaType = MediaType.parse("application/json");
if(modelType.equals(Constant.COMMENT_EXTRACTION)){ //评论观点抽取
RequestBody body = RequestBody.create(mediaType, "{\"text\":\""+content+"\",\"type\":8}");
Request request = new Request.Builder()
.url(commentUrl)
.method("POST", body)
.build();
Response response = HTTP_CLIENT.newCall(request).execute();
if (response.body() != null) {
return new ResultEntity(HttpStatus.OK,"成功",response.body().string());
}
}
if(modelType.equals(Constant.EMOTIONAL_TENDENCIES)){ //情感倾向分析
RequestBody body = RequestBody.create(mediaType, "{\"text\":\""+content+"\"}");
Request request = new Request.Builder()
.url(emoUrl)
.method("POST", body)
.build();
Response response = HTTP_CLIENT.newCall(request).execute();
if (response.body() != null) {
return new ResultEntity(HttpStatus.OK,"成功",response.body().string());
}
}
if(modelType.equals(Constant.WORD_FREQUENCY)){ //词频分析
// 使用 HanLP 分词
List<Term> terms = HanLP.segment(content);
// 创建词汇表
Map<String, Integer> wordCount = new HashMap<>();
// 统计词频
// 创建计数器
int count = 0;
for (Term term : terms) {
String word = term.word.trim(); // 去除空格
if(!word.isEmpty()){
count++;
if (wordCount.containsKey(word)) {
wordCount.put(word, wordCount.get(word) + 1);
} else {
wordCount.put(word, 1);
}
}
if (count >= 200) { // 达到200个关键词时结束统计
break;
}
}
// 将词汇表转换为列表,便于排序
List<Map.Entry<String, Integer>> wordList = new ArrayList<>(wordCount.entrySet());
// 按词频排序
wordList.sort((o1, o2) -> o2.getValue().compareTo(o1.getValue()));
List<WordFrequencyDTO> list=new ArrayList<>();
for (Map.Entry<String, Integer> entry : wordList) {
WordFrequencyDTO frequencyDTO=new WordFrequencyDTO();
frequencyDTO.setKeyword(entry.getKey());
frequencyDTO.setFrequency(entry.getValue());
list.add(frequencyDTO);
}
return new ResultEntity<>(HttpStatus.OK,"成功",list);
}
// if(modelType.equals(Constant.WORD_CLOUD)){ //词云分析
//
// }
return null;
}
@Override
public ResultEntity descriptiveStatistics(Map<String, List<Double>> map, List<String> statistic, String userId) {
DescriptiveStatisticsUtil statisticsUtil=new DescriptiveStatisticsUtil();
List<DescriptiveStatisticsDTO> dtoList=new ArrayList<>();
for(String key: map.keySet()){
DescriptiveStatisticsDTO statisticsDTO=new DescriptiveStatisticsDTO();
statisticsDTO.setField(key);
DescriptiveStatistics statistics=new DescriptiveStatistics();
for (int i = 0; i < statistic.size(); i++) {
if(statistic.get(i).equals("平均数")){
double mean = statisticsUtil.getMean(map.get(key));
statistics.setAverage(mean);
}
if(statistic.get(i).equals("中位数")){
double median = statisticsUtil.getMedian(map.get(key));
statistics.setMedian(median);
}
if(statistic.get(i).equals("众数")){
List<Double> mode = statisticsUtil.getMode(map.get(key));
statistics.setMode(mode);
}
if(statistic.get(i).equals("标准差")){
double standardDeviation = statisticsUtil.getStandardDeviation(map.get(key));
statistics.setStandardDeviation(standardDeviation);
}
if(statistic.get(i).equals("方差")){
double variance = statisticsUtil.getVariance(map.get(key));
statistics.setVariance(variance);
}
if(statistic.get(i).equals("标准误差")){
double standardError = statisticsUtil.getStandardError(map.get(key));
statistics.setStandardError(standardError);
}
if(statistic.get(i).equals("峰度")){
double kurtosis = statisticsUtil.getKurtosis(map.get(key));
statistics.setKurtosis(kurtosis);
}
if(statistic.get(i).equals("偏度")){
double skewness = statisticsUtil.getSkewness(map.get(key));
statistics.setSkewness(skewness);
}
if(statistic.get(i).equals("最大值")){
double max = statisticsUtil.getMax(map.get(key));
statistics.setMax(max);
}
if(statistic.get(i).equals("最小值")){
double min = statisticsUtil.getMin(map.get(key));
statistics.setMin(min);
}
if(statistic.get(i).equals("求和")){
double sum = statisticsUtil.getSum(map.get(key));
statistics.setSummation(sum);
}
if(statistic.get(i).equals("观测数")){
int count = statisticsUtil.getCount(map.get(key));
statistics.setObservations(count);
}
}
statisticsDTO.setStatistics(statistics);
dtoList.add(statisticsDTO);
}
return new ResultEntity(HttpStatus.OK,"成功",dtoList);
}
@Override
public List<String> viewMetrics(String userId, String tableName) {
List<String> list=new ArrayList<>();
if(tableName.equals(Constant.YHSXB)){
list=indicatorsMapper.getYHSXB();
}
if(tableName.equals(Constant.YHDLHYB)){
list=indicatorsMapper.getYHDLHYB();
}
if(tableName.equals(Constant.YHXFNLB)){
list=indicatorsMapper.getYHXFNLB();
}
if(tableName.equals(Constant.YHPLB) || tableName.equals(Constant.YHXWB)){
list=indicatorsMapper.getYHPLB();
}
return list;
}
@Override
public ResultEntity viewAnalyzeData(String userId, String tableName, List<String> fieldList) {
String table=null;
if(tableName.equals(Constant.YHSXB)){ //查询用户属性表
table="stu_user_attribute";
}
if(tableName.equals(Constant.YHDLHYB)){ //查询用户登录活跃表
table="stu_user_login_active";
}
if(tableName.equals(Constant.YHXFNLB)){ //查询用户消费能力表
table="stu_user_consumption_ability";
}
if(tableName.equals(Constant.YHPLB) || tableName.equals(Constant.YHXWB)){ //查询用户评论或行为表
table="stu_user_behavior";
}
List<Map<String,Object>> attributes = tableNameMapper.selectByFields(fieldList,table);
// List<Object> createTime = attributes.get("create_time");
return new ResultEntity(HttpStatus.OK,attributes);
}
}

@ -0,0 +1,253 @@
package com.sztzjy.marketing.util.algorithm;
import com.sztzjy.marketing.entity.dto.AssociationRulesDTO;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Apriori {
// private double min_support; //最小支持度
// private double min_confident; //最小置信度
//文件路径
// static String filePath = "D:\\home\\marketing\\1.txt";
static ArrayList<ArrayList<String>> D = new ArrayList<ArrayList<String>>();//事务数据库D
public static HashMap<ArrayList<String>, Integer> C = new HashMap<ArrayList<String>, Integer>();//项目集C
public static HashMap<ArrayList<String>, Integer> L = new HashMap<ArrayList<String>, Integer>();//候选集L
// 用于存取候选集每次计算结果即存放所有的频繁项集L最后计算关联规则就不用再次遍历事务数据库。
static HashMap<ArrayList<String>, Integer> L_ALL = new HashMap<ArrayList<String>, Integer>();
//从文件中读取内容,返回事务集
public static ArrayList<ArrayList<String>> readTable(MultipartFile file){
ArrayList<ArrayList<String>> t = new ArrayList<ArrayList<String>>();
ArrayList<String> t1 = null;
try {
InputStreamReader isr = new InputStreamReader(file.getInputStream());
BufferedReader bf = new BufferedReader(isr);
String str = null;
while((str = bf.readLine()) != null) {
t1 = new ArrayList<String>();
String[] str1 = str.split(",");
for(int i = 1; i < str1.length ; i++) {
t1.add(str1[i]);
}
t.add(t1);
}
bf.close();
isr.close();
} catch (Exception e) {
e.printStackTrace();
System.out.println("文件读取失败!");
}
System.out.println("\nD:"+t);
return t;
}
//剪枝步从候选集C中删除小于最小支持度的并放入频繁集L中
public static void pruning(HashMap<ArrayList<String>, Integer> C,HashMap<ArrayList<String>, Integer> L,double min_support) {
L.clear();
// 根据项目集生成候选集
L.putAll(C);
// 删除少于最小支持度的元素
ArrayList<ArrayList<String>> delete_key = new ArrayList<ArrayList<String>>();
for (ArrayList<String> key : L.keySet()) {
if (L.get(key) < min_support) {
delete_key.add(key);
}
}
for (int i = 0; i < delete_key.size(); i++) {
L.remove(delete_key.get(i));
}
}
/**
*
*/
public static void init(MultipartFile file,double min_support) {
// //将文件中的数据放入集合D中
D = readTable(file);
// 扫描事务数据库。生成项目集,支持度=该元素在事务数据库出现的次数/事务数据库的事务数
for (int i = 0; i < D.size(); i++) {
for (int j = 0; j < D.get(i).size(); j++) {
String[] e = { D.get(i).get(j) };
//将数组e转化为List
ArrayList<String> item = new ArrayList<String>(Arrays.asList(e));
//map中是否包含指定的键
if (!C.containsKey(item)) {
C.put(item, 1);
//System.out.println(C.get(item));
} else {
C.put(item, C.get(item) + 1);
//System.out.println(C.get(item));
}
}
}
//System.out.println("D.size= "+D.size());
pruning(C, L,min_support);// 剪枝
//将频繁项集放入集合中
L_ALL.clear();
L_ALL.putAll(L);
}
// 两个整数集求并集
public static ArrayList<String> arrayListUnion(ArrayList<String> arraylist1, ArrayList<String> arraylist2) {
ArrayList<String> arraylist = new ArrayList<String>();
arraylist.addAll(arraylist1);
arraylist.addAll(arraylist2);
//将ArrayList转化为HashSet去掉重复元素再将HashSet转换为ArrayList
arraylist = new ArrayList<String>(new HashSet<String>(arraylist));
return arraylist;
}
/**
*
*
* @param C
*
* @param L
*
* @return
*/
public static HashMap<ArrayList<String>, Integer> iteration(HashMap<ArrayList<String>, Integer> C,HashMap<ArrayList<String>, Integer> L,double min_support) {
HashMap<ArrayList<String>, Integer> L_temp = new HashMap<ArrayList<String>, Integer>();// 用于判断是否结束剪枝的临时变量
String str = null;
int t = 1;// 迭代次数
while (L.size() > 0) {// 一旦被剪枝后剪干净,剪枝之前则是最终要求的结果。
t++;
L_temp.clear();
L_temp.putAll(L);
// 一、连接步
C.clear();
// 1.将L中的项以一定的规则两两匹配
ArrayList<ArrayList<String>> L_key = new ArrayList<ArrayList<String>>(L.keySet());
for (int i = 0; i < L_key.size(); i++) {
for (int j = i + 1; j < L_key.size(); j++) {
ArrayList<String> C_item = new ArrayList<String>();
C_item = new ArrayList<String>(arrayListUnion(L_key.get(i),
L_key.get(j)));
if (C_item.size() == t) {
C.put(C_item, 0);// 频繁项集的所有非空子集都必须是频繁的
}
}
}
// 2.通过扫描D计算此项的支持度
for (ArrayList<String> key : C.keySet()) {
for (int i = 0; i < D.size(); i++) {
if (D.get(i).containsAll(key)) {
C.put(key, C.get(key) + 1 );
}
}
}
str = C.toString();
System.out.println("候选"+t+"项集C: \n"+C);
// 二、剪枝步
pruning(C, L,min_support);
System.out.println("频繁"+t+"项集L: \n"+L+"\n");
str = L.toString();
//System.out.println("===");
L_ALL.putAll(L);
}
return L_temp;
}
// 求一个集合的所有子集
public static ArrayList<ArrayList<String>> getSubset(ArrayList<String> L) {
if (L.size() > 0) {
ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
for (int i = 0; i < Math.pow(2, L.size()); i++) {// 集合子集个数=2的该集合长度的乘方
ArrayList<String> subSet = new ArrayList<String>();
int index = i;// 索引从0一直到2的集合长度的乘方-1
for (int j = 0; j < L.size(); j++) {
// 通过逐一位移判断索引那一位是1如果是再添加此项
if ((index & 1) == 1) {// 位与运算判断最后一位是否为1
subSet.add(L.get(j));
}
index >>= 1;// 索引右移一位
}
result.add(subSet); // 把子集存储起来
}
return result;
} else {
return null;
}
}
// 判断两个集合相交是否为空
public static boolean intersectionIsNull(ArrayList<String> l1,
ArrayList<String> l2) {
Set<String> s1 = new HashSet<String>(l1);
Set<String> s2 = new HashSet<String>(l2);
s1.retainAll(s2);
if (s1.size() > 0) {
return false;
} else {
return true;
}
}
/**
*
*/
public static List<AssociationRulesDTO> connection(double min_confident) {
List<AssociationRulesDTO> list=new ArrayList<>();
for (ArrayList<String> key : L_ALL.keySet()) {// 对最终的关联集各个事件进行判断
ArrayList<ArrayList<String>> key_allSubset = getSubset(key);
//得到所有频繁集中每个集合的子集
// System.out.println(key_allSubset);
for (int i = 0; i < key_allSubset.size(); i++) {
ArrayList<String> item_pre = key_allSubset.get(i);//得到一个真子集
if (0 < item_pre.size() && item_pre.size() < key.size()) {// 判断是否是非空真子集
// 各个非空互补真子集之间形成关联事件
double item_pre_support = L_ALL.get(item_pre);//得到真子集的支持度度
//System.out.println("itempre="+item_pre_support);
for (int j = 0; j < key_allSubset.size(); j++) {
ArrayList<String> item_post = key_allSubset.get(j);
if (0 < item_post.size()
&& item_post.size() < key.size()
&& arrayListUnion(item_pre, item_post).equals(key)
&& intersectionIsNull(item_pre, item_post))
//不相交的两个非空真子集,相并为频繁项集
{
double d = L_ALL.get(arrayListUnion(item_pre, item_post));
//double item_post_support = L_ALL.get(item_post);// 互补真子集的支持度比则是事件的置信度
//System.out.println("item_post="+item_post_support);
double confident = d
/ item_pre_support; // 事件的置信度
if (confident > min_confident) {// 如果事件的置信度大于最小置信度
//封装对象返回
AssociationRulesDTO associationRulesDTO=new AssociationRulesDTO();
associationRulesDTO.setCorrelation(item_pre);
associationRulesDTO.setAssociated(item_post);
associationRulesDTO.setConfidenceLevel(confident);
list.add(associationRulesDTO);
System.out.print(item_pre + "==>" + item_post );// 则是一个关联事件
System.out.println("==>" + confident);
}
}
}
}
}
}
return list;
}
public static void main(String[] args) {
// Apriori apriori = new Apriori();
// apriori.init(D);
// System.out.println("候选1项集C\n"+apriori.C);
// System.out.println("频繁1项集L\n"+apriori.L+"\n");
// apriori.L = apriori.iteration(apriori.C, apriori.L);
// System.out.println("关联规则如下:");
// apriori.connection(min_confident);
}
}

@ -0,0 +1,234 @@
package com.sztzjy.marketing.util.algorithm;
import java.util.*;
import java.io.*;
public class DataDeal {
static double min_support = 4; //最小支持度
static double min_confident = 0.7; //最小置信度
//文件路径,我的是在当前项目下,大家换成自己的文件路径就是了
static String filePath = "D:\\home\\marketing\\1.txt";
static ArrayList<ArrayList<String>> D = new ArrayList<ArrayList<String>>();//事务数据库D
static HashMap<ArrayList<String>, Integer> C = new HashMap<ArrayList<String>, Integer>();//项目集C
static HashMap<ArrayList<String>, Integer> L = new HashMap<ArrayList<String>, Integer>();//候选集L
// 用于存取候选集每次计算结果即存放所有的频繁项集L最后计算关联规则就不用再次遍历事务数据库。
static HashMap<ArrayList<String>, Integer> L_ALL = new HashMap<ArrayList<String>, Integer>();
//从文件中读取内容,返回事务集
public static ArrayList<ArrayList<String>> readTable(String filePath){
ArrayList<ArrayList<String>> t = new ArrayList<ArrayList<String>>();
ArrayList<String> t1 = null;
File file = new File(filePath);
try {
InputStreamReader isr = new InputStreamReader(new FileInputStream(file));
BufferedReader bf = new BufferedReader(isr);
String str = null;
while((str = bf.readLine()) != null) {
t1 = new ArrayList<String>();
String[] str1 = str.split(",");
for(int i = 1; i < str1.length ; i++) {
t1.add(str1[i]);
}
t.add(t1);
}
bf.close();
isr.close();
} catch (Exception e) {
e.printStackTrace();
System.out.println("文件不存在!");
}
System.out.println("\nD:"+t);
return t;
}
//剪枝步从候选集C中删除小于最小支持度的并放入频繁集L中
public static void pruning(HashMap<ArrayList<String>, Integer> C,HashMap<ArrayList<String>, Integer> L) {
L.clear();
// 根据项目集生成候选集
L.putAll(C);
// 删除少于最小支持度的元素
ArrayList<ArrayList<String>> delete_key = new ArrayList<ArrayList<String>>();
for (ArrayList<String> key : L.keySet()) {
if (L.get(key) < min_support) {
delete_key.add(key);
}
}
for (int i = 0; i < delete_key.size(); i++) {
L.remove(delete_key.get(i));
}
}
/**
*
*/
public static void init() {
//将文件中的数据放入集合D中
D = readTable(filePath);
// 扫描事务数据库。生成项目集,支持度=该元素在事务数据库出现的次数/事务数据库的事务数
for (int i = 0; i < D.size(); i++) {
for (int j = 0; j < D.get(i).size(); j++) {
String[] e = { D.get(i).get(j) };
//将数组e转化为List
ArrayList<String> item = new ArrayList<String>(Arrays.asList(e));
//map中是否包含指定的键
if (!C.containsKey(item)) {
C.put(item, 1);
//System.out.println(C.get(item));
} else {
C.put(item, C.get(item) + 1);
//System.out.println(C.get(item));
}
}
}
//System.out.println("D.size= "+D.size());
pruning(C, L);// 剪枝
//将频繁项集放入集合中
L_ALL.putAll(L);
}
// 两个整数集求并集
public static ArrayList<String> arrayListUnion(ArrayList<String> arraylist1, ArrayList<String> arraylist2) {
ArrayList<String> arraylist = new ArrayList<String>();
arraylist.addAll(arraylist1);
arraylist.addAll(arraylist2);
//将ArrayList转化为HashSet去掉重复元素再将HashSet转换为ArrayList
arraylist = new ArrayList<String>(new HashSet<String>(arraylist));
return arraylist;
}
/**
*
*
* @param C
*
* @param L
*
* @return
*/
public static HashMap<ArrayList<String>, Integer> iteration(HashMap<ArrayList<String>, Integer> C,HashMap<ArrayList<String>, Integer> L) {
HashMap<ArrayList<String>, Integer> L_temp = new HashMap<ArrayList<String>, Integer>();// 用于判断是否结束剪枝的临时变量
String str = null;
int t = 1;// 迭代次数
while (L.size() > 0) {// 一旦被剪枝后剪干净,剪枝之前则是最终要求的结果。
t++;
L_temp.clear();
L_temp.putAll(L);
// 一、连接步
C.clear();
// 1.将L中的项以一定的规则两两匹配
ArrayList<ArrayList<String>> L_key = new ArrayList<ArrayList<String>>(L.keySet());
for (int i = 0; i < L_key.size(); i++) {
for (int j = i + 1; j < L_key.size(); j++) {
ArrayList<String> C_item = new ArrayList<String>();
C_item = new ArrayList<String>(arrayListUnion(L_key.get(i),
L_key.get(j)));
if (C_item.size() == t) {
C.put(C_item, 0);// 频繁项集的所有非空子集都必须是频繁的
}
}
}
// 2.通过扫描D计算此项的支持度
for (ArrayList<String> key : C.keySet()) {
for (int i = 0; i < D.size(); i++) {
if (D.get(i).containsAll(key)) {
C.put(key, C.get(key) + 1 );
}
}
}
str = C.toString();
System.out.println("候选"+t+"项集C: \n"+C);
// 二、剪枝步
pruning(C, L);
System.out.println("频繁"+t+"项集L: \n"+L+"\n");
str = L.toString();
//System.out.println("===");
L_ALL.putAll(L);
}
return L_temp;
}
// 求一个集合的所有子集
public static ArrayList<ArrayList<String>> getSubset(ArrayList<String> L) {
if (L.size() > 0) {
ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
for (int i = 0; i < Math.pow(2, L.size()); i++) {// 集合子集个数=2的该集合长度的乘方
ArrayList<String> subSet = new ArrayList<String>();
int index = i;// 索引从0一直到2的集合长度的乘方-1
for (int j = 0; j < L.size(); j++) {
// 通过逐一位移判断索引那一位是1如果是再添加此项
if ((index & 1) == 1) {// 位与运算判断最后一位是否为1
subSet.add(L.get(j));
}
index >>= 1;// 索引右移一位
}
result.add(subSet); // 把子集存储起来
}
return result;
} else {
return null;
}
}
// 判断两个集合相交是否为空
public static boolean intersectionIsNull(ArrayList<String> l1,
ArrayList<String> l2) {
Set<String> s1 = new HashSet<String>(l1);
Set<String> s2 = new HashSet<String>(l2);
s1.retainAll(s2);
if (s1.size() > 0) {
return false;
} else {
return true;
}
}
/**
*
*/
public static void connection() {
for (ArrayList<String> key : L_ALL.keySet()) {// 对最终的关联集各个事件进行判断
ArrayList<ArrayList<String>> key_allSubset = getSubset(key);
//得到所有频繁集中每个集合的子集
// System.out.println(key_allSubset);
for (int i = 0; i < key_allSubset.size(); i++) {
ArrayList<String> item_pre = key_allSubset.get(i);//得到一个真子集
if (0 < item_pre.size() && item_pre.size() < key.size()) {// 判断是否是非空真子集
// 各个非空互补真子集之间形成关联事件
double item_pre_support = L_ALL.get(item_pre);//得到真子集的支持度度
//System.out.println("itempre="+item_pre_support);
for (int j = 0; j < key_allSubset.size(); j++) {
ArrayList<String> item_post = key_allSubset.get(j);
if (0 < item_post.size()
&& item_post.size() < key.size()
&& arrayListUnion(item_pre, item_post).equals(key)
&& intersectionIsNull(item_pre, item_post))
//不相交的两个非空真子集,相并为频繁项集
{
double d = L_ALL.get(arrayListUnion(item_pre, item_post));
//double item_post_support = L_ALL.get(item_post);// 互补真子集的支持度比则是事件的置信度
//System.out.println("item_post="+item_post_support);
double confident = d
/ item_pre_support; // 事件的置信度
if (confident > min_confident) {// 如果事件的置信度大于最小置信度
System.out.print(item_pre + "==>" + item_post );// 则是一个关联事件
System.out.println("==>" + confident);
}
}
}
}
}
}
}
public static void main(String[] args) {
DataDeal apriori = new DataDeal();
apriori.init();
System.out.println("候选1项集C\n"+apriori.C);
System.out.println("频繁1项集L\n"+apriori.L+"\n");
apriori.L = apriori.iteration(apriori.C, apriori.L);
System.out.println("关联规则如下:");
apriori.connection();
}
}

@ -0,0 +1,130 @@
package com.sztzjy.marketing.util.algorithm;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import java.util.*;
public class DescriptiveStatisticsUtil {
// 计算平均数
public double getMean(List<Double> data) {
DescriptiveStatistics stats = new DescriptiveStatistics();
for (double value : data) {
stats.addValue(value);
}
return stats.getMean();
}
// 计算中位数
public double getMedian(List<Double> data) {
Collections.sort(data);
int size = data.size();
if (size % 2 == 0) {
return (data.get(size / 2 - 1) + data.get(size / 2)) / 2.0;
} else {
return data.get(size / 2);
}
}
// 计算众数
public List<Double> getMode(List<Double> data) {
HashMap map = new HashMap();
double imode = 0;
for (int i = 0; i < data.size(); i++) {
double x = data.get(i);
if (map.containsKey(String.valueOf(x))) {
// 如果出现多次取出以前的计数然后加1
int len = Integer.parseInt(map.get(String.valueOf(x)).toString());
map.put(String.valueOf(x), String.valueOf(len + 1));
imode = Math.max(imode, len + 1);
} else {
// 如果是第一次出现计数为1
map.put(String.valueOf(x), String.valueOf(1));
imode = Math.max(imode, 1);
}
}
Iterator iter = map.keySet().iterator();
ArrayList lst = new ArrayList();
while (iter.hasNext()) {
Object key = iter.next();
Object v = map.get(key);
if (Integer.parseInt(v.toString()) == imode) {
lst.add(key);
}
}
return lst;
}
// 计算标准差
public double getStandardDeviation(List<Double> data) {
DescriptiveStatistics stats = new DescriptiveStatistics();
for (double value : data) {
stats.addValue(value);
}
return stats.getStandardDeviation();
}
// 计算方差
public double getVariance(List<Double> data) {
DescriptiveStatistics stats = new DescriptiveStatistics();
for (double value : data) {
stats.addValue(value);
}
return stats.getVariance();
}
// 计算标准误差
public double getStandardError(List<Double> data) {
double standardDeviation = getStandardDeviation(data);
int count = getCount(data);
return standardDeviation / Math.sqrt(count);
}
// 计算峰度
public double getKurtosis(List<Double> data) {
DescriptiveStatistics stats = new DescriptiveStatistics();
for (double value : data) {
stats.addValue(value);
}
return stats.getKurtosis();
}
// 计算偏度
public double getSkewness(List<Double> data) {
DescriptiveStatistics stats = new DescriptiveStatistics();
for (double value : data) {
stats.addValue(value);
}
return stats.getSkewness();
}
// 获取最大值
public double getMax(List<Double> data) {
return Collections.max(data);
}
// 获取最小值
public double getMin(List<Double> data) {
return Collections.min(data);
}
// 计算总和
public double getSum(List<Double> data) {
double sum = 0;
for (double value : data) {
sum += value;
}
return sum;
}
// 获取观测数
public int getCount(List<Double> data) {
return data.size();
}
}

@ -1,8 +1,11 @@
package com.sztzjy.marketing.util.algorithm;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -14,6 +17,7 @@ public class KMeans {
private List<Point> centroids; // 质心
private List<Point> points; // 数据集
public KMeans(int k, int maxIterations, List<Point> points) {
this.k = k;
this.maxIterations = maxIterations;
@ -21,6 +25,11 @@ public class KMeans {
this.centroids = initializeCentroids();
}
public List<Point> getCentroids() {
return centroids;
}
// 初始化质心
private List<Point> initializeCentroids() {
List<Point> centroids = new ArrayList<>();
@ -93,7 +102,7 @@ public class KMeans {
}
// 示例中的数据点类
static class Point {
public static class Point {
private double x;
private double y;
@ -124,27 +133,37 @@ public class KMeans {
}
}
public static void main(String[] args) {
List<KMeans.Point> irisData = readIrisData("D:\\project\\digital_marketing\\src\\main\\java\\com\\sztzjy\\marketing\\controller\\Iris.txt");
int k = 3; // 假设聚为3类
int maxIterations = 100;
KMeans kMeans = new KMeans(k, maxIterations, irisData);
List<List<KMeans.Point>> clusters = kMeans.cluster();
// 打印每个簇的结果
for (int i = 0; i < clusters.size(); i++) {
System.out.println("Cluster " + i + ": " + clusters.get(i));
}
}
private static List<KMeans.Point> readIrisData(String filename) {
// public static void main(String[] args) {
// List<KMeans.Point> irisData = readIrisData("D:\\home\\marketing\\Iris.txt");
// int k = 3; // 假设聚为3类
// int maxIterations = 100;
// KMeans kMeans = new KMeans(k, maxIterations, irisData);
// List<List<KMeans.Point>> clusters = kMeans.cluster();
//
// // 打印每个簇的结果
// for (int i = 0; i < clusters.size(); i++) {
// System.out.println("Cluster " + i + ": " + clusters.get(i));
// }
//
// // 获取每个簇的中心点坐标
// List<Point> centroids = kMeans.getCentroids();
// for (int i = 0; i < centroids.size(); i++) {
// System.out.println("Centroid for cluster " + i + ": " + centroids.get(i));
// }
// }
public static List<KMeans.Point> readIrisData(MultipartFile file) {
List<KMeans.Point> points = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(file.getInputStream()))) {
String line;
// 跳过标题行
br.readLine();
while ((line = br.readLine()) != null) {
String[] values = line.split(",");
double x = Double.parseDouble(values[0]);
double y = Double.parseDouble(values[1]);
double x = Double.parseDouble(values[0]); // 假设第一列是数值
double y = Double.parseDouble(values[1]); // 假设第二列是数值
points.add(new KMeans.Point(x, y));
}
} catch (IOException e) {

@ -0,0 +1,59 @@
package com.sztzjy.marketing.util.algorithm;
public class LinearRegression {
private double intercept;
private double slope;
// 线性回归的训练方法
public void fit(double[] x, double[] y) {
int n = x.length;
double sumX = 0.0, sumY = 0.0, sumXY = 0.0, sumX2 = 0.0;
for (int i = 0; i < n; i++) {
sumX += x[i];
sumY += y[i];
sumXY += x[i] * y[i];
sumX2 += x[i] * x[i];
}
double xMean = sumX / n;
double yMean = sumY / n;
this.slope = (sumXY - n * xMean * yMean) / (sumX2 - n * xMean * xMean);
this.intercept = yMean - this.slope * xMean;
}
// 预测方法
public double predict(double x) {
return this.intercept + this.slope * x;
}
// 获取截距
public double getIntercept() {
return this.intercept;
}
// 获取斜率
public double getSlope() {
return this.slope;
}
public static void main(String[] args) {
// 示例数据
double[] x = {1, 2, 3, 4, 5};
double[] y = {2, 3, 5, 6, 8};
// 创建线性回归模型
LinearRegression lr = new LinearRegression();
lr.fit(x, y);
// 输出模型参数
System.out.println("截距: " + lr.getIntercept());
System.out.println("斜率: " + lr.getSlope());
// 预测新数据
double newX = 6;
double predictedY = lr.predict(newX);
System.out.println("输入x: " + newX + "预测y=" + predictedY);
}
}

@ -0,0 +1,196 @@
package com.sztzjy.marketing.util.algorithm;
import org.ujmp.core.DenseMatrix;
import org.ujmp.core.Matrix;
/**
* https://blog.csdn.net/weixin_45040801/article/details/102542209
* https://blog.csdn.net/ccblogger/article/details/81739200
* */
public class LogisticRegression {
/**
*
*
* @param data
* @param classValues
* @return
*/
public static double[] train(double[][] data, double[] classValues) {
if (data != null && classValues != null && data.length == classValues.length) {
// 期望矩阵
// Matrix matrWeights = DenseMatrix.Factory.zeros(data[0].length + 1, 1);
Matrix matrWeights = DenseMatrix.Factory.zeros(data[0].length, 1);
System.out.println("data[0].length + 1========"+data[0].length + 1);
// 数据矩阵
// Matrix matrData = DenseMatrix.Factory.zeros(data.length, data[0].length + 1);
Matrix matrData = DenseMatrix.Factory.zeros(data.length, data[0].length);
// 标志矩阵
Matrix matrLable = DenseMatrix.Factory.zeros(data.length, 1);
// 训练速率矩阵
// Matrix matrRate = DenseMatrix.Factory.zeros(data[0].length + 1,data.length);
// 统计difference的总体失误的辅助矩阵
Matrix matrDiffUtil = DenseMatrix.Factory.zeros(data[0].length,data.length);
for(int i=0;i<data.length;i++){
for(int j=0;j<data[0].length;j++) {
matrDiffUtil.setAsDouble(1, j, i);
}
}
System.out.println("matrDiffUtil="+matrDiffUtil);
/**
*
*
* */
// System.out.println("matrRate======="+matrRate);
// 设置训练速率矩阵
// for(int i=0;i<data[0].length + 1;i++){
// for(int j=0;j<data.length;j++){
// }
// }
for (int i = 0; i < data.length; i++) {
// matrData.setAsDouble(1.0, i, 0);
// 初始化标志矩阵
matrLable.setAsDouble(classValues[i], i, 0);
for (int j = 0; j < data[0].length; j++) {
// 初始化数据矩阵
// matrData.setAsDouble(data[i][j], i, j + 1);
matrData.setAsDouble(data[i][j], i, j);
if (i == 0) {
// 初始化期望矩阵
// matrWeights.setAsDouble(1.0, j+1, 0);
matrWeights.setAsDouble(1.0, j, 0);
}
}
}
// matrWeights.setAsDouble(-0.5, data[0].length, 0);
// matrRate = matrData.transpose().times(0.9);
// System.out.println("matrRate============"+matrRate);
double step = 0.011;
int maxCycle = 5000000;
// int maxCycle = 5;
System.out.println("matrData======"+matrData);
System.out.println("matrWeights"+matrWeights);
System.out.println("matrLable"+matrLable);
/**
* 使
* https://blog.csdn.net/lionel_fengj/article/details/53400715
*
* */
for (int i = 0; i < maxCycle; i++) {
// 将想要函数转换为sigmoid函数并得到的值
Matrix h = sigmoid(matrData.mtimes(matrWeights));
// System.out.println("h=="+h);
// 求出预期和真实的差值
Matrix difference = matrLable.minus(h);
// System.out.println("difference "+difference);
// matrData转置后和difference相乘得到预期和真实差值的每一个值
// 公式:@0 = @0 - ax(y0-y),可以参考https://blog.csdn.net/ccblogger/article/details/81739200
matrWeights = matrWeights.plus(matrData.transpose().mtimes(difference).times(step));
// matrWeights = matrWeights.plus(matrRate.mtimes(difference).times(step));
// matrWeights = matrWeights.plus(matrDiffUtil.mtimes(difference).times(step));
}
double[] rtn = new double[(int) matrWeights.getRowCount()];
for (long i = 0; i < matrWeights.getRowCount(); i++) {
rtn[(int) i] = matrWeights.getAsDouble(i, 0);
}
return rtn;
}
return null;
}
/**
* sigmoid
*
* @param sourceMatrix
* @return sigmoid
*/
public static Matrix sigmoid(Matrix sourceMatrix) {
Matrix rtn = DenseMatrix.Factory.zeros(sourceMatrix.getRowCount(), sourceMatrix.getColumnCount());
for (int i = 0; i < sourceMatrix.getRowCount(); i++) {
for (int j = 0; j < sourceMatrix.getColumnCount(); j++) {
rtn.setAsDouble(sigmoid(sourceMatrix.getAsDouble(i, j)), i, j);
}
}
return rtn;
}
/**
* sigmoid
*
* @param source
* @return sigmoid
*/
public static double sigmoid(double source) {
return 1.0 / (1 + Math.exp(-1 * source));
}
// 测试预测值:
/**
*
*
* @param sourceData
* @param model
* @return
*/
public static double getValue(double[] sourceData, double[] model) {
// double logisticRegressionValue = model[0];
double logisticRegressionValue = 0;
for (int i = 0; i < sourceData.length; i++) {
// logisticRegressionValue = logisticRegressionValue + sourceData[i] * model[i + 1];
logisticRegressionValue = logisticRegressionValue + sourceData[i] * model[i];
}
logisticRegressionValue = sigmoid(logisticRegressionValue);
return logisticRegressionValue;
}
public static void main(String[] args) {
double[][] sourceData = new double[][]{{-1, 1}, {0, 1}, {1, -1}, {1, 0}, {0, 0.1}, {0, -0.1}, {-1, -1.1}, {1, 0.9}};
double[] classValue = new double[]{1, 1, 0, 0, 1, 0, 0, 0};
double[] modle = LogisticRegression.train(sourceData, classValue);
// double logicValue = LogisticRegression.getValue(new double[] { 0, 0 }, modle);
double logicValue0 = LogisticRegression.getValue(new double[]{-1, 1}, modle);
double logicValue1 = LogisticRegression.getValue(new double[]{0, 1}, modle);
double logicValue2 = LogisticRegression.getValue(new double[]{1, -1}, modle);//3.1812246935599485E-60无限趋近于0
double logicValue3 = LogisticRegression.getValue(new double[]{1, 0}, modle);//3.091713602147872E-30无限趋近于0
double logicValue4 = LogisticRegression.getValue(new double[]{0, 0.1}, modle);//3.091713602147872E-30无限趋近于0
double logicValue5 = LogisticRegression.getValue(new double[]{0, -0.1}, modle);//3.091713602147872E-30无限趋近于0
System.out.println("---model---");
for (int i = 0; i < modle.length; i++) {
System.out.println(modle[i]);
}
System.out.println("-----------");
// System.out.println(logicValue);
System.out.println(logicValue0);
System.out.println(logicValue1);
System.out.println(logicValue2);
System.out.println(logicValue3);
System.out.println(logicValue4);
System.out.println(logicValue5);
}
}

@ -0,0 +1,50 @@
package com.sztzjy.marketing.util.algorithm;
import java.util.ArrayList;
import java.util.List;
public class TrainDataSet {
/**
*
**/
public List<double[]> features = new ArrayList<>();
/**
*
**/
public List<Double> labels = new ArrayList<>();
/**
*
**/
public int featureDim;
public int size() {
return labels.size();
}
public double[] getFeature(int index) {
return features.get(index);
}
public double getLabel(int index) {
return labels.get(index);
}
public void addData(double[] feature, double label) {
if (features.isEmpty()) {
featureDim = feature.length;
} else {
if (featureDim != feature.length) {
throwDimensionMismatchException(feature.length);
}
}
features.add(feature);
labels.add(label);
}
public void throwDimensionMismatchException(int errorLen) {
throw new RuntimeException("DimensionMismatchError: 你应该传入维度为 " + featureDim + " 的特征向量 , 但你传入了维度为 " + errorLen + " 的特征向量");
}
}

@ -0,0 +1,226 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sztzjy.marketing.mapper.StuTableNameMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.marketing.entity.StuTableName">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="table_name" jdbcType="VARCHAR" property="tableName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, user_id, table_name, create_time, update_time
</sql>
<select id="selectByExample" parameterType="com.sztzjy.marketing.entity.StuTableNameExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from stu_table_name
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from stu_table_name
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from stu_table_name
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.marketing.entity.StuTableNameExample">
delete from stu_table_name
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.marketing.entity.StuTableName">
insert into stu_table_name (id, user_id, table_name,
create_time, update_time)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.marketing.entity.StuTableName">
insert into stu_table_name
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="tableName != null">
table_name,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="tableName != null">
#{tableName,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.marketing.entity.StuTableNameExample" resultType="java.lang.Long">
select count(*) from stu_table_name
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update stu_table_name
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.tableName != null">
table_name = #{record.tableName,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update stu_table_name
set id = #{record.id,jdbcType=INTEGER},
user_id = #{record.userId,jdbcType=VARCHAR},
table_name = #{record.tableName,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.marketing.entity.StuTableName">
update stu_table_name
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="tableName != null">
table_name = #{tableName,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.marketing.entity.StuTableName">
update stu_table_name
set user_id = #{userId,jdbcType=VARCHAR},
table_name = #{tableName,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getTableName" resultType="java.lang.String">
select table_name from stu_table_name where user_id=#{userId}
</select>
<select id="selectByFields" resultType="java.util.Map">
SELECT
<foreach collection="fieldList" item="field" separator=",">
${field}
</foreach>
FROM ${table}
</select>
</mapper>

@ -0,0 +1,386 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sztzjy.marketing.mapper.StuUserBehaviorMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.marketing.entity.StuUserBehavior">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="login_name" jdbcType="VARCHAR" property="loginName" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="student_id" jdbcType="VARCHAR" property="studentId" />
<result column="stu_class" jdbcType="VARCHAR" property="stuClass" />
<result column="major" jdbcType="VARCHAR" property="major" />
<result column="school" jdbcType="VARCHAR" property="school" />
<result column="role_name" jdbcType="VARCHAR" property="roleName" />
<result column="goods_name" jdbcType="VARCHAR" property="goodsName" />
<result column="goods_type" jdbcType="VARCHAR" property="goodsType" />
<result column="goods_subcategories" jdbcType="VARCHAR" property="goodsSubcategories" />
<result column="user_behavior_type" jdbcType="VARCHAR" property="userBehaviorType" />
<result column="behavior_date" jdbcType="TIMESTAMP" property="behaviorDate" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, user_id, login_name, user_name, student_id, stu_class, major, school, role_name,
goods_name, goods_type, goods_subcategories, user_behavior_type, behavior_date, create_time,
update_time
</sql>
<select id="selectByExample" parameterType="com.sztzjy.marketing.entity.StuUserBehaviorExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from stu_user_behavior
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from stu_user_behavior
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from stu_user_behavior
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.marketing.entity.StuUserBehaviorExample">
delete from stu_user_behavior
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.marketing.entity.StuUserBehavior">
insert into stu_user_behavior (id, user_id, login_name,
user_name, student_id, stu_class,
major, school, role_name,
goods_name, goods_type, goods_subcategories,
user_behavior_type, behavior_date, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{loginName,jdbcType=VARCHAR},
#{userName,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{stuClass,jdbcType=VARCHAR},
#{major,jdbcType=VARCHAR}, #{school,jdbcType=VARCHAR}, #{roleName,jdbcType=VARCHAR},
#{goodsName,jdbcType=VARCHAR}, #{goodsType,jdbcType=VARCHAR}, #{goodsSubcategories,jdbcType=VARCHAR},
#{userBehaviorType,jdbcType=VARCHAR}, #{behaviorDate,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.marketing.entity.StuUserBehavior">
insert into stu_user_behavior
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="loginName != null">
login_name,
</if>
<if test="userName != null">
user_name,
</if>
<if test="studentId != null">
student_id,
</if>
<if test="stuClass != null">
stu_class,
</if>
<if test="major != null">
major,
</if>
<if test="school != null">
school,
</if>
<if test="roleName != null">
role_name,
</if>
<if test="goodsName != null">
goods_name,
</if>
<if test="goodsType != null">
goods_type,
</if>
<if test="goodsSubcategories != null">
goods_subcategories,
</if>
<if test="userBehaviorType != null">
user_behavior_type,
</if>
<if test="behaviorDate != null">
behavior_date,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="loginName != null">
#{loginName,jdbcType=VARCHAR},
</if>
<if test="userName != null">
#{userName,jdbcType=VARCHAR},
</if>
<if test="studentId != null">
#{studentId,jdbcType=VARCHAR},
</if>
<if test="stuClass != null">
#{stuClass,jdbcType=VARCHAR},
</if>
<if test="major != null">
#{major,jdbcType=VARCHAR},
</if>
<if test="school != null">
#{school,jdbcType=VARCHAR},
</if>
<if test="roleName != null">
#{roleName,jdbcType=VARCHAR},
</if>
<if test="goodsName != null">
#{goodsName,jdbcType=VARCHAR},
</if>
<if test="goodsType != null">
#{goodsType,jdbcType=VARCHAR},
</if>
<if test="goodsSubcategories != null">
#{goodsSubcategories,jdbcType=VARCHAR},
</if>
<if test="userBehaviorType != null">
#{userBehaviorType,jdbcType=VARCHAR},
</if>
<if test="behaviorDate != null">
#{behaviorDate,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.marketing.entity.StuUserBehaviorExample" resultType="java.lang.Long">
select count(*) from stu_user_behavior
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update stu_user_behavior
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.loginName != null">
login_name = #{record.loginName,jdbcType=VARCHAR},
</if>
<if test="record.userName != null">
user_name = #{record.userName,jdbcType=VARCHAR},
</if>
<if test="record.studentId != null">
student_id = #{record.studentId,jdbcType=VARCHAR},
</if>
<if test="record.stuClass != null">
stu_class = #{record.stuClass,jdbcType=VARCHAR},
</if>
<if test="record.major != null">
major = #{record.major,jdbcType=VARCHAR},
</if>
<if test="record.school != null">
school = #{record.school,jdbcType=VARCHAR},
</if>
<if test="record.roleName != null">
role_name = #{record.roleName,jdbcType=VARCHAR},
</if>
<if test="record.goodsName != null">
goods_name = #{record.goodsName,jdbcType=VARCHAR},
</if>
<if test="record.goodsType != null">
goods_type = #{record.goodsType,jdbcType=VARCHAR},
</if>
<if test="record.goodsSubcategories != null">
goods_subcategories = #{record.goodsSubcategories,jdbcType=VARCHAR},
</if>
<if test="record.userBehaviorType != null">
user_behavior_type = #{record.userBehaviorType,jdbcType=VARCHAR},
</if>
<if test="record.behaviorDate != null">
behavior_date = #{record.behaviorDate,jdbcType=TIMESTAMP},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update stu_user_behavior
set id = #{record.id,jdbcType=INTEGER},
user_id = #{record.userId,jdbcType=VARCHAR},
login_name = #{record.loginName,jdbcType=VARCHAR},
user_name = #{record.userName,jdbcType=VARCHAR},
student_id = #{record.studentId,jdbcType=VARCHAR},
stu_class = #{record.stuClass,jdbcType=VARCHAR},
major = #{record.major,jdbcType=VARCHAR},
school = #{record.school,jdbcType=VARCHAR},
role_name = #{record.roleName,jdbcType=VARCHAR},
goods_name = #{record.goodsName,jdbcType=VARCHAR},
goods_type = #{record.goodsType,jdbcType=VARCHAR},
goods_subcategories = #{record.goodsSubcategories,jdbcType=VARCHAR},
user_behavior_type = #{record.userBehaviorType,jdbcType=VARCHAR},
behavior_date = #{record.behaviorDate,jdbcType=TIMESTAMP},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.marketing.entity.StuUserBehavior">
update stu_user_behavior
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="loginName != null">
login_name = #{loginName,jdbcType=VARCHAR},
</if>
<if test="userName != null">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="studentId != null">
student_id = #{studentId,jdbcType=VARCHAR},
</if>
<if test="stuClass != null">
stu_class = #{stuClass,jdbcType=VARCHAR},
</if>
<if test="major != null">
major = #{major,jdbcType=VARCHAR},
</if>
<if test="school != null">
school = #{school,jdbcType=VARCHAR},
</if>
<if test="roleName != null">
role_name = #{roleName,jdbcType=VARCHAR},
</if>
<if test="goodsName != null">
goods_name = #{goodsName,jdbcType=VARCHAR},
</if>
<if test="goodsType != null">
goods_type = #{goodsType,jdbcType=VARCHAR},
</if>
<if test="goodsSubcategories != null">
goods_subcategories = #{goodsSubcategories,jdbcType=VARCHAR},
</if>
<if test="userBehaviorType != null">
user_behavior_type = #{userBehaviorType,jdbcType=VARCHAR},
</if>
<if test="behaviorDate != null">
behavior_date = #{behaviorDate,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.marketing.entity.StuUserBehavior">
update stu_user_behavior
set user_id = #{userId,jdbcType=VARCHAR},
login_name = #{loginName,jdbcType=VARCHAR},
user_name = #{userName,jdbcType=VARCHAR},
student_id = #{studentId,jdbcType=VARCHAR},
stu_class = #{stuClass,jdbcType=VARCHAR},
major = #{major,jdbcType=VARCHAR},
school = #{school,jdbcType=VARCHAR},
role_name = #{roleName,jdbcType=VARCHAR},
goods_name = #{goodsName,jdbcType=VARCHAR},
goods_type = #{goodsType,jdbcType=VARCHAR},
goods_subcategories = #{goodsSubcategories,jdbcType=VARCHAR},
user_behavior_type = #{userBehaviorType,jdbcType=VARCHAR},
behavior_date = #{behaviorDate,jdbcType=TIMESTAMP},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
Loading…
Cancel
Save