|
|
@ -257,5 +257,33 @@ public class DemoScoreCal { |
|
|
|
System.err.println("-----------------2222222222---------------"); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testMath() { |
|
|
|
// 每个指标需要单独的分支计算器,因为每个指标的最大最小值是不同的
|
|
|
|
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(new BigDecimal(8), new BigDecimal(8), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); |
|
|
|
ScoreCalculator<Integer> sc2 = new BigDecimalScoreCalculator(new BigDecimal(10), new BigDecimal(10), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); |
|
|
|
|
|
|
|
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", "a:bbb2", index1SampleValues, new BigDecimal(10), new BigDecimal(1), false, sc1); |
|
|
|
IndexInputVO<Integer> index2VO = new IndexInputVO<>("bbb", "a:bbb2", index2SampleValues, new BigDecimal(10), new BigDecimal(1), false, sc2); |
|
|
|
|
|
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO); |
|
|
|
|
|
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
|
HashMap<String, CalculateResult> result = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); |
|
|
|
|
|
|
|
System.err.println("--------------------------------"); |
|
|
|
result.forEach((key, value) -> { |
|
|
|
System.out.println(key.concat("的总得分为:") + value.getTotalScore()); |
|
|
|
//System.out.println(JSON.toJSONString(indexInputVOS));
|
|
|
|
value.getDetails().forEach(o -> System.out.println(JSON.toJSONString(o))); |
|
|
|
}); |
|
|
|
|
|
|
|
System.err.println("--------------------------------"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|