|
|
@ -122,27 +122,63 @@ public class DemoScoreCal { |
|
|
|
public void testBigDecimalBatchCalculateGroupBySampleId() throws InterruptedException { |
|
|
|
//{4,8,1,3,2}
|
|
|
|
|
|
|
|
// 每个指标需要单独的分支计算器,因为每个指标的最大最小值是不同的
|
|
|
|
ScoreCalculator sc1 = new BigDecimalScoreCalculator(new BigDecimal(1), new BigDecimal(8), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE); |
|
|
|
ScoreCalculator sc2 = new BigDecimalScoreCalculator(new BigDecimal(1), new BigDecimal(8), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.NEGATIVE); |
|
|
|
//分值计算器 每个指标需要单独的分值计算器,因为每个指标的最大最小值是不同的
|
|
|
|
ScoreCalculator sc1 = new BigDecimalScoreCalculator(new BigDecimal(50), new BigDecimal(100), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); |
|
|
|
ScoreCalculator sc2 = new BigDecimalScoreCalculator(new BigDecimal(20), new BigDecimal(100), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); |
|
|
|
ScoreCalculator sc3 = new BigDecimalScoreCalculator(new BigDecimal(20), new BigDecimal(40), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); |
|
|
|
ScoreCalculator sc4 = new BigDecimalScoreCalculator(new BigDecimal(10), new BigDecimal(100), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); |
|
|
|
|
|
|
|
//每个指标的数值 比如 a指标里有5条数据
|
|
|
|
List<SampleValue> index1SampleValues = Arrays.asList( |
|
|
|
new SampleValue<>("id1", new BigDecimal(100)), |
|
|
|
new SampleValue<>("id2", new BigDecimal(50)), |
|
|
|
new SampleValue<>("id3", new BigDecimal(60)), |
|
|
|
new SampleValue<>("id4", new BigDecimal(80)), |
|
|
|
new SampleValue<>("id5", new BigDecimal(80)) |
|
|
|
); |
|
|
|
|
|
|
|
List<SampleValue> index1SampleValues2 = Arrays.asList( |
|
|
|
new SampleValue<>("id1", new BigDecimal(100)), |
|
|
|
new SampleValue<>("id2", new BigDecimal(80)), |
|
|
|
new SampleValue<>("id3", new BigDecimal(80)), |
|
|
|
new SampleValue<>("id4", new BigDecimal(20)), |
|
|
|
new SampleValue<>("id5", new BigDecimal(20)) |
|
|
|
); |
|
|
|
|
|
|
|
List<SampleValue> index1SampleValues3 = Arrays.asList( |
|
|
|
new SampleValue<>("id1", new BigDecimal(40)), |
|
|
|
new SampleValue<>("id2", new BigDecimal(20)), |
|
|
|
new SampleValue<>("id3", new BigDecimal(40)), |
|
|
|
new SampleValue<>("id4", new BigDecimal(30)), |
|
|
|
new SampleValue<>("id5", new BigDecimal(20)) |
|
|
|
); |
|
|
|
|
|
|
|
List<SampleValue> index1SampleValues4 = Arrays.asList( |
|
|
|
new SampleValue<>("id1", new BigDecimal(20)), |
|
|
|
new SampleValue<>("id2", new BigDecimal(100)), |
|
|
|
new SampleValue<>("id3", new BigDecimal(10)), |
|
|
|
new SampleValue<>("id4", new BigDecimal(50)), |
|
|
|
new SampleValue<>("id5", new BigDecimal(20)) |
|
|
|
); |
|
|
|
|
|
|
|
List<SampleValue> index1SampleValues = Arrays.asList(new SampleValue<>("id1", new BigDecimal(4)), new SampleValue<>("id2", new BigDecimal(1)), new SampleValue<>("id3", new BigDecimal(8))); |
|
|
|
List<SampleValue> index2SampleValues = Arrays.asList(new SampleValue<>("id1", new BigDecimal(1)), new SampleValue<>("id2", new BigDecimal(8)), new SampleValue<>("id3", new BigDecimal(3))); |
|
|
|
|
|
|
|
// 每个指标的信息,包括样本列表,权重,指标标记
|
|
|
|
IndexInputVO index1VO = new IndexInputVO("aaa", index1SampleValues, new BigDecimal(6), new BigDecimal(1), sc1); |
|
|
|
IndexInputVO index2VO = new IndexInputVO("bbb", index2SampleValues, new BigDecimal(6), new BigDecimal(1), sc2); |
|
|
|
IndexInputVO index1VO = new IndexInputVO("aaa1", index1SampleValues, new BigDecimal(-1), new BigDecimal(0.2), sc1); |
|
|
|
IndexInputVO index2VO = new IndexInputVO("aaa2", index1SampleValues2, new BigDecimal(-1), new BigDecimal(0.15), sc2); |
|
|
|
IndexInputVO index3VO = new IndexInputVO("aaa3", index1SampleValues3, new BigDecimal(-1), new BigDecimal(0.15), sc3); |
|
|
|
IndexInputVO index4VO = new IndexInputVO("aaa4", index1SampleValues4, new BigDecimal(-1), new BigDecimal(0.5), sc4); |
|
|
|
|
|
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO); |
|
|
|
|
|
|
|
List<IndexInputVO> indexInputVOS = Arrays.asList(index1VO, index2VO,index3VO,index4VO); |
|
|
|
|
|
|
|
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); |
|
|
|
HashMap<String, BigDecimal> result = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); |
|
|
|
|
|
|
|
System.err.println("--------------------------------"); |
|
|
|
System.err.println("----------------1----------------"); |
|
|
|
result.forEach((key, value) -> { |
|
|
|
System.out.println(key.concat("的得分为:").concat(value.toString())); |
|
|
|
}); |
|
|
|
System.err.println("--------------------------------"); |
|
|
|
System.err.println("-----------------2---------------"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|