diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java new file mode 100644 index 00000000..694375aa --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java @@ -0,0 +1,62 @@ +package com.ruoyi.platform.controller.activeLearn; + +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.GenericsAjaxResult; +import com.ruoyi.platform.domain.ActiveLearn; +import com.ruoyi.platform.service.ActiveLearnService; +import com.ruoyi.platform.vo.ActiveLearnVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.io.IOException; + +@RestController +@RequestMapping("activeLearn") +@Api("主动学习") +public class ActiveLearnController extends BaseController { + + @Resource + private ActiveLearnService activeLearnService; + + @GetMapping + @ApiOperation("分页查询") + public GenericsAjaxResult> queryByPage(@RequestParam("page") int page, + @RequestParam("size") int size, @RequestParam(value = "name", required = false) String name) { + PageRequest pageRequest = PageRequest.of(page, size); + return genericsSuccess(this.activeLearnService.queryByPage(name, pageRequest)); + } + + @PostMapping + @ApiOperation("新增主动学习") + public GenericsAjaxResult addActiveLearn(@RequestBody ActiveLearnVo activeLearnServiceVo) { + return genericsSuccess(this.activeLearnService.save(activeLearnServiceVo)); + } + + @PutMapping + @ApiOperation("编辑主动学习") + public GenericsAjaxResult editActiveLearn(@RequestBody ActiveLearnVo activeLearnServiceVo) { + return genericsSuccess(this.activeLearnService.edit(activeLearnServiceVo)); + } + + @GetMapping("/getActiveLearnDetail") + @ApiOperation("获取主动学习详细信息") + public GenericsAjaxResult getActiveLearnDetail(@RequestParam("id") Long id) throws IOException { + return genericsSuccess(this.activeLearnService.getActiveLearnDetail(id)); + } + + @DeleteMapping("{id}") + @ApiOperation("删除主动学习") + public GenericsAjaxResult deleteActiveLearn(@PathVariable("id") Long id) { + return genericsSuccess(this.activeLearnService.delete(id)); + } + + @PostMapping("/run/{id}") + @ApiOperation("运行主动学习实验") + public GenericsAjaxResult runActiveLearn(@PathVariable("id") Long id) throws Exception { + return genericsSuccess(this.activeLearnService.runActiveLearnIns(id)); + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java new file mode 100644 index 00000000..7af4c201 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java @@ -0,0 +1,54 @@ +package com.ruoyi.platform.controller.activeLearn; + +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.GenericsAjaxResult; +import com.ruoyi.platform.domain.ActiveLearnIns; +import com.ruoyi.platform.service.ActiveLearnInsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.List; + +@RestController +@RequestMapping("activeLearnIns") +@Api("主动学习实验实例") +public class ActiveLearnInsController extends BaseController { + @Resource + private ActiveLearnInsService activeLearnInsService; + + @GetMapping + @ApiOperation("分页查询") + public GenericsAjaxResult> queryByPage(ActiveLearnIns activeLearnIns, int page, int size) throws IOException { + PageRequest pageRequest = PageRequest.of(page, size); + return genericsSuccess(this.activeLearnInsService.queryByPage(activeLearnIns, pageRequest)); + } + + @DeleteMapping("{id}") + @ApiOperation("删除实验实例") + public GenericsAjaxResult deleteById(@PathVariable("id") Long id) { + return genericsSuccess(this.activeLearnInsService.removeById(id)); + } + + @DeleteMapping("batchDelete") + @ApiOperation("批量删除实验实例") + public GenericsAjaxResult batchDelete(@RequestBody List ids) { + return genericsSuccess(this.activeLearnInsService.batchDelete(ids)); + } + + @PutMapping("{id}") + @ApiOperation("终止实验实例") + public GenericsAjaxResult terminateActiveLearnIns(@PathVariable("id") Long id) { + return genericsSuccess(this.activeLearnInsService.terminateActiveLearnIns(id)); + } + + @GetMapping("{id}") + @ApiOperation("查看实验实例详情") + public GenericsAjaxResult getDetailById(@PathVariable("id") Long id) { + return genericsSuccess(this.activeLearnInsService.getDetailById(id)); + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearn.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearn.java new file mode 100644 index 00000000..f41702a6 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearn.java @@ -0,0 +1,77 @@ +package com.ruoyi.platform.domain; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@ApiModel(description = "主动学习") +public class ActiveLearn { + private Long id; + + @ApiModelProperty(value = "实验名称") + private String name; + + @ApiModelProperty(value = "实验描述") + private String description; + + @ApiModelProperty(value = "数据集") + private String dataset; + + @ApiModelProperty(value = "数据集csv文件中哪几列是预测目标列,逗号分隔") + private String targetColumns; + + @ApiModelProperty(value = "分类算法") + private String classifierType; + + @ApiModelProperty(value = "每次查询个数") + private Integer queryBatchSize; + + @ApiModelProperty(value = "停止判则") + private String stoppingCriterion; + + @ApiModelProperty(value = "stopping_criterion为num_of_queries时传入,查询次数") + private Integer numOfQueries; + + @ApiModelProperty(value = "stopping_criterion为cost_limit时传入,成本限制") + private Double costLimit; + + @ApiModelProperty(value = "stopping_criterion为percent_of_unlabel时传入,未标记比例") + private Double percentOfUnlabel; + + @ApiModelProperty(value = "stopping_criterion为percent_of_unlabel时传入,时间限制") + private Double timeLimit; + + @ApiModelProperty(value = "查询策略") + private String queryStrategy; + + @ApiModelProperty(value = "实验次数") + private Integer numOfExperiment; + + @ApiModelProperty(value = "测试集比率") + private Double testRatio; + + @ApiModelProperty(value = "初始使用标记数据比率") + private Double initialLabelRate; + + @ApiModelProperty(value = "指标") + private String performanceMetric; + + private Integer state; + + private String createBy; + + private Date createTime; + + private String updateBy; + + private Date updateTime; + + @ApiModelProperty(value = "状态列表") + private String statusList; +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearnIns.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearnIns.java new file mode 100644 index 00000000..94bfe470 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ActiveLearnIns.java @@ -0,0 +1,38 @@ +package com.ruoyi.platform.domain; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@ApiModel(description = "主动学习实验实例") +public class ActiveLearnIns { + private Long id; + + private Long activeLearnId; + + private String param; + + private String resultPath; + + private Integer state; + + private String status; + + @ApiModelProperty(value = "Argo实例名称") + private String argoInsName; + + @ApiModelProperty(value = "Argo命名空间") + private String argoInsNs; + + private Date createTime; + + private Date updateTime; + + private Date finishTime; +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnDao.java new file mode 100644 index 00000000..e2d07475 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnDao.java @@ -0,0 +1,21 @@ +package com.ruoyi.platform.mapper; + +import com.ruoyi.platform.domain.ActiveLearn; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +public interface ActiveLearnDao { + long count(@Param("name") String name); + + List queryByPage(@Param("name") String name, @Param("pageable") Pageable pageable); + + ActiveLearn getActiveLearnByName(@Param("name") String name); + + int save(@Param("activeLearn") ActiveLearn activeLearn); + + int edit(@Param("activeLearn") ActiveLearn activeLearn); + + ActiveLearn getActiveLearnById(@Param("id") Long id); +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnInsDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnInsDao.java new file mode 100644 index 00000000..2793665c --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/ActiveLearnInsDao.java @@ -0,0 +1,21 @@ +package com.ruoyi.platform.mapper; + +import com.ruoyi.platform.domain.ActiveLearnIns; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +public interface ActiveLearnInsDao { + long count(@Param("activeLearnIns") ActiveLearnIns activeLearnIns); + + List queryAllByLimit(@Param("activeLearnIns") ActiveLearnIns activeLearnIns, @Param("pageable") Pageable pageable); + + int insert(@Param("activeLearnIns") ActiveLearnIns activeLearnIns); + + int update(@Param("activeLearnIns") ActiveLearnIns activeLearnIns); + + ActiveLearnIns queryById(@Param("id") Long id); + + List getByActiveLearnId(@Param("activeLearnId") Long activeLearnId); +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java new file mode 100644 index 00000000..21433f21 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java @@ -0,0 +1,22 @@ +package com.ruoyi.platform.service; + +import com.ruoyi.platform.domain.ActiveLearnIns; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import java.io.IOException; +import java.util.List; + +public interface ActiveLearnInsService { + Page queryByPage(ActiveLearnIns activeLearnIns, PageRequest pageRequest) throws IOException; + + ActiveLearnIns insert(ActiveLearnIns activeLearnIns); + + String removeById(Long id); + + String batchDelete(List ids); + + boolean terminateActiveLearnIns(Long id); + + ActiveLearnIns getDetailById(Long id); +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java new file mode 100644 index 00000000..73b82c64 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java @@ -0,0 +1,23 @@ +package com.ruoyi.platform.service; + +import com.ruoyi.platform.domain.ActiveLearn; +import com.ruoyi.platform.vo.ActiveLearnVo; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import java.io.IOException; + +public interface ActiveLearnService { + Page queryByPage(String name, PageRequest pageRequest); + + ActiveLearn save(ActiveLearnVo activeLearnServiceVo); + + String edit(ActiveLearnVo activeLearnServiceVo); + + ActiveLearnVo getActiveLearnDetail(Long id) throws IOException; + + String delete(Long id); + + String runActiveLearnIns(Long id) throws Exception; + +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java new file mode 100644 index 00000000..24bf7f59 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java @@ -0,0 +1,111 @@ +package com.ruoyi.platform.service.impl; + +import com.ruoyi.platform.constant.Constant; +import com.ruoyi.platform.domain.ActiveLearn; +import com.ruoyi.platform.domain.ActiveLearnIns; +import com.ruoyi.platform.mapper.ActiveLearnDao; +import com.ruoyi.platform.mapper.ActiveLearnInsDao; +import com.ruoyi.platform.service.ActiveLearnInsService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +@Service("activeLearnInsService") +public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { + @Resource + private ActiveLearnInsDao activeLearnInsDao; + @Resource + private ActiveLearnDao activeLearnDao; + + @Override + public Page queryByPage(ActiveLearnIns activeLearnIns, PageRequest pageRequest) throws IOException { + long total = this.activeLearnInsDao.count(activeLearnIns); + List activeLearnInsList = this.activeLearnInsDao.queryAllByLimit(activeLearnIns, pageRequest); + return new PageImpl<>(activeLearnInsList, pageRequest, total); + } + + @Override + public ActiveLearnIns insert(ActiveLearnIns activeLearnIns) { + this.activeLearnInsDao.insert(activeLearnIns); + return activeLearnIns; + } + + @Override + public String removeById(Long id) { + ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id); + if (activeLearnIns == null) { + return "实验实例不存在"; + } + + //todo queryStatusFromArgo + + activeLearnIns.setState(Constant.State_invalid); + int update = activeLearnInsDao.update(activeLearnIns); + if (update > 0) { + updateActiveLearnStatus(activeLearnIns.getActiveLearnId()); + return "删除成功"; + } else { + return "删除失败"; + } + } + + @Override + public String batchDelete(List ids) { + for (Long id : ids) { + String result = removeById(id); + if (!"删除成功".equals(result)) { + return result; + } + } + return "删除成功"; + } + + @Override + public boolean terminateActiveLearnIns(Long id) { + ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id); + if (activeLearnIns == null) { + throw new IllegalStateException("实验实例未查询到,id: " + id); + } + + String currentStatus = activeLearnIns.getStatus(); + String name = activeLearnIns.getArgoInsName(); + String namespace = activeLearnIns.getArgoInsNs(); + + //todo queryStatusFromArgo + + return false; + } + + @Override + public ActiveLearnIns getDetailById(Long id) { + ActiveLearnIns activeLearnIns = activeLearnInsDao.queryById(id); + if(Constant.Running.equals(activeLearnIns.getStatus()) || Constant.Pending.equals(activeLearnIns.getStatus())){ + //todo queryStatusFromArgo + } + return activeLearnIns; + } + + public void updateActiveLearnStatus(Long activeLearnId) { + List insList = activeLearnInsDao.getByActiveLearnId(activeLearnId); + List statusList = new ArrayList<>(); + + // 更新实验状态列表 + for (int i = 0; i < insList.size(); i++) { + statusList.add(insList.get(i).getStatus()); + } + String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); + ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(activeLearnId); + if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) { + activeLearn.setStatusList(subStatus); + activeLearnDao.edit(activeLearn); + } + } + +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java new file mode 100644 index 00000000..3bcdee48 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java @@ -0,0 +1,111 @@ +package com.ruoyi.platform.service.impl; + +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.platform.constant.Constant; +import com.ruoyi.platform.domain.ActiveLearn; +import com.ruoyi.platform.mapper.ActiveLearnDao; +import com.ruoyi.platform.service.ActiveLearnService; +import com.ruoyi.platform.utils.JacksonUtil; +import com.ruoyi.platform.utils.JsonUtils; +import com.ruoyi.platform.vo.ActiveLearnVo; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.List; + +@Service("activeLearnService") +public class ActiveLearnServiceImpl implements ActiveLearnService { + @Resource + private ActiveLearnDao activeLearnDao; + + @Override + public Page queryByPage(String name, PageRequest pageRequest) { + long total = activeLearnDao.count(name); + List activeLearns = activeLearnDao.queryByPage(name, pageRequest); + return new PageImpl<>(activeLearns, pageRequest, total); + } + + @Override + public ActiveLearn save(ActiveLearnVo activeLearnVo) { + ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName()); + if (activeLearnByName != null) { + throw new RuntimeException("实验名称已存在"); + } + ActiveLearn activeLearn = new ActiveLearn(); + BeanUtils.copyProperties(activeLearnVo, activeLearn); + String username = SecurityUtils.getLoginUser().getUsername(); + activeLearn.setCreateBy(username); + activeLearn.setUpdateBy(username); + String datasetJson = JacksonUtil.toJSONString(activeLearnVo.getDataset()); + activeLearn.setDataset(datasetJson); + activeLearnDao.save(activeLearn); + return activeLearn; + } + + @Override + public String edit(ActiveLearnVo activeLearnVo) { + ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName()); + if (activeLearnByName != null && !activeLearnByName.getId().equals(activeLearnVo.getId())) { + throw new RuntimeException("实验名称已存在"); + } + + ActiveLearn activeLearn = new ActiveLearn(); + BeanUtils.copyProperties(activeLearnVo, activeLearn); + String username = SecurityUtils.getLoginUser().getUsername(); + activeLearn.setUpdateBy(username); + String datasetJson = JacksonUtil.toJSONString(activeLearnVo.getDataset()); + activeLearn.setDataset(datasetJson); + activeLearnDao.edit(activeLearn); + + return "修改成功"; + } + + @Override + public ActiveLearnVo getActiveLearnDetail(Long id) throws IOException { + ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); + ActiveLearnVo activeLearnVo = new ActiveLearnVo(); + BeanUtils.copyProperties(activeLearn, activeLearnVo); + if (StringUtils.isNotEmpty(activeLearn.getDataset())) { + activeLearnVo.setDataset(JsonUtils.jsonToMap(activeLearn.getDataset())); + } + return activeLearnVo; + } + + @Override + public String delete(Long id) { + ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); + if (activeLearn == null) { + throw new RuntimeException("实验不存在"); + } + String username = SecurityUtils.getLoginUser().getUsername(); + String createBy = activeLearn.getCreateBy(); + if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { + throw new RuntimeException("无权限删除该实验"); + } + activeLearn.setState(Constant.State_invalid); + return activeLearnDao.edit(activeLearn) > 0 ? "删除成功" : "删除失败"; + } + + @Override + public String runActiveLearnIns(Long id) throws Exception { + ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); + if (activeLearn == null) { + throw new Exception("主动学习配置不存在"); + } + + ActiveLearnVo activeLearnParam = new ActiveLearnVo(); + BeanUtils.copyProperties(activeLearn, activeLearnParam); + activeLearnParam.setDataset(JsonUtils.jsonToMap(activeLearn.getDataset())); + String param = JsonUtils.objectToJson(activeLearnParam); + + // todo 调argo转换接口 + + return "执行成功"; + } +} diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java index d5e436e8..dfddf71f 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/AutoMlServiceImpl.java @@ -102,13 +102,13 @@ public class AutoMlServiceImpl implements AutoMlService { public String delete(Long id) { AutoMl autoMl = autoMlDao.getAutoMlById(id); if (autoMl == null) { - throw new RuntimeException("服务不存在"); + throw new RuntimeException("实验不存在"); } String username = SecurityUtils.getLoginUser().getUsername(); String createBy = autoMl.getCreateBy(); if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { - throw new RuntimeException("无权限删除该服务"); + throw new RuntimeException("无权限删除该实验"); } autoMl.setState(Constant.State_invalid); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ActiveLearnVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ActiveLearnVo.java new file mode 100644 index 00000000..c151f916 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/ActiveLearnVo.java @@ -0,0 +1,77 @@ +package com.ruoyi.platform.vo; + +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.Map; + +@Data +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +@ApiModel(description = "主动学习") +public class ActiveLearnVo { + private Long id; + + @ApiModelProperty(value = "实验名称") + private String name; + + @ApiModelProperty(value = "实验描述") + private String description; + + /** + * 对应数据集 + */ + private Map dataset; + + @ApiModelProperty(value = "数据集csv文件中哪一列是预测目标列,逗号分隔") + private String targetColumns; + + @ApiModelProperty(value = "分类算法:logistic_regression(逻辑回归),decision_tree(决策树),random_forest(随机森林),SVM(支持向量机),naive_bayes(朴素贝叶斯),GBM(梯度提升机)") + private String classifierType; + + @ApiModelProperty(value = "每次查询个数") + private Integer queryBatchSize; + + @ApiModelProperty(value = "停止判则:num_of_queries(查询次数),percent_of_unlabel(未标记样本比例),time_limit(时间限制)") + private String stoppingCriterion; + + @ApiModelProperty(value = "stopping_criterion为num_of_queries时传入,查询次数") + private Integer numOfQueries; + +// @ApiModelProperty(value = "stopping_criterion为cost_limit时传入,成本限制") +// private Double costLimit; + + @ApiModelProperty(value = "stopping_criterion为percent_of_unlabel时传入,未标记比例") + private Double percentOfUnlabel; + + @ApiModelProperty(value = "stopping_criterion为percent_of_unlabel时传入,时间限制") + private Double timeLimit; + + @ApiModelProperty(value = "查询策略:Uncertainty,QBC,Random,GraphDensity") + private String queryStrategy; + + @ApiModelProperty(value = "实验次数") + private Integer numOfExperiment; + + @ApiModelProperty(value = "测试集比率") + private Double testRatio; + + @ApiModelProperty(value = "初始使用标记数据比率") + private Double initialLabelRate; + + @ApiModelProperty(value = "指标:accuracy_score,roc_auc_score,get_fps_tps_thresholds,hamming_loss,one_error,coverage_error") + private String performanceMetric; + + private Integer state; + + private String createBy; + + private Date createTime; + + private String updateBy; + + private Date updateTime; +} diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml new file mode 100644 index 00000000..92b5cc23 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnDaoMapper.xml @@ -0,0 +1,115 @@ + + + + + insert into active_learn(name, description, dataset, target_columns, classifier_type, query_batch_size, + stopping_criterion, + num_of_queries, cost_limit, percent_of_unlabel, time_limit, query_strategy, + num_of_experiment, test_ratio, + initial_label_rate, performance_metric, create_by, update_by) + values (#{activeLearn.name}, #{activeLearn.description}, #{activeLearn.dataset}, #{activeLearn.targetColumns}, + #{activeLearn.classifierType}, #{activeLearn.queryBatchSize}, #{activeLearn.stoppingCriterion}, + #{activeLearn.numOfQueries}, + #{activeLearn.costLimit}, #{activeLearn.percentOfUnlabel}, #{activeLearn.timeLimit}, + #{activeLearn.queryStrategy}, + #{activeLearn.numOfExperiment}, #{activeLearn.testRatio}, #{activeLearn.initialLabelRate}, + #{activeLearn.performanceMetric}, + #{activeLearn.createBy}, #{activeLearn.updateBy}) + + + + update active_learn + + + name = #{activeLearn.name}, + + + description = #{activeLearn.description}, + + + dataset = #{activeLearn.dataset}, + + + target_columns = #{activeLearn.targetColumns}, + + + classifier_type = #{activeLearn.classifierType}, + + + query_batch_size = #{activeLearn.queryBatchSize}, + + + stopping_criterion = #{activeLearn.stoppingCriterion}, + + + num_of_queries = #{activeLearn.numOfQueries}, + + + cost_limit = #{activeLearn.costLimit}, + + + percent_of_unlabel = #{activeLearn.percentOfUnlabel}, + + + time_limit = #{activeLearn.timeLimit}, + + + query_strategy = #{activeLearn.queryStrategy}, + + + num_of_experiment = #{activeLearn.numOfExperiment}, + + + test_ratio = #{activeLearn.testRatio}, + + + initial_label_rate = #{activeLearn.initialLabelRate}, + + + performance_metric = #{activeLearn.performanceMetric}, + + + update_by = #{activeLearn.updateBy}, + + + status_list = #{activeLearn.statusList}, + + + state = #{activeLearn.state}, + + + where id = #{activeLearn.id} + + + + + + + + + + + + + state = 1 + + and name like concat('%', #{name}, '%') + + + + \ No newline at end of file diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnInsDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnInsDaoMapper.xml new file mode 100644 index 00000000..8c4ef022 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ActiveLearnInsDaoMapper.xml @@ -0,0 +1,65 @@ + + + + + insert into active_learn_ins(active_learn_id, status, param, argo_ins_name, argo_ins_ns, result_path) + values (#{activeLearnIns.activeLearnId}, #{activeLearnIns.status}, #{activeLearnIns.param}, + #{activeLearnIns.argoInsName}, #{activeLearnIns.argoInsNs}, #{activeLearnIns.resultPath}) + + + + update active_learn_ins + + + state = #{activeLearnIns.state}, + + + update_time = #{activeLearnIns.updateTime}, + + + finish_time = #{activeLearnIns.finishTime}, + + + status = #{activeLearnIns.status}, + + + result_path = #{activeLearnIns.resultPath}, + + + where id = #{activeLearnIns.id} + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml index 1e4d228c..129228e0 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/AutoMlDao.xml @@ -105,6 +105,9 @@ target_columns = #{autoMl.targetColumns}, + + update_by = #{autoMl.updateBy}, + state = #{autoMl.state},