Ignore:
Timestamp:
06/22/16 11:25:46 (8 years ago)
Author:
sherbold
Message:
  • added the same workaround for the problem with Discretize to the TopMetricFilter?. We slightly refactored the implementation within the AbstractCODEP by putting the rescaling of sets to the WekaUtils? to facilitate better re-use.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/wekaclassifier/AbstractCODEP.java

    r128 r129  
    2323import java.util.regex.Pattern; 
    2424 
     25import de.ugoe.cs.cpdp.util.WekaUtils; 
    2526import de.ugoe.cs.util.console.Console; 
    2627import weka.classifiers.AbstractClassifier; 
     
    7172    private Map<Integer, Integer> upscaleIndex = null; 
    7273 
    73     /** 
    74      * Scaling value that moves the decimal point by 5 digets. 
    75      */ 
    76     private final double SCALER = 10000.0d; 
    77  
    7874    /* 
    7975     * (non-Javadoc) 
     
    136132                    } 
    137133                    else { 
    138                         traindataCopy = upscaleAttribute(traindata, attrIndex); 
     134                        traindataCopy = WekaUtils.upscaleAttribute(traindata, attrIndex); 
    139135                    } 
    140136 
     
    182178                // instance value must be upscaled 
    183179                int attrIndex = upscaleIndex.get(j); 
    184                 double upscaledVal = instance.value(attrIndex) * SCALER; 
     180                double upscaledVal = instance.value(attrIndex) * WekaUtils.SCALER; 
    185181                traindataCopy = new Instances(instance.dataset()); 
    186182                instance = new DenseInstance(instance.weight(), instance.toDoubleArray()); 
     
    231227    /** 
    232228     * <p> 
    233      * Upscales the value of a single attribute. This is a workaround to get BayesNet running for 
    234      * all data. Works on a copy of the training data, i.e., leaves the original data untouched. 
    235      * </p> 
    236      * 
    237      * @param traindata 
    238      *            data from which the attribute is upscaled. 
    239      * @param attributeIndex 
    240      *            index of the attribute 
    241      * @return data with upscaled attribute 
    242      */ 
    243     private Instances upscaleAttribute(Instances traindata, int attributeIndex) { 
    244         Instances traindataCopy = new Instances(traindata); 
    245         for (int i = 0; i < traindata.size(); i++) { 
    246             traindataCopy.get(i).setValue(attributeIndex, 
    247                                           traindata.get(i).value(attributeIndex) * SCALER); 
    248         } 
    249         return traindataCopy; 
    250     } 
    251  
    252     /** 
    253      * <p> 
    254229     * Abstract method through which implementing classes define which classifier is used for the 
    255230     * CODEP. 
Note: See TracChangeset for help on using the changeset viewer.