Changeset 120 for trunk/CrossPare/src/de


Ignore:
Timestamp:
06/03/16 15:54:42 (8 years ago)
Author:
sherbold
Message:
  • implemented LACE2 after Peters et al., 2015
Location:
trunk/CrossPare/src/de/ugoe/cs/cpdp
Files:
1 added
2 edited

Legend:

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

    r86 r120  
    9797     * @param data data to which the processor is applied 
    9898     */ 
    99     private void applyMORPH(Instances data) { 
     99    public void applyMORPH(Instances data) { 
    100100        for (int i=0; i<data.numInstances(); i++ ) { 
    101             Instance instance = data.instance(i); 
    102             Instance nearestUnlikeNeighbor = getNearestUnlikeNeighbor(instance, data); 
    103             if( nearestUnlikeNeighbor==null ) { 
    104                 throw new RuntimeException("could not find nearest unlike neighbor within the data: " + data.relationName()); 
    105             } 
    106             for( int j=0; j<data.numAttributes() ; j++ ) { 
    107                 if( data.attribute(j)!=data.classAttribute() && data.attribute(j).isNumeric()) { 
    108                     double randVal = rand.nextDouble()*(beta-alpha)+alpha; 
    109                     instance.setValue(j, instance.value(j) + randVal*(instance.value(j)-nearestUnlikeNeighbor.value(j)) ); 
    110                 } 
     101            morphInstance(data.get(i), data); 
     102        } 
     103    } 
     104     
     105    /** 
     106     * <p> 
     107     * Applies MORPH to a single instance 
     108     * </p> 
     109     * 
     110     * @param instance instance that is morphed 
     111     * @param data data based on which the instance is morphed 
     112     */ 
     113    public void morphInstance(Instance instance, Instances data) { 
     114        Instance nearestUnlikeNeighbor = getNearestUnlikeNeighbor(instance, data); 
     115        if( nearestUnlikeNeighbor==null ) { 
     116            throw new RuntimeException("could not find nearest unlike neighbor within the data: " + data.relationName()); 
     117        } 
     118        for( int j=0; j<data.numAttributes() ; j++ ) { 
     119            if( data.attribute(j)!=data.classAttribute() && data.attribute(j).isNumeric()) { 
     120                double randVal = rand.nextDouble()*(beta-alpha)+alpha; 
     121                instance.setValue(j, instance.value(j) + randVal*(instance.value(j)-nearestUnlikeNeighbor.value(j)) ); 
    111122            } 
    112123        } 
     
    122133     * @return nearest unlike instance 
    123134     */ 
    124     protected Instance getNearestUnlikeNeighbor(Instance instance, Instances data) { 
     135    public Instance getNearestUnlikeNeighbor(Instance instance, Instances data) { 
    125136        Instance nearestUnlikeNeighbor = null; 
    126137         
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/dataselection/CLIFF.java

    r86 r120  
    6565    } 
    6666 
    67     private Instances applyCLIFF(Instances data) { 
     67    protected Instances applyCLIFF(Instances data) { 
    6868        final double[][] powerAttributes = new double[data.size()][data.numAttributes()]; 
    6969        final double[] powerEntity = new double[data.size()]; 
Note: See TracChangeset for help on using the changeset viewer.