incubator-ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1429043 - /incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/utils/SMOTEplus.java
Date Fri, 04 Jan 2013 19:18:51 GMT
Author: clin
Date: Fri Jan  4 19:18:51 2013
New Revision: 1429043

URL: http://svn.apache.org/viewvc?rev=1429043&view=rev
Log:
add neighor's label to the synthetic instance. 

Modified:
    incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/utils/SMOTEplus.java

Modified: incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/utils/SMOTEplus.java
URL: http://svn.apache.org/viewvc/incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/utils/SMOTEplus.java?rev=1429043&r1=1429042&r2=1429043&view=diff
==============================================================================
--- incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/utils/SMOTEplus.java
(original)
+++ incubator/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/utils/SMOTEplus.java
Fri Jan  4 19:18:51 2013
@@ -6,8 +6,6 @@ import java.util.Comparator;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Random;
-
 import org.cleartk.classifier.Feature;
 import org.cleartk.classifier.Instance;
 import com.google.common.collect.HashBasedTable;
@@ -17,15 +15,15 @@ import com.google.common.collect.Table;
 /**
  * A simple implementation of SMOTE algorithm. 
  * Nitesh V. Shawla et. al. SMOTE: Synthetic Minority Over-sampling Technique, 06/02
- * currently only get the nearest neighbor for each minority instance.
- * May be modified to my SMOTE-plus algorithm.
+ * Find K nearest neighbor for each minority instance.
  *  
  * @author Chen Lin
+ * @DCT: 12/28/2012
+ * Modified on 1/4/2013
  */
 public class SMOTEplus {
 
 	protected List<Instance<String>> minorityInsts;
-	protected List<Instance<String>> majorityInsts;
 	protected Table<Instance<String>, String, Integer> instanceFeatureCount;
 	protected Table<Instance<String>, Instance<String>, Double> interInstanceDistance;
 	protected List<Instance<String>> syntheticInsts;
@@ -80,8 +78,6 @@ public class SMOTEplus {
 		return this.syntheticInsts;
 	}
 
-	private static Random rand = new Random();
-	
 	private Instance<String> generateInstance(Instance<String> aMinorityInst,
 			Instance<String> nearestNeighbor) {
 		List<Feature> features = new ArrayList<Feature>();
@@ -93,7 +89,7 @@ public class SMOTEplus {
 				features.add(feature);
 			}
 		}
-		String outcome = rand.nextBoolean()? aMinorityInst.getOutcome() : nearestNeighbor.getOutcome();
+		String outcome = nearestNeighbor.getOutcome();
 		Instance<String> syntheticInst = new Instance<String>(outcome, features);
 		return syntheticInst;
 	}



Mime
View raw message