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