|
|
|
@ -4,6 +4,7 @@ import com.epmet.support.normalizing.*; |
|
|
|
import com.epmet.support.normalizing.batch.BatchScoreCalculator; |
|
|
|
import com.epmet.support.normalizing.batch.IndexInputVO; |
|
|
|
import com.epmet.support.normalizing.batch.IndexOutputVO; |
|
|
|
import com.epmet.support.normalizing.batch.SampleValue; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
@ -24,10 +25,8 @@ public class DemoScoreCal { |
|
|
|
@Test |
|
|
|
public void demoInteger() { |
|
|
|
Integer[] iArray = {4, 8, 1, 3, 2}; |
|
|
|
BigDecimal minScore = new BigDecimal(5); |
|
|
|
BigDecimal maxScore = new BigDecimal(10); |
|
|
|
|
|
|
|
ScoreCalculator sc = new IntegerScoreCalculator(iArray, minScore, maxScore, Correlation.NEGATIVE); |
|
|
|
ScoreCalculator sc = new IntegerScoreCalculator(iArray, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE); |
|
|
|
BigDecimal[] scores = sc.normalize(iArray); |
|
|
|
Arrays.stream(scores).forEach(s -> System.out.println(s)); |
|
|
|
} |
|
|
|
@ -38,10 +37,8 @@ public class DemoScoreCal { |
|
|
|
@Test |
|
|
|
public void demoIntegerPartical() { |
|
|
|
Integer[] iArray = {4, 1, 8}; |
|
|
|
BigDecimal minScore = new BigDecimal(5); |
|
|
|
BigDecimal maxScore = new BigDecimal(10); |
|
|
|
|
|
|
|
ScoreCalculator sc = new IntegerScoreCalculator(1, 8, minScore, maxScore, Correlation.NEGATIVE); |
|
|
|
ScoreCalculator sc = new IntegerScoreCalculator(1, 8, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE); |
|
|
|
BigDecimal[] scores = sc.normalize(iArray);// 此处也可以直接使用list参数的重载方法,计算阶段没有任何区别,区别在于new IntegerScoreCalculator()阶段
|
|
|
|
Arrays.stream(scores).forEach(s -> System.out.println(s)); |
|
|
|
} |
|
|
|
@ -76,9 +73,12 @@ public class DemoScoreCal { |
|
|
|
ScoreCalculator<Integer> sc1 = new IntegerScoreCalculator(1, 8, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE); |
|
|
|
ScoreCalculator<Integer> sc2 = new IntegerScoreCalculator(1, 8, ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE); |
|
|
|
|
|
|
|
List<SampleValue<Integer>> index1SampleValues = Arrays.asList(new SampleValue<>("id1", 4), new SampleValue<>("id2", 1), new SampleValue<>("id3", 8)); |
|
|
|
List<SampleValue<Integer>> index2SampleValues = Arrays.asList(new SampleValue<>("id1", 1), new SampleValue<>("id2", 8), new SampleValue<>("id3", 3)); |
|
|
|
|
|
|
|
// 每个指标的信息,包括样本列表,权重,指标标记
|
|
|
|
IndexInputVO<Integer> index1VO = new IndexInputVO<>("aaa", Arrays.asList(4, 1, 8), new BigDecimal(1), sc1); |
|
|
|
IndexInputVO<Integer> index2VO = new IndexInputVO<>("bbb", Arrays.asList(1, 8, 3), new BigDecimal(1), sc2); |
|
|
|
IndexInputVO<Integer> index1VO = new IndexInputVO<>("aaa", index1SampleValues, new BigDecimal(1), sc1); |
|
|
|
IndexInputVO<Integer> index2VO = new IndexInputVO<>("bbb", index2SampleValues, new BigDecimal(1), sc2); |
|
|
|
|
|
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO); |
|
|
|
|
|
|
|
|