Commit 061f6de1 authored by whlviolin's avatar whlviolin

增加线性回归和lasso回归两种方式

parent ecd30789
<template>
<div style="height:100%;width:100%">
<div style="height: 100%;position:relative;" >
<div style="height:41px;line-height:41px; font-size:16px;font-weight:600;border-bottom:1px solid #e3e3e3">
<span style="margin-left:30px">{{algoName}}</span>
</div>
<div v-if="loading" style="position: absolute; top: 41px; right:0px; left:0px; bottom:0px;overflow: scroll;">
<div style="padding-bottom: 100px;">
<div style="width: 100%; height:80px;margin:10px 30px;">
<span style="font-weight:600;font-size:14px">算法结果描述</span>
</div>
<div class="dynamicComp">
<div v-for="(item,idx) in compDataList">
<!-- <component :is="item.type"></component>-->
<div style="margin:30px">
<span style="font-weight:600;font-size:14px">{{item.name}}</span>
</div>
<div v-if="item.name=='模型结果图'">
<div style="height:400px; display: flex;flex-direction: column; align-content: center;justify-content: center; align-items: center;">
<vab-chart autoresize :options="fwl" :style="{'width': '100%', 'height':'100%'}" />
</div>
</div>
<div v-else>
<el-table
border
height="100%"
:data=decimalNumberPrecision(item.header,item.value)
:style="{'width': '100%','margin':'30px'}">
<template v-for="item1 in item.header">
<el-table-column
:prop="item1"
align="center"
:label="item1"
:sortable="true"
min-width="200">
</el-table-column>
</template>
</el-table>
</div>
<div style="margin:15px">
<div style="font-weight:600;font-size: 14px;margin:10px 15px;">图表说明:</div>
<div style="white-space: pre-wrap;font-size: 14px;margin:10px 15px;line-height:1.8">{{item.chartText}}</div>
</div>
<div style="margin:15px" v-if="item.displayAnalysisText==true">
<div style="font-weight:600;font-size: 14px;margin:10px 15px;">智能分析:</div>
<div style="white-space: pre-wrap;font-size: 14px;margin:10px 15px;line-height:1.8">{{item.analysisText}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import {getOptionByLasso, getOptionByDEA} from "@/utils/echartsUtil"
import * as echarts from 'echarts';
import VabChart from '@/plugins/echarts'
import {forEach} from "lodash/fp/_util";
//引入echarts
export default {
name: 'lasso',
props: {
algoName: {
},
algoRes: {
},
algoParams:{
},
},
components: {
VabChart
},
data() {
return {
compDataList:[],
fwl: {},
quadrant:{},
displayAnalysisText: false,
loading: false,
}
},
mounted() {
debugger;
this.initData();
},
methods: {
initData() {
debugger;
let data=JSON.parse(this.algoRes)
console.log(this.algoRes)
let params = []
this.algoParams.forEach(function(algoParam) {
algoParam.forEach(function (param) {
params.push(param["name"])
})
});
params.unshift("截距");
this.loading = true;
let newHeader=[]
for(let i in data) {
let item = data[i]
let header = Object.keys(item.value)
if(item.name.indexOf('模型系数表') >= 0 || item.name.indexOf('模型结果预测') >= 0){
let data1 =this.resultToJsonObjectArray(header, item.value, params)
if(item.name.indexOf('模型系数表') >= 0){
item["displayAnalysisText"] =true;
}
item['header'] = header
item['value'] = data1
this.compDataList.push(item)
}
if(item.name.indexOf('模型结果图') >= 0){
this.fwl =getOptionByLasso(item)
this.compDataList.push(item)
}
if(item.text["图表说明"]!==undefined){
item["chartText"]=item.text["图表说明"].replaceAll('\n','\n● ')
item["analysisText"]=item.text["智能分析"].replaceAll('\n','\n● ')
}else{
item["chartText"]=item.text.replaceAll('\n','\n● ')
}
}
},
decimalNumberPrecision(headers, datas){
datas.forEach(function(data) {
headers.forEach(function (header) {
let value = data[header];
if (typeof value === 'number')
data[header] = value.toFixed(3)
});
});
return datas
},
resultToJsonObjectArray(keys, values, params) {
let rows = [];
let p = values[keys[0]];
let indexs = [];
for(let m = 0; m<p.length; m++){
if(params.indexOf(p[m])>-1){
indexs.push(m);
}
}
let item = values[keys[1]]
for (let j = 0; j < Object.keys(item).length; j++) {
if(indexs.indexOf(j)>-1){
let key = Object.keys(item)[j]
let row = {}
for (let i = 0; i < keys.length; i++) {
if(keys[i]== "R²"){
row[keys[i]] = values["R²"]
}else{
let key1 = keys[i];
let value = values[key1][key];
row[key1] =value
}
}
rows.push(row)
}
}
return rows;
},
}
}
</script>
<style scoped>
</style>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment