Ver código fonte

[task-1853] 性能验证模块 开发 (二期) / 线性区间验证:WST 408

Li Yuan 1 ano atrás
pai
commit
30407a49f4

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/funcs/TestFuncs.java

@@ -38,7 +38,7 @@ public class TestFuncs {
 
         System.out.println("R方为" + po.getRSquared());
         System.out.println("调整R方为" + po.getAdjRSquared());
-        System.out.println(po.getFunction());
+        System.out.println(po.getFunction(3));
         System.out.println("标准误为:" + Arrays.toString(po.getStdErrors()));
 
         System.out.println("f值:" + po.getFValue());

+ 1 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeADLPctBnd.java

@@ -199,6 +199,7 @@ public class LinearRangeADLPctBnd extends PVModel {
             i++;
         }
         table.buildData(r);
+        table.setNote(String.format("最优拟合方程是%s阶方程  %s",getBestName(),prBest.getFunction(getScale())));
         return table;
     }
     @Override

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeAverageSlope.java

@@ -85,7 +85,7 @@ public class LinearRangeAverageSlope extends PVModel {
         Map<String, Object> map = new HashMap<>();
         map.put("data", JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect));
 
-        chartDTO.setOption(renderChartTemplate(map, 0, "/scatter/polynomialRegression.ftl"));
+        chartDTO.setOption(renderChartTemplate(map, 0, "/scatter/linearRegression.ftl"));
         return chartDTO;
     }
     public TableDTO buildDataTableDTO() {

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/model2/LinearRangeEP6A.java

@@ -173,7 +173,7 @@ public class LinearRangeEP6A extends PVModel {
         config.put("yAxisLow", -0.1);
         config.put("data", JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect));
 
-        chartDTO.setOption(renderChartTemplate(config, 1, "/scatter/linesForRange.ftl"));
+        chartDTO.setOption(renderChartTemplate(config, 1, "/scatter/linearRangeEP6A.ftl"));
         return chartDTO;
     }
 

+ 8 - 8
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/regression/PolynomialRegression.java

@@ -86,22 +86,22 @@ public class PolynomialRegression extends Regression {
     }
 
 
-    public String getFunction() {
+    public String getFunction(int scale) {
         if (!this.isHasData()) {
             return "未构造数据";
         }
         final double[] parameters = this.getParameters();
         StringBuilder function = new StringBuilder("y =  ");
         for (int i = 0; i < parameters.length; i++) {
-            function.append(parameters[i]);
-            for (int j = 0; j < i; j++) {
-                function.append(" x ");
-                if (j != (i - 1)) {
-                    function.append("*");
+            function.append(Double.parseDouble(String.format("%." + scale + "f", parameters[i])));
+//            for (int j = 0; j < i; j++) {
+                function.append("x");
+                if (i - 1 > 0) {
+                    function.append(String.format("<sup>%d</sup>",i));
                 }
-            }
+//            }
             if (i != (parameters.length - 1)) {
-                function.append(" + ");
+                function.append(parameters[i+1]>0?"+":"");
             }
 
         }

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/regression/StatisticsTest.java

@@ -74,7 +74,7 @@ public class StatisticsTest {
 
         System.out.println("R方为" + po.getRSquared());
         System.out.println("调整R方为" + po.getAdjRSquared());
-        System.out.println(po.getFunction());
+        System.out.println(po.getFunction(3));
         System.out.println("标准误为:" + Arrays.toString(po.getStdErrors()));
 
         System.out.println("f值:" + po.getFValue());

+ 5 - 13
ibps-provider-root/modules/provider-business/src/main/resources/pv/report/linearRangeADL.ftl

@@ -1,18 +1,10 @@
 进行t检验后表明
-<#if !pr3.isNonlinear() && !pr2.isNonlinear() >
-三阶和二阶系数都无统计学意义(p>0.05),数据组符合统计学标准的线性。对数据组进行精密度检验。
+<#if !pr3.isNonlinear() && !pr2.isNonlinear() >三阶和二阶系数都无统计学意义(p&gt;0.05),数据组符合统计学标准的线性。对数据组进行精密度检验。
 <#else>
-    <#if pr2.isNonlinear()>
-二阶系数有统计学意义(p<0.05),
-    <#else>
-二阶系数无统计学意义(p>0.05),
-    </#if>
-    <#if pr3.isNonlinear()>
-三阶系数有统计学意义(p<0.05),
-    <#else>
-三阶系数无统计学意义(p>0.05),
-    </#if>
-数据拟合结果是统计学标准的非线性。对数据组进行非线性程度判断及测定精密度检验。
+    <#if pr2.isNonlinear()>二阶系数有统计学意义(p&lt;0.05),<#else>二阶系数无统计学意义(p&gt;0.05),</#if>
+    <#if pr3.isNonlinear()>三阶系数有统计学意义(p&lt;0.05),<#else>三阶系数无统计学意义(p&gt;0.05),</#if>
+    数据拟合结果是统计学标准的非线性。对数据组进行非线性程度判断及测定精密度检验。
 </#if>
+<br />
 计算最佳拟合回归标准误σ=${prBest.stdError},总平均浓度=${mean},不精密度百分比=${cv}%。
 由ADL计算公式得ADL=${adl}%。${rangeFormat}

+ 0 - 0
ibps-provider-root/modules/provider-business/src/main/resources/pv/scatter/linesForRange.ftl → ibps-provider-root/modules/provider-business/src/main/resources/pv/scatter/linearRangeEP6A.ftl


+ 28 - 11
ibps-provider-root/modules/provider-business/src/main/resources/pv/scatter/linearRegression.ftl

@@ -5,33 +5,49 @@
     },
     {
       transform: {
-        type: 'ecStat:regression'
+        type: 'ecStat:regression',
+        config: {
+          method: 'polynomial',
+          order: 1
+        }
       }
     }
   ],
   title: {
     text: 'Linear Regression',
-    subtext: 'By ecStat.regression',
-    sublink: 'https://github.com/ecomfe/echarts-stat',
-    left: 'center'
-  },
-  legend: {
-    bottom: 5
+    left: 'center',
+    top: 8,
+    textStyle: {
+      fontSize: 14,
+      fontWeight: 'bold',
+      color: '#333'
+    }
   },
   tooltip: {
-    trigger: 'axis',
+    trigger: 'item',
     axisPointer: {
       type: 'cross'
     }
   },
   xAxis: {
+    name: '实际浓度',
+    nameLocation: 'center',
+    nameTextStyle: {
+      fontSize: 14
+    },
+    nameGap: 20,
     splitLine: {
-      lineStyle: {
-        type: 'dashed'
-      }
+      show: false
     }
   },
   yAxis: {
+    name: '测量浓度均值',
+    nameLocation: 'center',
+    nameTextStyle: {
+      fontSize: 14
+    },
+    nameGap: 30,
+    min: 0,
     splitLine: {
       lineStyle: {
         type: 'dashed'
@@ -46,6 +62,7 @@
     {
       name: 'line',
       type: 'line',
+      smooth: true,
       datasetIndex: 1,
       symbolSize: 0.1,
       symbol: 'circle',

+ 100 - 107
ibps-provider-root/modules/provider-business/src/main/resources/pv/scatter/polynomialRegression.ftl

@@ -1,122 +1,115 @@
 {
-  grid: {
-    left: '2%',
-    right: '2%',
-    bottom: '12%',
-    top: '12%',
-    containLabel: true
-  },
-  dataset: [
-    {
-      source: '${data}'
-    },
-    {
-      transform: {
-        type: 'ecStat:regression',
-        config: {
-          method: 'polynomial',
-          order: 1
+    dataset: [
+      {
+        source: ${data}
+      },
+      {
+        transform: {
+          type: 'ecStat:regression',
+          config: {
+            method: 'polynomial',
+            order: 1
+          }
         }
       }
-    }
-<#if (power > 1) >
-    ,{
-      transform: {
-        type: 'ecStat:regression',
-        config: {
-          method: 'polynomial',
-          order: ${power}
+  <#if power gt 1 >
+      ,{
+        transform: {
+          type: 'ecStat:regression',
+          config: {
+            method: 'polynomial',
+            order: ${power}
+          }
         }
       }
-    }
-</#if>
-  ],
-  title: {
-    text: '线性回归图',
-    subtext: '',
-    sublink: '',
-    left: 'center',
-    top: 8,
-    textStyle: {
-      fontSize: 14,
-      fontWeight: 'bold',
-      color: '#333'
-    }
-  },
-  tooltip: {
-    trigger: 'axis',
-    axisPointer: {
-      type: 'cross'
-    }
-  },
-  xAxis: {
-    name: 'x轴',
-    nameLocation: 'center',
-    nameTextStyle: {
-      fontSize: 14
-    },
-    nameGap: 20,
-    splitLine: {
-      show: false
-    }
-  },
-  yAxis: {
-    name: 'y轴',
-    nameLocation: 'center',
-    nameTextStyle: {
-      fontSize: 14
+  </#if>
+    ],
+    title: {
+      text: '线性回归图',
+      subtext: '',
+      sublink: '',
+      left: 'center',
+      top: 8,
+      textStyle: {
+        fontSize: 14,
+        fontWeight: 'bold',
+        color: '#333'
+      }
     },
-    nameGap: 20,
-    min: 0,
-    splitLine: {
-      lineStyle: {
-        type: 'dashed'
+    tooltip: {
+      trigger: 'axis',
+      axisPointer: {
+        type: 'cross'
       }
-    }
-  },
-  series: [
-    {
-      name: 'scatter',
-      type: 'scatter'
     },
-    {
-      name: 'line',
-      type: 'line',
-      smooth: true,
-      datasetIndex: 1,
-      symbolSize: 0.1,
-      symbol: 'circle',
-      label: {
-        show: true,
-        fontSize: 18
+    xAxis: {
+      name: '实际浓度',
+      nameLocation: 'center',
+      nameTextStyle: {
+        fontSize: 14
       },
-      labelLayout: {
-        x: 100
+      nameGap: 20,
+      splitLine: {
+        show: false
+      }
+    },
+    yAxis: {
+      name: '测量浓度均值',
+      nameLocation: 'center',
+      nameTextStyle: {
+        fontSize: 14
       },
-      encode: {
-        label: 2,
-        tooltip: 1
+      nameGap: 20,
+      min: 0,
+      splitLine: {
+        lineStyle: {
+          type: 'dashed'
+        }
       }
     },
-    {
-      name: 'line2',
-      type: 'line',
-      smooth: true,
-      datasetIndex: 2,
-      symbolSize: 0.1,
-      symbol: 'circle',
-      label: {
-        show: true,
-        fontSize: 18
+    series: [
+      {
+        name: '均值',
+        type: 'scatter'
       },
-      labelLayout: {
-        x: 100,
-        dy: 20
+      {
+        name: '1阶',
+        type: 'line',
+        smooth: true,
+        datasetIndex: 1,
+        symbolSize: 0.1,
+        symbol: 'circle',
+        label: {
+          show: true,
+          fontSize: 16
+        },
+        labelLayout: {
+          x: 100
+        },
+        encode: {
+          label: 2,
+          tooltip: 1
+        }
       },
-      encode: {
-        label: 2,
-        tooltip: 1
+      {
+        name: '${power}阶',
+        type: 'line',
+        smooth: true,
+        datasetIndex: 2,
+        symbolSize: 0.1,
+        symbol: 'circle',
+        label: {
+          show: true,
+          fontSize: 16
+        },
+        labelLayout: {
+          x: 100,
+          dy: 20
+        },
+        encode: {
+          label: 2,
+          tooltip: 1
+        }
       }
-    }
-  ]
-}
+    ]
+  }