| @@ -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<Page<ActiveLearn>> 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<ActiveLearn> addActiveLearn(@RequestBody ActiveLearnVo activeLearnServiceVo) { | |||
| return genericsSuccess(this.activeLearnService.save(activeLearnServiceVo)); | |||
| } | |||
| @PutMapping | |||
| @ApiOperation("编辑主动学习") | |||
| public GenericsAjaxResult<String> editActiveLearn(@RequestBody ActiveLearnVo activeLearnServiceVo) { | |||
| return genericsSuccess(this.activeLearnService.edit(activeLearnServiceVo)); | |||
| } | |||
| @GetMapping("/getActiveLearnDetail") | |||
| @ApiOperation("获取主动学习详细信息") | |||
| public GenericsAjaxResult<ActiveLearnVo> getActiveLearnDetail(@RequestParam("id") Long id) throws IOException { | |||
| return genericsSuccess(this.activeLearnService.getActiveLearnDetail(id)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除主动学习") | |||
| public GenericsAjaxResult<String> deleteActiveLearn(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.activeLearnService.delete(id)); | |||
| } | |||
| @PostMapping("/run/{id}") | |||
| @ApiOperation("运行主动学习实验") | |||
| public GenericsAjaxResult<String> runActiveLearn(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.activeLearnService.runActiveLearnIns(id)); | |||
| } | |||
| } | |||
| @@ -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<Page<ActiveLearnIns>> 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<String> deleteById(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.activeLearnInsService.removeById(id)); | |||
| } | |||
| @DeleteMapping("batchDelete") | |||
| @ApiOperation("批量删除实验实例") | |||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Long> ids) { | |||
| return genericsSuccess(this.activeLearnInsService.batchDelete(ids)); | |||
| } | |||
| @PutMapping("{id}") | |||
| @ApiOperation("终止实验实例") | |||
| public GenericsAjaxResult<Boolean> terminateActiveLearnIns(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.activeLearnInsService.terminateActiveLearnIns(id)); | |||
| } | |||
| @GetMapping("{id}") | |||
| @ApiOperation("查看实验实例详情") | |||
| public GenericsAjaxResult<ActiveLearnIns> getDetailById(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.activeLearnInsService.getDetailById(id)); | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| @@ -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; | |||
| } | |||
| @@ -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<ActiveLearn> 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); | |||
| } | |||
| @@ -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<ActiveLearnIns> 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<ActiveLearnIns> getByActiveLearnId(@Param("activeLearnId") Long activeLearnId); | |||
| } | |||
| @@ -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<ActiveLearnIns> queryByPage(ActiveLearnIns activeLearnIns, PageRequest pageRequest) throws IOException; | |||
| ActiveLearnIns insert(ActiveLearnIns activeLearnIns); | |||
| String removeById(Long id); | |||
| String batchDelete(List<Long> ids); | |||
| boolean terminateActiveLearnIns(Long id); | |||
| ActiveLearnIns getDetailById(Long id); | |||
| } | |||
| @@ -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<ActiveLearn> 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; | |||
| } | |||
| @@ -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<ActiveLearnIns> queryByPage(ActiveLearnIns activeLearnIns, PageRequest pageRequest) throws IOException { | |||
| long total = this.activeLearnInsDao.count(activeLearnIns); | |||
| List<ActiveLearnIns> 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<Long> 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<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(activeLearnId); | |||
| List<String> 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); | |||
| } | |||
| } | |||
| } | |||
| @@ -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<ActiveLearn> queryByPage(String name, PageRequest pageRequest) { | |||
| long total = activeLearnDao.count(name); | |||
| List<ActiveLearn> 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 "执行成功"; | |||
| } | |||
| } | |||
| @@ -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); | |||
| @@ -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<String,Object> 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; | |||
| } | |||
| @@ -0,0 +1,115 @@ | |||
| <?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.ruoyi.platform.mapper.ActiveLearnDao"> | |||
| <insert id="save"> | |||
| 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}) | |||
| </insert> | |||
| <update id="edit"> | |||
| update active_learn | |||
| <set> | |||
| <if test="activeLearn.name != null and activeLearn.name !=''"> | |||
| name = #{activeLearn.name}, | |||
| </if> | |||
| <if test="activeLearn.description != null and activeLearn.description !=''"> | |||
| description = #{activeLearn.description}, | |||
| </if> | |||
| <if test="activeLearn.dataset != null and activeLearn.dataset !=''"> | |||
| dataset = #{activeLearn.dataset}, | |||
| </if> | |||
| <if test="activeLearn.targetColumns != null and activeLearn.targetColumns !=''"> | |||
| target_columns = #{activeLearn.targetColumns}, | |||
| </if> | |||
| <if test="activeLearn.classifierType != null and activeLearn.classifierType !=''"> | |||
| classifier_type = #{activeLearn.classifierType}, | |||
| </if> | |||
| <if test="activeLearn.queryBatchSize != null"> | |||
| query_batch_size = #{activeLearn.queryBatchSize}, | |||
| </if> | |||
| <if test="activeLearn.stoppingCriterion != null and activeLearn.stoppingCriterion !=''"> | |||
| stopping_criterion = #{activeLearn.stoppingCriterion}, | |||
| </if> | |||
| <if test="activeLearn.numOfQueries != null"> | |||
| num_of_queries = #{activeLearn.numOfQueries}, | |||
| </if> | |||
| <if test="activeLearn.costLimit != null"> | |||
| cost_limit = #{activeLearn.costLimit}, | |||
| </if> | |||
| <if test="activeLearn.percentOfUnlabel != null"> | |||
| percent_of_unlabel = #{activeLearn.percentOfUnlabel}, | |||
| </if> | |||
| <if test="activeLearn.timeLimit != null"> | |||
| time_limit = #{activeLearn.timeLimit}, | |||
| </if> | |||
| <if test="activeLearn.queryStrategy != null and activeLearn.queryStrategy !=''"> | |||
| query_strategy = #{activeLearn.queryStrategy}, | |||
| </if> | |||
| <if test="activeLearn.numOfExperiment != null"> | |||
| num_of_experiment = #{activeLearn.numOfExperiment}, | |||
| </if> | |||
| <if test="activeLearn.testRatio != null"> | |||
| test_ratio = #{activeLearn.testRatio}, | |||
| </if> | |||
| <if test="activeLearn.initialLabelRate != null"> | |||
| initial_label_rate = #{activeLearn.initialLabelRate}, | |||
| </if> | |||
| <if test="activeLearn.performanceMetric != null and activeLearn.performanceMetric !=''"> | |||
| performance_metric = #{activeLearn.performanceMetric}, | |||
| </if> | |||
| <if test="activeLearn.updateBy != null and activeLearn.updateBy !=''"> | |||
| update_by = #{activeLearn.updateBy}, | |||
| </if> | |||
| <if test="activeLearn.statusList != null and activeLearn.statusList !=''"> | |||
| status_list = #{activeLearn.statusList}, | |||
| </if> | |||
| <if test="activeLearn.state != null"> | |||
| state = #{activeLearn.state}, | |||
| </if> | |||
| </set> | |||
| where id = #{activeLearn.id} | |||
| </update> | |||
| <select id="count" resultType="java.lang.Long"> | |||
| select count(1) from active_learn | |||
| <include refid="common_condition"></include> | |||
| </select> | |||
| <select id="queryByPage" resultType="com.ruoyi.platform.domain.ActiveLearn"> | |||
| select * from active_learn | |||
| <include refid="common_condition"></include> | |||
| </select> | |||
| <select id="getActiveLearnByName" resultType="com.ruoyi.platform.domain.ActiveLearn"> | |||
| select * | |||
| from active_learn | |||
| where name = #{name} | |||
| and state = 1 | |||
| </select> | |||
| <select id="getActiveLearnById" resultType="com.ruoyi.platform.domain.ActiveLearn"> | |||
| select * | |||
| from active_learn | |||
| where id = #{id} | |||
| </select> | |||
| <sql id="common_condition"> | |||
| <where> | |||
| state = 1 | |||
| <if test="name != null and name != ''"> | |||
| and name like concat('%', #{name}, '%') | |||
| </if> | |||
| </where> | |||
| </sql> | |||
| </mapper> | |||
| @@ -0,0 +1,65 @@ | |||
| <?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.ruoyi.platform.mapper.ActiveLearnInsDao"> | |||
| <insert id="insert"> | |||
| 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}) | |||
| </insert> | |||
| <update id="update"> | |||
| update active_learn_ins | |||
| <set> | |||
| <if test="activeLearnIns.state != null"> | |||
| state = #{activeLearnIns.state}, | |||
| </if> | |||
| <if test="activeLearnIns.updateTime != null"> | |||
| update_time = #{activeLearnIns.updateTime}, | |||
| </if> | |||
| <if test="activeLearnIns.finishTime != null"> | |||
| finish_time = #{activeLearnIns.finishTime}, | |||
| </if> | |||
| <if test="activeLearnIns.status != null and activeLearnIns.status != ''"> | |||
| status = #{activeLearnIns.status}, | |||
| </if> | |||
| <if test="activeLearnIns.resultPath != null and activeLearnIns.resultPath != ''"> | |||
| result_path = #{activeLearnIns.resultPath}, | |||
| </if> | |||
| </set> | |||
| where id = #{activeLearnIns.id} | |||
| </update> | |||
| <select id="count" resultType="java.lang.Long"> | |||
| select count(1) | |||
| from active_learn_ins | |||
| <where> | |||
| state = 1 | |||
| and active_learn_id = #{autoMlIns.activeLearnId} | |||
| </where> | |||
| </select> | |||
| <select id="queryAllByLimit" resultType="com.ruoyi.platform.domain.ActiveLearnIns"> | |||
| select * from active_learn_ins | |||
| <where> | |||
| state = 1 | |||
| and active_learn_id = #{autoMlIns.activeLearnId} | |||
| </where> | |||
| order by update_time DESC | |||
| limit #{pageable.offset}, #{pageable.pageSize} | |||
| </select> | |||
| <select id="queryById" resultType="com.ruoyi.platform.domain.ActiveLearnIns"> | |||
| select * from active_learn_ins | |||
| <where> | |||
| state = 1 and id = #{id} | |||
| </where> | |||
| </select> | |||
| <select id="getByActiveLearnId" resultType="com.ruoyi.platform.domain.ActiveLearnIns"> | |||
| select * | |||
| from active_learn_ins | |||
| where active_learn_id = #{activeLearnId} | |||
| and state = 1 | |||
| order by update_time DESC limit 5 | |||
| </select> | |||
| </mapper> | |||
| @@ -105,6 +105,9 @@ | |||
| <if test="autoMl.targetColumns != null and autoMl.targetColumns !=''"> | |||
| target_columns = #{autoMl.targetColumns}, | |||
| </if> | |||
| <if test="autoMl.updateBy != null and autoMl.updateBy !=''"> | |||
| update_by = #{autoMl.updateBy}, | |||
| </if> | |||
| <if test="autoMl.state != null"> | |||
| state = #{autoMl.state}, | |||
| </if> | |||