- Timestamp:
- 07/18/16 12:26:03 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/dataselection/SynonymOutlierRemoval.java
r86 r135 19 19 /** 20 20 * <p> 21 * Synonym outlier removal after Amasaki et al. (2015). 21 * Synonym outlier removal after Amasaki et al. (2015). 22 22 * </p> 23 23 * … … 26 26 public class SynonymOutlierRemoval implements IPointWiseDataselectionStrategy { 27 27 28 /* (non-Javadoc) 28 /* 29 * (non-Javadoc) 30 * 29 31 * @see de.ugoe.cs.cpdp.IParameterizable#setParameter(java.lang.String) 30 32 */ … … 34 36 } 35 37 36 /* (non-Javadoc) 37 * @see de.ugoe.cs.cpdp.dataselection.IPointWiseDataselectionStrategy#apply(weka.core.Instances, weka.core.Instances) 38 /* 39 * (non-Javadoc) 40 * 41 * @see de.ugoe.cs.cpdp.dataselection.IPointWiseDataselectionStrategy#apply(weka.core.Instances, 42 * weka.core.Instances) 38 43 */ 39 44 @Override … … 48 53 * </p> 49 54 * 50 * @param traindata data from which the outliers are removed. 55 * @param traindata 56 * data from which the outliers are removed. 51 57 */ 52 58 public void applySynonymRemoval(Instances traindata) { 53 double minDistance[][] = new double[traindata.size()][traindata.numAttributes() -1];54 double minDistanceAttribute[] = new double[traindata.numAttributes() -1];59 double minDistance[][] = new double[traindata.size()][traindata.numAttributes() - 1]; 60 double minDistanceAttribute[] = new double[traindata.numAttributes() - 1]; 55 61 double distance; 56 for ( int j=0; j<minDistanceAttribute.length; j++) {62 for (int j = 0; j < minDistanceAttribute.length; j++) { 57 63 minDistanceAttribute[j] = Double.MAX_VALUE; 58 64 } 59 for (int i1 = traindata.size() -1; i1 < traindata.size(); i1++) {60 int k =0;65 for (int i1 = traindata.size() - 1; i1 < traindata.size(); i1++) { 66 int k = 0; 61 67 for (int j = 0; j < traindata.numAttributes(); j++) { 62 if ( j!=traindata.classIndex()) {68 if (j != traindata.classIndex()) { 63 69 minDistance[i1][k] = Double.MAX_VALUE; 64 70 for (int i2 = 0; i2 < traindata.size(); i2++) { 65 71 if (i1 != i2) { 66 distance = Math.abs(traindata.get(i1).value(j) - traindata.get(i2).value(j)); 72 distance = 73 Math.abs(traindata.get(i1).value(j) - traindata.get(i2).value(j)); 67 74 if (distance < minDistance[i1][k]) { 68 75 minDistance[i1][k] = distance; 69 76 } 70 if ( distance < minDistanceAttribute[k]) {77 if (distance < minDistanceAttribute[k]) { 71 78 minDistanceAttribute[k] = distance; 72 79 } … … 77 84 } 78 85 } 79 for ( int i=traindata.size()-1; i>=0; i--) {86 for (int i = traindata.size() - 1; i >= 0; i--) { 80 87 boolean hasClosest = false; 81 for ( int j=0; !hasClosest && j<traindata.numAttributes(); j++) {82 hasClosest = minDistance[i][j] <=minDistanceAttribute[j];88 for (int j = 0; !hasClosest && j < traindata.numAttributes(); j++) { 89 hasClosest = minDistance[i][j] <= minDistanceAttribute[j]; 83 90 } 84 if ( !hasClosest) {91 if (!hasClosest) { 85 92 traindata.delete(i); 86 93 }
Note: See TracChangeset
for help on using the changeset viewer.