Ignore:
Timestamp:
07/18/16 12:26:03 (8 years ago)
Author:
sherbold
Message:
  • code documentation and formatting
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/dataprocessing/TCAPlusNormalization.java

    r86 r135  
    1919import weka.core.Instances; 
    2020 
    21 // normalization selected according to TCA+ rules (TCA has to be applied separately 
     21/** 
     22 * <p> 
     23 * Normalization selected according to the TCA+ rules after Nam et al. (Transfer Defect Learning). 
     24 * </p> 
     25 *  
     26 * @author Steffen Herbold 
     27 */ 
    2228public class TCAPlusNormalization implements IProcessesingStrategy { 
    2329 
     
    3036    @Override 
    3137    public void setParameter(String parameters) { 
    32         // TODO Auto-generated method stub 
    33          
     38        // dummy, paramters not used 
    3439    } 
    3540 
     41    /* 
     42     * (non-Javadoc) 
     43     *  
     44     * @see de.ugoe.cs.cpdp.dataprocessing.IProcessesingStrategy#apply(weka.core.Instances, 
     45     * weka.core.Instances) 
     46     */ 
    3647    @Override 
    3748    public void apply(Instances testdata, Instances traindata) { 
    3849        applyTCAPlus(testdata, traindata); 
    3950    } 
    40      
     51 
    4152    private void applyTCAPlus(Instances testdata, Instances traindata) { 
    4253        DistChar dcTest = WekaUtils.datasetDistance(testdata); 
    4354        DistChar dcTrain = WekaUtils.datasetDistance(traindata); 
    44          
     55 
    4556        // RULE 1: 
    46         if( 0.9*dcTrain.mean<=dcTest.mean && 1.1*dcTrain.mean>=dcTest.mean && 
    47             0.9*dcTrain.std<=dcTest.std && 1.1*dcTrain.std>=dcTest.std) { 
     57        if (0.9 * dcTrain.mean <= dcTest.mean && 1.1 * dcTrain.mean >= dcTest.mean && 
     58            0.9 * dcTrain.std <= dcTest.std && 1.1 * dcTrain.std >= dcTest.std) 
     59        { 
    4860            // do nothing 
    4961        } 
    5062        // RULE 2: 
    51         else if((0.4*dcTrain.min>dcTest.min || 1.6*dcTrain.min<dcTest.min) && 
    52                 (0.4*dcTrain.max>dcTest.max || 1.6*dcTrain.min<dcTest.max) && 
    53                 (0.4*dcTrain.min>dcTest.num || 1.6*dcTrain.min<dcTest.num)) { 
     63        else if ((0.4 * dcTrain.min > dcTest.min || 1.6 * dcTrain.min < dcTest.min) && 
     64            (0.4 * dcTrain.max > dcTest.max || 1.6 * dcTrain.min < dcTest.max) && 
     65            (0.4 * dcTrain.min > dcTest.num || 1.6 * dcTrain.min < dcTest.num)) 
     66        { 
    5467            NormalizationUtil.minMax(testdata); 
    5568            NormalizationUtil.minMax(traindata); 
    5669        } 
    5770        // RULE 3: 
    58         else if((0.4*dcTrain.std>dcTest.std && dcTrain.num<dcTest.num) ||  
    59                 (1.6*dcTrain.std<dcTest.std)&& dcTrain.num>dcTest.num) { 
     71        else if ((0.4 * dcTrain.std > dcTest.std && dcTrain.num < dcTest.num) || 
     72            (1.6 * dcTrain.std < dcTest.std) && dcTrain.num > dcTest.num) 
     73        { 
    6074            NormalizationUtil.zScoreTraining(testdata, traindata); 
    6175        } 
    6276        // RULE 4: 
    63         else if((0.4*dcTrain.std>dcTest.std && dcTrain.num>dcTest.num) ||  
    64                 (1.6*dcTrain.std<dcTest.std)&& dcTrain.num<dcTest.num) { 
     77        else if ((0.4 * dcTrain.std > dcTest.std && dcTrain.num > dcTest.num) || 
     78            (1.6 * dcTrain.std < dcTest.std) && dcTrain.num < dcTest.num) 
     79        { 
    6580            NormalizationUtil.zScoreTarget(testdata, traindata); 
    6681        } 
    67         //RULE 5: 
     82        // RULE 5: 
    6883        else { 
    6984            NormalizationUtil.zScore(testdata); 
Note: See TracChangeset for help on using the changeset viewer.