ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r1508435 - in /ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion: attributes/features/selection/ eval/ medfacts/cleartk/ train/
Date Tue, 30 Jul 2013 13:37:31 GMT
Author: swu
Date: Tue Jul 30 13:37:30 2013
New Revision: 1508435

URL: http://svn.apache.org/r1508435
Log:
ctakes-assertion: more modifications to improve evaluation and logging for feature selection
tests

Added:
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AnnotationStatisticsCompact.java
  (with props)
Modified:
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/attributes/features/selection/Chi2FeatureSelection.java
    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/medfacts/cleartk/ConditionalCleartkAnalysisEngine.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/GenericCleartkAnalysisEngine.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/SubjectCleartkAnalysisEngine.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java
    ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/train/CrossValidateChi2GridSearch.java

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/attributes/features/selection/Chi2FeatureSelection.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/attributes/features/selection/Chi2FeatureSelection.java?rev=1508435&r1=1508434&r2=1508435&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/attributes/features/selection/Chi2FeatureSelection.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/attributes/features/selection/Chi2FeatureSelection.java
Tue Jul 30 13:37:30 2013
@@ -38,9 +38,12 @@ public class Chi2FeatureSelection<OUTCOM
 
     protected Table<String, OUTCOME_T, Integer> featValueClassCount;
 
-    public Chi2Scorer() {
+	private boolean yates = false;
+
+    public Chi2Scorer(boolean yate) {
       this.classCounts = HashMultiset.<OUTCOME_T> create();
       this.featValueClassCount = HashBasedTable.<String, OUTCOME_T, Integer> create();
+      this.yates = yate;
     }
 
     public void update(String featureName, OUTCOME_T outcome, int occurrences) {
@@ -88,13 +91,12 @@ public class Chi2FeatureSelection<OUTCOM
         return chi2val;
       }
 
-      boolean yates = true;
       for (int lbl = 0; lbl < numOfClass; lbl++) {
         // for positive part of feature:
         double expected = (outcomeCounts[lbl] / (double) n) * (posiFeatCount);
         if (expected > 0) {
           double diff = Math.abs(posiOutcomeCounts[lbl] - expected);
-          if (yates) { // apply Yate's correction
+          if (this.yates ) { // apply Yate's correction
             diff -= 0.5;
           }
           if (diff > 0)
@@ -106,7 +108,7 @@ public class Chi2FeatureSelection<OUTCOM
         double observ = outcomeCounts[lbl] - posiOutcomeCounts[lbl];
         if (expected > 0) {
           double diff = Math.abs(observ - expected);
-          if (yates) { // apply Yate's correction
+          if (this.yates) { // apply Yate's correction
             diff -= 0.5;
           }
           if (diff > 0)
@@ -121,6 +123,8 @@ public class Chi2FeatureSelection<OUTCOM
   private double chi2Threshold;
 
   private Chi2Scorer<OUTCOME_T> chi2Function;
+  
+  private boolean yates = false;
 
   public Chi2FeatureSelection(String name) {
     this(name, 0.0);
@@ -131,6 +135,17 @@ public class Chi2FeatureSelection<OUTCOM
     this.chi2Threshold = threshold;
   }
 
+  /**
+   * Constructor that can let use control the yate's correction
+   * @param name
+   * @param threshold
+   * @param yates : true for using yate's correction, false for turn off yate's correction
+   */
+  public Chi2FeatureSelection(String name, double threshold, boolean yates) {
+	    super(name);
+	    this.chi2Threshold = threshold;
+	    this.yates = yates;
+	  }
   @Override
   public boolean apply(Feature feature) {
     return this.selectedFeatureNames.contains(this.getFeatureName(feature));
@@ -139,7 +154,7 @@ public class Chi2FeatureSelection<OUTCOM
   @Override
   public void train(Iterable<Instance<OUTCOME_T>> instances) {
     // aggregate statistics for all features
-    this.chi2Function = new Chi2Scorer<OUTCOME_T>();
+    this.chi2Function = new Chi2Scorer<OUTCOME_T>(this.yates);
     for (Instance<OUTCOME_T> instance : instances) {
       OUTCOME_T outcome = instance.getOutcome();
       for (Feature feature : instance.getFeatures()) {

Added: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AnnotationStatisticsCompact.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AnnotationStatisticsCompact.java?rev=1508435&view=auto
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AnnotationStatisticsCompact.java
(added)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AnnotationStatisticsCompact.java
Tue Jul 30 13:37:30 2013
@@ -0,0 +1,494 @@
+/* 
+ * Copyright (c) 2012, Regents of the University of Colorado 
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer. 
+ * Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution. 
+ * Neither the name of the University of Colorado at Boulder nor the names of its contributors
may be used to endorse or promote products derived from this software without specific prior
written permission. 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE. 
+ */
+package org.apache.ctakes.assertion.eval;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.cleartk.eval.util.ConfusionMatrix;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.HashMultiset;
+import com.google.common.collect.Multiset;
+
+/**
+ * Stores statistics for comparing {@link Annotation}s extracted by a system to gold
+ * {@link Annotation}s.
+ * 
+ * <br>
+ * Copyright (c) 2012, Regents of the University of Colorado <br>
+ * All rights reserved.
+ * 
+ * @author Steven Bethard
+ */
+public class AnnotationStatisticsCompact<OUTCOME_TYPE extends Comparable<? super OUTCOME_TYPE>>
implements
+    Serializable {
+
+  private static final long serialVersionUID = 1L;
+
+  private Multiset<OUTCOME_TYPE> referenceOutcomes;
+
+  private Multiset<OUTCOME_TYPE> predictedOutcomes;
+
+  private Multiset<OUTCOME_TYPE> correctOutcomes;
+
+  private ConfusionMatrix<OUTCOME_TYPE> confusionMatrix;
+
+  /**
+   * Creates a {@link Function} that converts an {@link Annotation} into a hashable representation
+   * of its begin and end offsets.
+   * 
+   * The {@link Function} created by this method is suitable for passing to the first
+   * {@link Function} argument of {@link #add(Collection, Collection, Function, Function)}.
+   */
+  public static <ANNOTATION_TYPE extends Annotation> Function<ANNOTATION_TYPE, Span>
annotationToSpan() {
+    return new Function<ANNOTATION_TYPE, Span>() {
+      @Override
+      public Span apply(ANNOTATION_TYPE annotation) {
+        return new Span(annotation);
+      }
+    };
+  }
+
+  /**
+   * Creates a {@link Function} that extracts a feature value from a {@link TOP}.
+   * 
+   * The {@link Function} created by this method is suitable for passing to the second
+   * {@link Function} argument of {@link #add(Collection, Collection, Function, Function)}.
+   * 
+   * @param featureName
+   *          The name of the feature whose value is to be extracted.
+   */
+  public static <ANNOTATION_TYPE extends TOP> Function<ANNOTATION_TYPE, String>
annotationToFeatureValue(
+      final String featureName) {
+    return new Function<ANNOTATION_TYPE, String>() {
+      @Override
+      public String apply(ANNOTATION_TYPE annotation) {
+        Feature feature = annotation.getType().getFeatureByBaseName(featureName);
+        return annotation.getFeatureValueAsString(feature);
+      }
+    };
+  }
+
+  /**
+   * Creates a {@link Function} that always returns null.
+   * 
+   * This may be useful when only the span of the offset is important, but you still need
to pass in
+   * the final argument of {@link #add(Collection, Collection, Function, Function)}.
+   */
+  public static <ANNOTATION_TYPE, OUTCOME_TYPE> Function<ANNOTATION_TYPE, OUTCOME_TYPE>
annotationToNull() {
+    return new Function<ANNOTATION_TYPE, OUTCOME_TYPE>() {
+      @Override
+      public OUTCOME_TYPE apply(ANNOTATION_TYPE annotation) {
+        return null;
+      }
+    };
+  }
+
+  /**
+   * Add all statistics together.
+   * 
+   * This is often useful for combining individual fold statistics that result from methods
like
+   * {@link Evaluation_ImplBase#crossValidation(List, int)}.
+   * 
+   * @param statistics
+   *          The sequence of statistics that should be combined.
+   * @return The combination of all the individual statistics.
+   */
+  public static <OUTCOME_TYPE extends Comparable<? super OUTCOME_TYPE>> AnnotationStatisticsCompact<OUTCOME_TYPE>
addAll(
+      Iterable<AnnotationStatisticsCompact<OUTCOME_TYPE>> statistics) {
+    AnnotationStatisticsCompact<OUTCOME_TYPE> result = new AnnotationStatisticsCompact<OUTCOME_TYPE>();
+    for (AnnotationStatisticsCompact<OUTCOME_TYPE> item : statistics) {
+      result.addAll(item);
+    }
+    return result;
+  }
+
+  /**
+   * Create an AnnotationStatisticsCompact that compares {@link Annotation}s based on their
begin and end
+   * offsets, plus a {@link Feature} of the {@link Annotation} that represents the outcome
or label.
+   */
+  public AnnotationStatisticsCompact() {
+    this.referenceOutcomes = HashMultiset.create();
+    this.predictedOutcomes = HashMultiset.create();
+    this.correctOutcomes = HashMultiset.create();
+    this.confusionMatrix = new ConfusionMatrix<OUTCOME_TYPE>();
+  }
+
+  /**
+   * Update the statistics, comparing the reference annotations to the predicted annotations.
+   * 
+   * Annotations are considered to match if they have the same character offsets in the text.
All
+   * outcomes (e.g. as returned in {@link #confusions()}) will be <code>null</code>.
+   * 
+   * @param referenceAnnotations
+   *          The reference annotations, typically identified by humans.
+   * @param predictedAnnotations
+   *          The predicted annotations, typically identified by a model.
+   */
+  public <ANNOTATION_TYPE extends Annotation> void add(
+      Collection<? extends ANNOTATION_TYPE> referenceAnnotations,
+      Collection<? extends ANNOTATION_TYPE> predictedAnnotations) {
+    this.add(
+        referenceAnnotations,
+        predictedAnnotations,
+        AnnotationStatisticsCompact.<ANNOTATION_TYPE> annotationToSpan(),
+        AnnotationStatisticsCompact.<ANNOTATION_TYPE, OUTCOME_TYPE> annotationToNull());
+  }
+
+  /**
+   * Update the statistics, comparing the reference annotations to the predicted annotations.
+   * 
+   * Annotations are considered to match if they have the same span (according to
+   * {@code annotationToSpan}) and if they have the same outcome (according to
+   * {@code annotationToOutcome}).
+   * 
+   * @param referenceAnnotations
+   *          The reference annotations, typically identified by humans.
+   * @param predictedAnnotations
+   *          The predicted annotations, typically identified by a model.
+   * @param annotationToSpan
+   *          A function that defines how to convert an annotation into a hashable object
that
+   *          represents the span of that annotation. The {@link #annotationToSpan()} method
+   *          provides an example function that could be used here.
+   * @param annotationToOutcome
+   *          A function that defines how to convert an annotation into an object that represents
+   *          the outcome (or "label") assigned to that annotation. The
+   *          {@link #annotationToFeatureValue(String)} method provides a sample function
that could
+   *          be used here.
+   */
+  public <ANNOTATION_TYPE, SPAN_TYPE> void add(
+      Collection<? extends ANNOTATION_TYPE> referenceAnnotations,
+      Collection<? extends ANNOTATION_TYPE> predictedAnnotations,
+      Function<ANNOTATION_TYPE, SPAN_TYPE> annotationToSpan,
+      Function<ANNOTATION_TYPE, OUTCOME_TYPE> annotationToOutcome) {
+
+    // map gold spans to their outcomes
+    Map<SPAN_TYPE, OUTCOME_TYPE> referenceSpanOutcomes = new HashMap<SPAN_TYPE,
OUTCOME_TYPE>();
+    for (ANNOTATION_TYPE ann : referenceAnnotations) {
+      referenceSpanOutcomes.put(annotationToSpan.apply(ann), annotationToOutcome.apply(ann));
+    }
+
+    // map system spans to their outcomes
+    Map<SPAN_TYPE, OUTCOME_TYPE> predictedSpanOutcomes = new HashMap<SPAN_TYPE,
OUTCOME_TYPE>();
+    for (ANNOTATION_TYPE ann : predictedAnnotations) {
+      predictedSpanOutcomes.put(annotationToSpan.apply(ann), annotationToOutcome.apply(ann));
+    }
+
+    // update the gold and system outcomes
+    this.referenceOutcomes.addAll(referenceSpanOutcomes.values());
+    this.predictedOutcomes.addAll(predictedSpanOutcomes.values());
+
+    // determine the outcomes that were correct
+    Set<SPAN_TYPE> intersection = new HashSet<SPAN_TYPE>();
+    intersection.addAll(referenceSpanOutcomes.keySet());
+    intersection.retainAll(predictedSpanOutcomes.keySet());
+    for (SPAN_TYPE span : intersection) {
+      OUTCOME_TYPE goldOutcome = referenceSpanOutcomes.get(span);
+      OUTCOME_TYPE systemOutcome = predictedSpanOutcomes.get(span);
+      if (Objects.equal(goldOutcome, systemOutcome)) {
+        this.correctOutcomes.add(goldOutcome);
+      }
+    }
+
+    // update the confusion matrix
+    Set<SPAN_TYPE> union = new HashSet<SPAN_TYPE>();
+    union.addAll(referenceSpanOutcomes.keySet());
+    union.addAll(predictedSpanOutcomes.keySet());
+    for (SPAN_TYPE span : union) {
+      OUTCOME_TYPE goldOutcome = referenceSpanOutcomes.get(span);
+      OUTCOME_TYPE systemOutcome = predictedSpanOutcomes.get(span);
+      this.confusionMatrix.add(goldOutcome, systemOutcome);
+    }
+  }
+
+  /**
+   * Adds all the statistics collected by another AnnotationStatisticsCompact to this one.
+   * 
+   * @param that
+   *          The other statistics that should be added to this one.
+   */
+  public void addAll(AnnotationStatisticsCompact<OUTCOME_TYPE> that) {
+    this.referenceOutcomes.addAll(that.referenceOutcomes);
+    this.predictedOutcomes.addAll(that.predictedOutcomes);
+    this.correctOutcomes.addAll(that.correctOutcomes);
+    this.confusionMatrix.add(that.confusionMatrix);
+  }
+
+  public int countCorrectOutcomes() {
+    return this.correctOutcomes.size();
+  }
+
+  public int countCorrectOutcomes(OUTCOME_TYPE outcome) {
+    return this.correctOutcomes.count(outcome);
+  }
+
+  public int countPredictedOutcomes() {
+    return this.predictedOutcomes.size();
+  }
+
+  public int countPredictedOutcomes(OUTCOME_TYPE outcome) {
+    return this.predictedOutcomes.count(outcome);
+  }
+
+  public int countReferenceOutcomes() {
+    return this.referenceOutcomes.size();
+  }
+
+  public int countReferenceOutcomes(OUTCOME_TYPE outcome) {
+    return this.referenceOutcomes.count(outcome);
+  }
+
+  public int countFalseNegatives(OUTCOME_TYPE... positiveOutcomes) {
+    int numReferenceOutcomes = this.countReferenceOutcomes();
+    int numPredictedOutcomes = this.countPredictedOutcomes();
+    if (numReferenceOutcomes != numPredictedOutcomes) {
+      throw new IllegalStateException(
+          String.format(
+              "Expected number equal number of references outcomes and predicted outcomes.
 Had reference outcomes=%d, predicted outcomes=%d",
+              numReferenceOutcomes,
+              numPredictedOutcomes,
+              this.countPredictedOutcomes()));
+    }
+    int totalFalseNegatives = 0;
+    for (OUTCOME_TYPE positiveOutcome : positiveOutcomes) {
+      totalFalseNegatives += this.countReferenceOutcomes(positiveOutcome)
+          - this.countCorrectOutcomes(positiveOutcome);
+    }
+    return totalFalseNegatives;
+  }
+
+  public int countFalsePositives(OUTCOME_TYPE... positiveOutcomes) {
+    int numReferenceOutcomes = this.countReferenceOutcomes();
+    int numPredictedOutcomes = this.countPredictedOutcomes();
+    if (numReferenceOutcomes != numPredictedOutcomes) {
+      throw new IllegalStateException(
+          String.format(
+              "Expected number equal number of references outcomes and predicted outcomes.
 Had reference outcomes=%d, predicted outcomes=%d",
+              numReferenceOutcomes,
+              numPredictedOutcomes,
+              this.countPredictedOutcomes()));
+    }
+    int totalFalsePositives = 0;
+    for (OUTCOME_TYPE positiveOutcome : positiveOutcomes) {
+      totalFalsePositives += this.countPredictedOutcomes(positiveOutcome)
+          - this.countCorrectOutcomes(positiveOutcome);
+    }
+
+    return totalFalsePositives;
+  }
+
+  public int countTrueNegatives(OUTCOME_TYPE... positiveOutcomes) {
+    int numReferenceOutcomes = this.countReferenceOutcomes();
+    int numPredictedOutcomes = this.countPredictedOutcomes();
+    if (numReferenceOutcomes != numPredictedOutcomes) {
+      throw new IllegalStateException(
+          String.format(
+              "Expected number equal number of references outcomes and predicted outcomes.
 Had reference outcomes=%d, predicted outcomes=%d",
+              numReferenceOutcomes,
+              numPredictedOutcomes,
+              this.countPredictedOutcomes()));
+    }
+    int totalTrueNegatives = this.countCorrectOutcomes();
+
+    for (OUTCOME_TYPE positiveOutcome : positiveOutcomes) {
+      totalTrueNegatives -= this.countCorrectOutcomes(positiveOutcome);
+    }
+
+    return totalTrueNegatives;
+
+  }
+
+  public int countTruePositives(OUTCOME_TYPE... positiveOutcomes) {
+    int numReferenceOutcomes = this.countReferenceOutcomes();
+    int numPredictedOutcomes = this.countPredictedOutcomes();
+    if (numReferenceOutcomes != numPredictedOutcomes) {
+      throw new IllegalStateException(
+          String.format(
+              "Expected number equal number of references outcomes and predicted outcomes.
 Had reference outcomes=%d, predicted outcomes=%d",
+              numReferenceOutcomes,
+              numPredictedOutcomes,
+              this.countPredictedOutcomes()));
+    }
+
+    int totalTruePositives = 0;
+    for (OUTCOME_TYPE positiveOutcome : positiveOutcomes) {
+      totalTruePositives += this.countCorrectOutcomes(positiveOutcome);
+    }
+    return totalTruePositives;
+  }
+
+  /**
+   * Returns the {@link ConfusionMatrix} tabulating reference outcomes matched to predicted
+   * outcomes.
+   * 
+   * @return The confusion matrix.
+   */
+  public ConfusionMatrix<OUTCOME_TYPE> confusions() {
+    return this.confusionMatrix;
+  }
+
+  public double precision() {
+    int nSystem = this.countPredictedOutcomes();
+    return nSystem == 0 ? 1.0 : ((double) this.countCorrectOutcomes()) / nSystem;
+  }
+
+  public double precision(OUTCOME_TYPE outcome) {
+    int nSystem = this.countPredictedOutcomes(outcome);
+    return nSystem == 0 ? 1.0 : ((double) this.countCorrectOutcomes(outcome)) / nSystem;
+  }
+
+  public double recall() {
+    int nGold = this.countReferenceOutcomes();
+    return nGold == 0 ? 1.0 : ((double) this.countCorrectOutcomes()) / nGold;
+  }
+
+  public double recall(OUTCOME_TYPE outcome) {
+    int nGold = this.countReferenceOutcomes(outcome);
+    return nGold == 0 ? 1.0 : ((double) this.countCorrectOutcomes(outcome)) / nGold;
+  }
+
+  public double f(double beta) {
+    double p = this.precision();
+    double r = this.recall();
+    double num = (1 + beta * beta) * p * r;
+    double den = (beta * beta * p) + r;
+    return den == 0.0 ? 0.0 : num / den;
+  }
+
+  public double f(double beta, OUTCOME_TYPE outcome) {
+    double p = this.precision(outcome);
+    double r = this.recall(outcome);
+    double num = (1 + beta * beta) * p * r;
+    double den = (beta * beta * p) + r;
+    return den == 0.0 ? 0.0 : num / den;
+  }
+
+  public double f1() {
+    return this.f(1.0);
+  }
+
+  public double f1(OUTCOME_TYPE outcome) {
+    return f(1.0, outcome);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder result = new StringBuilder();
+    result.append("P\tR\tF1\t#gold\t#system\t#correct\n");
+    result.append(String.format(
+        "%.3f\t%.3f\t%.3f\t%d\t%d\t%d\tOVERALL\n",
+        this.precision(),
+        this.recall(),
+        this.f1(),
+        this.referenceOutcomes.size(),
+        this.predictedOutcomes.size(),
+        this.correctOutcomes.size()));
+    List<OUTCOME_TYPE> outcomes = new ArrayList<OUTCOME_TYPE>(this.referenceOutcomes.elementSet());
+    if (outcomes.size() > 1) {
+      Collections.sort(outcomes);
+      for (OUTCOME_TYPE outcome : outcomes) {
+        result.append(String.format(
+            "%.3f\t%.3f\t%.3f\t%d\t%d\t%d\t%s\n",
+            this.precision(outcome),
+            this.recall(outcome),
+            this.f1(outcome),
+            this.referenceOutcomes.count(outcome),
+            this.predictedOutcomes.count(outcome),
+            this.correctOutcomes.count(outcome),
+            outcome));
+      }
+    }
+    return result.toString();
+  }
+
+  public String toTsv() {
+	StringBuilder result = new StringBuilder();
+	result.append(String.format(
+			"%s:%.3f\t%s:%.3f\t%s:%.3f\t",
+			"All",this.precision(),
+			"All",this.recall(),
+			"All",this.f1()));
+	List<OUTCOME_TYPE> outcomes = new ArrayList<OUTCOME_TYPE>(this.referenceOutcomes.elementSet());
+	if (outcomes.size() > 1) {
+		Collections.sort(outcomes);
+		for (OUTCOME_TYPE outcome : outcomes) {
+			result.append(String.format(
+					"%s:%.3f\t%s:%.3f\t%s:%.3f\t",
+					outcome,this.precision(outcome),
+					outcome,this.recall(outcome),
+					outcome,this.f1(outcome)));
+		}
+	}
+	result.append("\n");
+	return result.toString();
+}
+
+  
+  private static class Span {
+
+    public int end;
+
+    public int begin;
+
+    public Span(Annotation annotation) {
+      this.begin = annotation.getBegin();
+      this.end = annotation.getEnd();
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hashCode(this.begin, this.end);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      if (!this.getClass().equals(obj.getClass())) {
+        return false;
+      }
+      Span that = (Span) obj;
+      return this.begin == that.begin && this.end == that.end;
+    }
+
+    @Override
+    public String toString() {
+      ToStringHelper helper = Objects.toStringHelper(this);
+      helper.add("begin", this.begin);
+      helper.add("end", this.end);
+      return helper.toString();
+    }
+  }
+}

Propchange: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/eval/AnnotationStatisticsCompact.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=1508435&r1=1508434&r2=1508435&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
Tue Jul 30 13:37:30 2013
@@ -87,7 +87,6 @@ import org.cleartk.classifier.jar.Direct
 import org.cleartk.classifier.jar.GenericJarClassifierFactory;
 import org.cleartk.classifier.jar.JarClassifierBuilder;
 import org.cleartk.classifier.liblinear.LIBLINEARStringOutcomeDataWriter;
-import org.cleartk.eval.AnnotationStatistics;
 import org.cleartk.eval.Evaluation_ImplBase;
 import org.cleartk.util.Options_ImplBase;
 import org.kohsuke.args4j.Option;
@@ -113,7 +112,7 @@ import com.google.common.collect.Sets;
 //import org.chboston.cnlp.ctakes.relationextractor.eval.RelationExtractorEvaluation;
 //import org.chboston.cnlp.ctakes.relationextractor.ae.ModifierExtractorAnnotator;
 
-public class AssertionEvaluation extends Evaluation_ImplBase<File, Map<String, AnnotationStatistics>>
{
+public class AssertionEvaluation extends Evaluation_ImplBase<File, Map<String, AnnotationStatisticsCompact>>
{
   
 private static Logger logger = Logger.getLogger(AssertionEvaluation.class); 
 
@@ -352,20 +351,20 @@ private static Logger logger = Logger.ge
     // run cross-validation
     else if(options.crossValidationFolds != null) {
       // run n-fold cross-validation
-      List<Map<String, AnnotationStatistics>> foldStats = evaluation.crossValidation(trainFiles,
options.crossValidationFolds);
-      //AnnotationStatistics overallStats = AnnotationStatistics.addAll(foldStats);
-      Map<String, AnnotationStatistics> overallStats = new TreeMap<String, AnnotationStatistics>();
+      List<Map<String, AnnotationStatisticsCompact>> foldStats = evaluation.crossValidation(trainFiles,
options.crossValidationFolds);
+      //AnnotationStatisticsCompact overallStats = AnnotationStatisticsCompact.addAll(foldStats);
+      Map<String, AnnotationStatisticsCompact> overallStats = new TreeMap<String,
AnnotationStatisticsCompact>();
       
       for (String currentAnnotationType : annotationTypes)
       {
-    	  AnnotationStatistics currentAnnotationStatistics = new AnnotationStatistics();
-    	  overallStats.put(currentAnnotationType, currentAnnotationStatistics);
+    	  AnnotationStatisticsCompact currentAnnotationStatisticsCompact = new AnnotationStatisticsCompact();
+    	  overallStats.put(currentAnnotationType, currentAnnotationStatisticsCompact);
       }
-      for (Map<String, AnnotationStatistics> singleFoldMap : foldStats)
+      for (Map<String, AnnotationStatisticsCompact> singleFoldMap : foldStats)
       {
     	  for (String currentAnnotationType : annotationTypes)
     	  {
-    	    AnnotationStatistics currentFoldStatistics = singleFoldMap.get(currentAnnotationType);
+    	    AnnotationStatisticsCompact currentFoldStatistics = singleFoldMap.get(currentAnnotationType);
     	    overallStats.get(currentAnnotationType).addAll(currentFoldStatistics);
     	  }
       }
@@ -398,7 +397,7 @@ private static Logger logger = Logger.ge
     	  }
     	  logger.debug("testFiles.size() = " + testFiles.size());
     	  CollectionReader testCollectionReader = evaluation.getCollectionReader(testFiles);
-    	  Map<String, AnnotationStatistics> stats = evaluation.test(testCollectionReader,
modelsDir);
+    	  Map<String, AnnotationStatisticsCompact> stats = evaluation.test(testCollectionReader,
modelsDir);
 
     	  AssertionEvaluation.printScore(stats,  modelsDir.getAbsolutePath());
       }
@@ -476,12 +475,12 @@ private static void printOptionsForDebug
 	logger.info(message);
   }
 
-public static void printScore(Map<String, AnnotationStatistics> map, String directory)
+public static void printScore(Map<String, AnnotationStatisticsCompact> map, String
directory)
   {
-      for (Map.Entry<String, AnnotationStatistics> currentEntry : map.entrySet())
+      for (Map.Entry<String, AnnotationStatisticsCompact> currentEntry : map.entrySet())
 	  {
     	  String annotationType = currentEntry.getKey();
-    	  AnnotationStatistics stats = currentEntry.getValue();
+    	  AnnotationStatisticsCompact stats = currentEntry.getValue();
     	  
     	  System.out.format("directory: \"%s\"; assertion type: %s%n%n%s%n%n",
     	    directory,
@@ -491,11 +490,12 @@ public static void printScore(Map<String
     	  try {
     		  if (useEvaluationLogFile) {
     			  evaluationLogFileOut.write(
-    					  String.format("directory: \"%s\"; assertion type: %s%n%n%s%n%n",
-    							  directory,
-    							  annotationType.toUpperCase(),
-    							  stats.toString())
+    					  String.format("%s\t%f\t%s",
+    							  annotationType,
+    							  options.featureSelectionThreshold,
+    							  stats.toTsv())
     					  );
+    			  evaluationLogFileOut.flush();
     		  }
 		} catch (IOException e) {
 			// TODO Auto-generated catch block
@@ -781,7 +781,7 @@ public static void printScore(Map<String
   }
 
   @Override
-  protected Map<String, AnnotationStatistics> test(CollectionReader collectionReader,
File directory)
+  protected Map<String, AnnotationStatisticsCompact> test(CollectionReader collectionReader,
File directory)
       throws Exception {
 //    AnalysisEngine classifierAnnotator = AnalysisEngineFactory.createPrimitive(AssertionCleartkAnalysisEngine.getDescription(
 //        GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
@@ -839,14 +839,14 @@ public static void printScore(Map<String
     
     AnalysisEngine aggregate = builder.createAggregate();
     
-    AnnotationStatistics polarityStats = new AnnotationStatistics();
-    AnnotationStatistics conditionalStats = new AnnotationStatistics();
-    AnnotationStatistics uncertaintyStats = new AnnotationStatistics();
-    AnnotationStatistics subjectStats = new AnnotationStatistics();
-    AnnotationStatistics genericStats = new AnnotationStatistics();
-    AnnotationStatistics historyStats = new AnnotationStatistics();	// srh 3/6/13
+    AnnotationStatisticsCompact polarityStats = new AnnotationStatisticsCompact();
+    AnnotationStatisticsCompact conditionalStats = new AnnotationStatisticsCompact();
+    AnnotationStatisticsCompact uncertaintyStats = new AnnotationStatisticsCompact();
+    AnnotationStatisticsCompact subjectStats = new AnnotationStatisticsCompact();
+    AnnotationStatisticsCompact genericStats = new AnnotationStatisticsCompact();
+    AnnotationStatisticsCompact historyStats = new AnnotationStatisticsCompact();	// srh
3/6/13
     
-    Map<String, AnnotationStatistics> map = new TreeMap<String, AnnotationStatistics>();

+    Map<String, AnnotationStatisticsCompact> map = new TreeMap<String, AnnotationStatisticsCompact>();

     if (!options.ignorePolarity)
     {
       map.put("polarity",  polarityStats);
@@ -921,8 +921,8 @@ public static void printScore(Map<String
       if (!options.ignorePolarity)
       {
 	      polarityStats.add(goldEntitiesAndEvents, systemEntitiesAndEvents,
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToSpan(),
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToFeatureValue("polarity"));
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToSpan(),
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToFeatureValue("polarity"));
 	      if(options.printErrors){
 	    	  printErrors(jCas, goldEntitiesAndEvents, systemEntitiesAndEvents, "polarity", CONST.NE_POLARITY_NEGATION_PRESENT,
Integer.class);
 	      }
@@ -931,8 +931,8 @@ public static void printScore(Map<String
       if (!options.ignoreConditional)
       {
 	      conditionalStats.add(goldEntitiesAndEvents, systemEntitiesAndEvents,
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToSpan(),
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToFeatureValue("conditional"));
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToSpan(),
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToFeatureValue("conditional"));
 	      if(options.printErrors){
 	    	  printErrors(jCas, goldEntitiesAndEvents, systemEntitiesAndEvents, "conditional",
CONST.NE_CONDITIONAL_TRUE, Boolean.class);
 	      }
@@ -941,8 +941,8 @@ public static void printScore(Map<String
       if (!options.ignoreUncertainty)
       {
 	      uncertaintyStats.add(goldEntitiesAndEvents, systemEntitiesAndEvents,
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToSpan(),
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToFeatureValue("uncertainty"));
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToSpan(),
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToFeatureValue("uncertainty"));
 	      if(options.printErrors){
 	    	  printErrors(jCas, goldEntitiesAndEvents, systemEntitiesAndEvents, "uncertainty",
CONST.NE_UNCERTAINTY_PRESENT, Integer.class);
 	      }
@@ -951,8 +951,8 @@ public static void printScore(Map<String
       if (!options.ignoreSubject)
       {
 	      subjectStats.add(goldEntitiesAndEvents, systemEntitiesAndEvents,
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToSpan(),
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToFeatureValue("subject"));
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToSpan(),
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToFeatureValue("subject"));
 	      if(options.printErrors){
 	    	  printErrors(jCas, goldEntitiesAndEvents, systemEntitiesAndEvents, "subject", null,
CONST.ATTR_SUBJECT_PATIENT.getClass());
 	      }
@@ -961,8 +961,8 @@ public static void printScore(Map<String
       if (!options.ignoreGeneric)
       {
 	      genericStats.add(goldEntitiesAndEvents, systemEntitiesAndEvents,
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToSpan(),
-			  AnnotationStatistics.<IdentifiedAnnotation>annotationToFeatureValue("generic"));
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToSpan(),
+			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToFeatureValue("generic"));
 	      if(options.printErrors){
 	    	  printErrors(jCas, goldEntitiesAndEvents, systemEntitiesAndEvents, "generic", CONST.NE_GENERIC_TRUE,
Boolean.class);
 	      }
@@ -972,8 +972,8 @@ public static void printScore(Map<String
       if (!options.ignoreHistory)
       {
     	  historyStats.add(goldEntitiesAndEvents, systemEntitiesAndEvents,
-    			  AnnotationStatistics.<IdentifiedAnnotation>annotationToSpan(),
-    			  AnnotationStatistics.<IdentifiedAnnotation>annotationToFeatureValue("historyOf"));
+    			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToSpan(),
+    			  AnnotationStatisticsCompact.<IdentifiedAnnotation>annotationToFeatureValue("historyOf"));
     	  if(options.printErrors){
     		  printErrors(jCas, goldEntitiesAndEvents, systemEntitiesAndEvents, "historyOf", CONST.NE_HISTORY_OF_PRESENT,
Integer.class);
     	  }
@@ -993,37 +993,37 @@ public static void printScore(Map<String
 		  FeatureSelection<String> featureSelection; 
 		  if (currentAssertionAttribute.equals("polarity")) {
 			  // TODO: parameterize the thresholds
-			  featureSelection = PolarityCleartkAnalysisEngine.createFeatureSelection(1f);
+			  featureSelection = PolarityCleartkAnalysisEngine.createFeatureSelection(options.featureSelectionThreshold);
 			  featureSelection.train(instances);
 			  featureSelection.save(PolarityCleartkAnalysisEngine.createFeatureSelectionURI(directory));
 		  }
 		  else if (currentAssertionAttribute.equals("uncertainty")) {
 			  // TODO: parameterize the thresholds
-			  featureSelection = UncertaintyCleartkAnalysisEngine.createFeatureSelection(1f);
+			  featureSelection = UncertaintyCleartkAnalysisEngine.createFeatureSelection(options.featureSelectionThreshold);
 			  featureSelection.train(instances);
 			  featureSelection.save(UncertaintyCleartkAnalysisEngine.createFeatureSelectionURI(directory));
 		  }
 		  else if (currentAssertionAttribute.equals("conditional")) {
 			  // TODO: parameterize the thresholds
-			  featureSelection = ConditionalCleartkAnalysisEngine.createFeatureSelection(1f);
+			  featureSelection = ConditionalCleartkAnalysisEngine.createFeatureSelection(options.featureSelectionThreshold);
 			  featureSelection.train(instances);
 			  featureSelection.save(ConditionalCleartkAnalysisEngine.createFeatureSelectionURI(directory));
 		  }
 		  else if (currentAssertionAttribute.equals("subject")) {
 			  // TODO: parameterize the thresholds
-			  featureSelection = SubjectCleartkAnalysisEngine.createFeatureSelection(1f);
+			  featureSelection = SubjectCleartkAnalysisEngine.createFeatureSelection(options.featureSelectionThreshold);
 			  featureSelection.train(instances);
 			  featureSelection.save(SubjectCleartkAnalysisEngine.createFeatureSelectionURI(directory));
 		  }
 		  else if (currentAssertionAttribute.equals("generic")) {
 			  // TODO: parameterize the thresholds
-			  featureSelection = GenericCleartkAnalysisEngine.createFeatureSelection(1f);
+			  featureSelection = GenericCleartkAnalysisEngine.createFeatureSelection(options.featureSelectionThreshold);
 			  featureSelection.train(instances);
 			  featureSelection.save(GenericCleartkAnalysisEngine.createFeatureSelectionURI(directory));
 		  }
 		  else if (currentAssertionAttribute.equals("historyOf")) {
 			  // TODO: parameterize the thresholds
-			  featureSelection = HistoryCleartkAnalysisEngine.createFeatureSelection(1f);
+			  featureSelection = HistoryCleartkAnalysisEngine.createFeatureSelection(options.featureSelectionThreshold);
 			  featureSelection.train(instances);
 			  featureSelection.save(HistoryCleartkAnalysisEngine.createFeatureSelectionURI(directory));
 		  }

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/ConditionalCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/ConditionalCleartkAnalysisEngine.java?rev=1508435&r1=1508434&r2=1508435&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/ConditionalCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/ConditionalCleartkAnalysisEngine.java
Tue Jul 30 13:37:30 2013
@@ -72,7 +72,7 @@ public class ConditionalCleartkAnalysisE
 	      }
 	}
 	public static FeatureSelection<String> createFeatureSelection(double threshold) {
-		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold);
+		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold, false);
 		//		  return new MutualInformationFeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME);
 	}
 

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/GenericCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/GenericCleartkAnalysisEngine.java?rev=1508435&r1=1508434&r2=1508435&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/GenericCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/GenericCleartkAnalysisEngine.java
Tue Jul 30 13:37:30 2013
@@ -94,7 +94,7 @@ public class GenericCleartkAnalysisEngin
 	      }
 	}
 	public static FeatureSelection<String> createFeatureSelection(double threshold) {
-		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold);
+		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold, false);
 		//		  return new MutualInformationFeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME);
 	}
 

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java?rev=1508435&r1=1508434&r2=1508435&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/HistoryCleartkAnalysisEngine.java
Tue Jul 30 13:37:30 2013
@@ -97,7 +97,7 @@ public class HistoryCleartkAnalysisEngin
 	      }
 	}
 	public static FeatureSelection<String> createFeatureSelection(double threshold) {
-		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold);
+		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold, false);
 		//		  return new MutualInformationFeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME);
 	}
 

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java?rev=1508435&r1=1508434&r2=1508435&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/PolarityCleartkAnalysisEngine.java
Tue Jul 30 13:37:30 2013
@@ -93,7 +93,7 @@ public class PolarityCleartkAnalysisEngi
 	      }
 	}
 	public static FeatureSelection<String> createFeatureSelection(double threshold) {
-		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold);
+		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold, false);
 		//		  return new MutualInformationFeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME);
 	}
 

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/SubjectCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/SubjectCleartkAnalysisEngine.java?rev=1508435&r1=1508434&r2=1508435&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/SubjectCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/SubjectCleartkAnalysisEngine.java
Tue Jul 30 13:37:30 2013
@@ -97,7 +97,7 @@ public class SubjectCleartkAnalysisEngin
 	      }
 	}
 	public static FeatureSelection<String> createFeatureSelection(double threshold) {
-		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold);
+		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold, false);
 		//		  return new MutualInformationFeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME);
 	}
 

Modified: ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java?rev=1508435&r1=1508434&r2=1508435&view=diff
==============================================================================
--- ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java
(original)
+++ ctakes/trunk/ctakes-assertion/src/main/java/org/apache/ctakes/assertion/medfacts/cleartk/UncertaintyCleartkAnalysisEngine.java
Tue Jul 30 13:37:30 2013
@@ -79,7 +79,7 @@ public class UncertaintyCleartkAnalysisE
 	}
 	
 	public static FeatureSelection<String> createFeatureSelection(double threshold) {
-		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold);
+		return new Chi2FeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME,
threshold, false);
 		//		  return new MutualInformationFeatureSelection<String>(AssertionCleartkAnalysisEngine.FEATURE_SELECTION_NAME);
 	}
 

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=1508435&r1=1508434&r2=1508435&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
Tue Jul 30 13:37:30 2013
@@ -14,11 +14,11 @@ public class CrossValidateChi2GridSearch
 		
 		AssertionEvaluation.useEvaluationLogFile = true;
 		
-		float[] threshs = {2f, 5f, 10f, 20f, 50f, 100f};
+		float[] threshs = {1f, 5f, 10f, 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();
+//			AssertionEvaluation.evaluationLogFileOut.write("BEGIN Chi2 Grid Search with threshold
= "+ Float.toString(chi2threshold)+"\n");
+//			AssertionEvaluation.evaluationLogFileOut.flush();
 			
 			for (String attribute : AssertionConst.annotationTypes) {
 



Mime
View raw message