Browse Source

负相关时使用maxValue-k*(xi-min)

dev_shibei_match
jianjun 4 years ago
parent
commit
d306d011df
  1. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreCalculator.java
  2. 21
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java
  3. 16
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreCalculator.java

@ -76,16 +76,14 @@ public abstract class ScoreCalculator<T> {
throw new RuntimeException("入参数组错误:请设置sourceValue");
}
BigDecimal x = coefficient.multiply(convertValue2BigDecimal(sourceValue).subtract(minValue));
if (correlation == Correlation.POSITIVE) {
// 正相关
BigDecimal x = coefficient.multiply(convertValue2BigDecimal(sourceValue).subtract(minValue));
BigDecimal score = minScore.add(x);
return score;
} else if (correlation == Correlation.NEGATIVE) {
// 负相关
BigDecimal x = coefficient.multiply(convertValue2BigDecimal(sourceValue).subtract(minValue));
BigDecimal score = minScore.add(x);
return maxScore.subtract(score, MathContext.DECIMAL32);
return maxScore.subtract(x, MathContext.DECIMAL32);
} else {
throw new RuntimeException("错误的相关性");
}

21
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/batch/BatchScoreCalculator.java

@ -76,19 +76,24 @@ public class BatchScoreCalculator {
if (idx.getScoreCalculator().getMaxValue().compareTo(idx.getScoreCalculator().getMinValue()) == 0) {
//*((max-min)/ (Math.PI/2))+min
//Math.atan(new Double(vo.getSampleValue().toString()))*
normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString())))
.multiply(
(maxScoreValue.subtract(minScoreValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP)))
.add(minScoreValue).setScale(6, RoundingMode.HALF_UP);
if (Correlation.POSITIVE.getCode().equals(scoreCalculator.getCorrelation().getCode())) {
normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString())))
.multiply(
(maxScoreValue.subtract(minScoreValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP)))
.add(minScoreValue).setScale(6, RoundingMode.HALF_UP);
}else{
normalizeValue = new BigDecimal(Math.atan(new Double(getFinalSampleValue(vo.getSampleValue(), threshold).toString())))
.multiply(
(maxScoreValue.subtract(minScoreValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP)).multiply(new BigDecimal(-1)))
.add(maxScoreValue).setScale(6, RoundingMode.HALF_UP);
}
} else {
normalizeValue = scoreCalculator.normalize(getFinalSampleValue(vo.getSampleValue(), threshold));
}
//如果是负相关 则用100-归一后的值为最大值减
/* //如果是负相关 则用100-归一后的值为最大值减
if (Correlation.NEGATIVE.getCode().equals(scoreCalculator.getCorrelation().getCode())) {
normalizeValue = maxScoreValue.subtract(normalizeValue);
}
}*/
}
//如果归一后的值小于0 则置为0
if (normalizeValue.compareTo(NumConstant.ZERO_DECIMAL)<=-1){

16
epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/normalizing/MathUtilTest.java

@ -20,10 +20,20 @@ public class MathUtilTest {
BigDecimal maxValue = new BigDecimal(100);
BigDecimal minValue = new BigDecimal(60);
BigDecimal normalizeValue = new BigDecimal(Math.atan(new Double("0")))
.multiply(
(maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP))).add(minValue).setScale(6, RoundingMode.HALF_UP);
//((max-min)/ (Math.PI/2))+min
BigDecimal sampleValue = new BigDecimal(Math.atan(new Double("0")));
BigDecimal normalizeValue = sampleValue
.multiply(maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP))
.add(minValue).setScale(6, RoundingMode.HALF_UP);
BigDecimal normalizeValue2 = sampleValue
.multiply(maxValue.subtract(minValue).divide(new BigDecimal(Math.PI / 2), 10, RoundingMode.HALF_UP).multiply(new BigDecimal(-1)))
.add(maxValue).setScale(6, RoundingMode.HALF_UP);
System.out.println(normalizeValue);
System.out.println(normalizeValue2);
//new BigDecimal(Math.atan(new Double(vo.getSampleValue().toString())) / Math.PI * 100).setScale(6, RoundingMode.HALF_UP);
}

Loading…
Cancel
Save