Browse Source

Merge remote-tracking branch 'origin/dev_screen_data' into dev_screen_data

master
yinzuomei 5 years ago
parent
commit
019031d4de
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/DoubleScoreCalculator.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/IntegerScoreCalculator.java
  3. 46
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/ScoreCalculator.java

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/DoubleScoreCalculator.java

@ -17,7 +17,7 @@ public class DoubleScoreCalculator extends ScoreCalculator {
* @param correlation 相关性 * @param correlation 相关性
*/ */
public DoubleScoreCalculator(Double[] sourceArray, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) { public DoubleScoreCalculator(Double[] sourceArray, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) {
this.sourceArrary = sourceArray; this.sourceArrary = sourceArray.clone();
this.minScore = minScore; this.minScore = minScore;
this.maxScore = maxScore; this.maxScore = maxScore;
this.correlation = correlation; this.correlation = correlation;

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/support/normalizing/IntegerScoreCalculator.java

@ -17,7 +17,7 @@ public class IntegerScoreCalculator extends ScoreCalculator {
* @param correlation 相关性 * @param correlation 相关性
*/ */
public IntegerScoreCalculator(Integer[] sourceArray, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) { public IntegerScoreCalculator(Integer[] sourceArray, BigDecimal minScore, BigDecimal maxScore, Correlation correlation) {
this.sourceArrary = sourceArray; this.sourceArrary = sourceArray.clone();
this.minScore = minScore; this.minScore = minScore;
this.maxScore = maxScore; this.maxScore = maxScore;
this.correlation = correlation; this.correlation = correlation;

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

@ -6,6 +6,7 @@ import java.util.Arrays;
/** /**
* 所有数据类型计算器的父类实现算法骨架数据类型转换方法则由子类实现 * 所有数据类型计算器的父类实现算法骨架数据类型转换方法则由子类实现
* 如果需要保持传入的数组元素顺序不变请在实现类的构造方法中将传入数组进行克隆
* @param <T> 数据类型泛型 * @param <T> 数据类型泛型
*/ */
public abstract class ScoreCalculator<T> { public abstract class ScoreCalculator<T> {
@ -38,7 +39,7 @@ public abstract class ScoreCalculator<T> {
} }
/** /**
* 归一算法 * 单值归一算法
* @return * @return
*/ */
public BigDecimal normalize(T sourceValue) { public BigDecimal normalize(T sourceValue) {
@ -66,6 +67,49 @@ public abstract class ScoreCalculator<T> {
} }
} }
/**
* 单值归一算法带权重
* @param sourceValue
* @param weight
* @return
*/
public BigDecimal normalize(T sourceValue, BigDecimal weight) {
return normalize(sourceValue).multiply(weight);
}
/**
* 批量归一算法
* @param sourceValues
* @return
*/
public BigDecimal[] normalize(T[] sourceValues) {
BigDecimal[] scores = new BigDecimal[sourceValues.length];
for (int i=0;i<sourceValues.length;i++) {
BigDecimal score = normalize(sourceValues[i]);
scores[i] = score;
}
return scores;
}
/**
* 批量归一算法带权重
* @param sourceValues
* @param weight
* @return
*/
public BigDecimal[] normalize(T[] sourceValues, BigDecimal weight) {
BigDecimal[] scores = new BigDecimal[sourceValues.length];
for (int i=0;i<sourceValues.length;i++) {
BigDecimal score = normalize(sourceValues[i]);
scores[i] = score.multiply(weight);
}
return scores;
}
/** /**
* 校验数组 * 校验数组
* @param sourceArray * @param sourceArray

Loading…
Cancel
Save