Changeset 120 for trunk/CrossPare/src/de/ugoe/cs
- Timestamp:
- 06/03/16 15:54:42 (8 years ago)
- 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 97 97 * @param data data to which the processor is applied 98 98 */ 99 p rivatevoid applyMORPH(Instances data) {99 public void applyMORPH(Instances data) { 100 100 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)) ); 111 122 } 112 123 } … … 122 133 * @return nearest unlike instance 123 134 */ 124 p rotectedInstance getNearestUnlikeNeighbor(Instance instance, Instances data) {135 public Instance getNearestUnlikeNeighbor(Instance instance, Instances data) { 125 136 Instance nearestUnlikeNeighbor = null; 126 137 -
trunk/CrossPare/src/de/ugoe/cs/cpdp/dataselection/CLIFF.java
r86 r120 65 65 } 66 66 67 pr ivateInstances applyCLIFF(Instances data) {67 protected Instances applyCLIFF(Instances data) { 68 68 final double[][] powerAttributes = new double[data.size()][data.numAttributes()]; 69 69 final double[] powerEntity = new double[data.size()];
Note: See TracChangeset
for help on using the changeset viewer.