ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r1505015 - in /ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion: eval/AssertionEvaluation.java train/CrossValidateChi2GridSearch.java train/TrainAttributeModels.java
Date Fri, 19 Jul 2013 20:58:53 GMT
Author: swu
Date: Fri Jul 19 20:58:52 2013
New Revision: 1505015

URL: http://svn.apache.org/r1505015
Log:
some extra stuff for feature selection grid search and evaluations in general

Modified:
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/CrossValidateChi2GridSearch.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/TrainAttributeModels.java

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java?rev=1505015&r1=1505014&r2=1505015&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AssertionEvaluation.java
Fri Jul 19 20:58:52 2013
@@ -18,8 +18,10 @@
  */
 package org.apache.ctakes.assertion.eval;
 
+import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.util.ArrayList;
@@ -255,6 +257,19 @@ private static Logger logger = Logger.ge
 
   private String sharpCorpusDirectory;
 
+  static public File evaluationLogFile;
+  static public BufferedWriter evaluationLogFileOut;
+  static {
+	  try {
+		evaluationLogFile = new File("eval_"+new Date().toString().replaceAll(" ","_") + ".txt");
+		evaluationLogFileOut = new BufferedWriter(new FileWriter(evaluationLogFile), 32768);
+	} catch (IOException e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	}
+  }
+  static public boolean useEvaluationLogFile = false;
+
   protected static Options options = new Options();
   
   public static void main(String[] args) throws Exception {
@@ -472,8 +487,24 @@ public static void printScore(Map<String
     	    directory,
     	    annotationType.toUpperCase(),
     	    stats.toString());
+    	  
+    	  try {
+    		  if (useEvaluationLogFile) {
+    			  evaluationLogFileOut.write(
+    					  String.format("directory: \"%s\"; assertion type: %s%n%n%s%n%n",
+    							  directory,
+    							  annotationType.toUpperCase(),
+    							  stats.toString())
+    					  );
+    		  }
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+
 	  }
-      
+
   }
 
   private String[] trainingArguments;

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/CrossValidateChi2GridSearch.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/CrossValidateChi2GridSearch.java?rev=1505015&r1=1505014&r2=1505015&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/CrossValidateChi2GridSearch.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/CrossValidateChi2GridSearch.java
Fri Jul 19 20:58:52 2013
@@ -12,16 +12,20 @@ public class CrossValidateChi2GridSearch
 
 	public static void main(String[] args) throws Exception {
 		
-		float[] threshs = {0.0001f, 0.001f, 0.01f, 0.1f, 1f, 10f};
+		AssertionEvaluation.useEvaluationLogFile = true;
+		
+		float[] threshs = {2f, 5f, 10f, 20f, 50f, 100f};
 		for (Float chi2threshold : threshs ) {
+			System.out.println("BEGIN Chi2 Grid Search with threshold = "+ Float.toString(chi2threshold));
+			AssertionEvaluation.evaluationLogFileOut.write("BEGIN Chi2 Grid Search with threshold
= "+ Float.toString(chi2threshold));
+			AssertionEvaluation.evaluationLogFileOut.flush();
 			
-
 			for (String attribute : AssertionConst.annotationTypes) {
 
 				ArrayList<String> params = new ArrayList<String>();
 
 				params.add("--train-dir"); 			params.add(AssertionConst.trainingDirectories.get(attribute));
-				params.add("--models-dir"); 		params.add(AssertionConst.modelDirectory);
+				params.add("--models-dir"); 		params.add(AssertionConst.modelDirectory+Float.toString(chi2threshold));
 				params.add("--cross-validation"); 	params.add("5");
 				params.add("--feature-selection");	params.add(Float.toString(chi2threshold));
 

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/TrainAttributeModels.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/TrainAttributeModels.java?rev=1505015&r1=1505014&r2=1505015&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/TrainAttributeModels.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/TrainAttributeModels.java
Fri Jul 19 20:58:52 2013
@@ -25,7 +25,7 @@ public class TrainAttributeModels {
 			params.add("--models-dir"); params.add(AssertionConst.modelDirectory);
 //			params.add("--evaluation-output-dir");	params.add(AssertionConst.evalOutputDir); 
 			params.add("--train-only"); 
-			params.add("--feature-selection");	params.add("c");
+			params.add("--feature-selection");	params.add("1.0");
 			
 			// Build up an "ignore" string
 			for (String ignoreAttribute : AssertionConst.allAnnotationTypes) {



Mime
View raw message