feat: 数据预测
This commit is contained in:
@@ -22,14 +22,14 @@
|
||||
</el-popover>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="content" v-loading="forecastLoading">
|
||||
<div class="left">
|
||||
<BaseTable ref="inputTableRef" tableName="DATA_FORECAST_INPUT" showIndex :actionsWidth="200" hidePagination>
|
||||
<template #type>
|
||||
输入
|
||||
</template>
|
||||
<template #value="{ row }">
|
||||
<el-input
|
||||
<el-input-number
|
||||
v-model="row.value"
|
||||
placeholder="请输入内容"
|
||||
/>
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getModelTrainingListApi, startPredictApi, getModelPredictResultApi } from '@/api/data/dataForecast';
|
||||
import { getModelTrainingListApi, startPredictApi, getModelPredictResultApi, getHandleLoadDataResultApi } from '@/api/data/dataForecast';
|
||||
import BaseTable from '@/components/common/table/baseTable.vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import type{ Ref } from 'vue';
|
||||
@@ -87,19 +87,22 @@ const queryModelListFun = async () => {
|
||||
};
|
||||
};
|
||||
|
||||
const onModelChangeFun = (val: Model) => {
|
||||
const onModelChangeFun = async (val: Model) => {
|
||||
selectedModel.value = val;
|
||||
const sourceTitleMap = await getTitleMapFun();
|
||||
if (selectedModel.value.inputLabel) {
|
||||
const inputData = JSON.parse(selectedModel.value.inputLabel);
|
||||
const inputTableData = inputData.map((item: any) => {
|
||||
return {
|
||||
name: item,
|
||||
label: sourceTitleMap[item] || item,
|
||||
};
|
||||
});
|
||||
const outputData = JSON.parse(selectedModel.value.outputLabel);
|
||||
const outputData = JSON.parse(selectedModel.value.outputLabel || '[]');
|
||||
const outputTableData = outputData.map((item: any) => {
|
||||
return {
|
||||
name: item,
|
||||
label: sourceTitleMap[item] || item,
|
||||
};
|
||||
});
|
||||
inputTableRef.value?.setDataFun(inputTableData);
|
||||
@@ -130,13 +133,76 @@ const beginForecastFun = async () => {
|
||||
forecastLoading.value = false;
|
||||
if (res.code === 200) {
|
||||
getModelPredictResultFun();
|
||||
} else {
|
||||
clearResultFun();
|
||||
}
|
||||
};
|
||||
|
||||
const getTitleMapFun = async () => {
|
||||
const req = {
|
||||
modelId: selectedModel.value.id,
|
||||
};
|
||||
const res: any = await getHandleLoadDataResultApi(req);
|
||||
if (res.code === 200 && res.data) {
|
||||
if (Array.isArray(res.data?.source_title)) {
|
||||
const titleMap: Record<string, string> = {};
|
||||
res.data?.source_title.forEach((item: Record<string, string>) => {
|
||||
Object.keys(item).forEach((key:string) => {
|
||||
titleMap[key] = item[key];
|
||||
});
|
||||
});
|
||||
return titleMap;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
const clearResultFun = () => {
|
||||
const inputData = inputTableRef.value?.tableData;
|
||||
const outputData = outputTableRef.value?.tableData;
|
||||
const inputDataFormatted = inputData.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
value: '',
|
||||
};
|
||||
});
|
||||
const outputDataFormatted = outputData.map((item: any ) => {
|
||||
return {
|
||||
...item,
|
||||
value: '',
|
||||
};
|
||||
});
|
||||
inputTableRef.value?.setDataFun(inputDataFormatted);
|
||||
outputTableRef.value?.setDataFun(outputDataFormatted);
|
||||
};
|
||||
const getModelPredictResultFun = async () => {
|
||||
forecastLoading.value = true;
|
||||
const res: any = await getModelPredictResultApi({ modelId: selectedModel.value.id });
|
||||
forecastLoading.value = false;
|
||||
if (res.code === 200 && res.data) {
|
||||
// 处理预测结果
|
||||
const inputData = inputTableRef.value?.tableData;
|
||||
const outputData = outputTableRef.value?.tableData;
|
||||
const inputPredLabelValue = res.data?.inputPredLabelValue || [];
|
||||
const forecastValue = res.data?.outputPredLabelValue;
|
||||
const inputDataFormatted = inputData.map((item: any) => {
|
||||
const inputValue = inputPredLabelValue.find((inputItem: any) => inputItem.name === item.name);
|
||||
return {
|
||||
...item,
|
||||
value: inputValue.value || '',
|
||||
};
|
||||
});
|
||||
const outputDataFormatted = outputData.map((item: any ) => {
|
||||
return {
|
||||
...item,
|
||||
value: forecastValue ? forecastValue[item.name] : '',
|
||||
};
|
||||
});
|
||||
inputTableRef.value?.setDataFun(inputDataFormatted);
|
||||
outputTableRef.value?.setDataFun(outputDataFormatted);
|
||||
} else {
|
||||
clearResultFun();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user