forked from rongchao/epmet-cloud-rizhao
				
			
				 5 changed files with 156 additions and 18 deletions
			
			
		@ -0,0 +1,66 @@ | 
				
			|||
package com.epmet.stats.test.normalizing; | 
				
			|||
 | 
				
			|||
import com.epmet.support.normalizing.Correlation; | 
				
			|||
import com.epmet.support.normalizing.DoubleScoreCalculator; | 
				
			|||
import com.epmet.support.normalizing.IntegerScoreCalculator; | 
				
			|||
import com.epmet.support.normalizing.ScoreCalculator; | 
				
			|||
 | 
				
			|||
import java.math.BigDecimal; | 
				
			|||
import java.util.Arrays; | 
				
			|||
 | 
				
			|||
public class DemoScoreCal { | 
				
			|||
 | 
				
			|||
    public static void main(String[] args) { | 
				
			|||
        //demoInteger();
 | 
				
			|||
        demoIntegerPartical(); | 
				
			|||
        //demoDouble();
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 整数类型,完整源数据列表的归一算法 | 
				
			|||
     */ | 
				
			|||
    public static 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); | 
				
			|||
        BigDecimal[] scores = sc.normalize(iArray); | 
				
			|||
        Arrays.stream(scores).forEach(s -> System.out.println(s)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 整数类型,基于边界值的部分列表的的归一算法 | 
				
			|||
     */ | 
				
			|||
    public static void demoIntegerPartical() { | 
				
			|||
        Integer[] iArray = {4,1,2}; | 
				
			|||
        BigDecimal minScore = new BigDecimal(5); | 
				
			|||
        BigDecimal maxScore = new BigDecimal(10); | 
				
			|||
 | 
				
			|||
        ScoreCalculator sc = new IntegerScoreCalculator(1, 8 ,minScore, maxScore, Correlation.NEGATIVE); | 
				
			|||
        BigDecimal[] scores = sc.normalize(iArray);// 此处也可以直接使用list参数的重载方法,计算阶段没有任何区别,区别在于new IntegerScoreCalculator()阶段
 | 
				
			|||
        Arrays.stream(scores).forEach(s -> System.out.println(s)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * double类型归一算法 | 
				
			|||
     */ | 
				
			|||
    public static void demoDouble() { | 
				
			|||
        Double[] iArray = {1.9,8.9,1.0,3.0,2.0}; | 
				
			|||
        BigDecimal minScore = new BigDecimal(5); | 
				
			|||
        BigDecimal maxScore = new BigDecimal(10); | 
				
			|||
 | 
				
			|||
        ScoreCalculator sc = new DoubleScoreCalculator(iArray, minScore, maxScore, Correlation.POSITIVE); | 
				
			|||
        BigDecimal normalize = sc.normalize(3.0); | 
				
			|||
        System.out.println(normalize); | 
				
			|||
 | 
				
			|||
        /** | 
				
			|||
         * 同一组数据内,只有被计算值变了的话,不需要重新new对象,直接重复调用即可 | 
				
			|||
         */ | 
				
			|||
        BigDecimal normalize2 = sc.normalize(2.0); | 
				
			|||
        System.out.println(normalize2); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
} | 
				
			|||
					Loading…
					
					
				
		Reference in new issue