Commits

Anonymous committed c2a34a8

mean-error histogram's code

  • Participants
  • Parent commits 9a3b919

Comments (0)

Files changed (2)

File .cache

Binary file modified.

File src/main/scala/opennlp/textgrounder/temporal/TemporalEvaluation.scala

   driver_stats, prefix, max_rank_for_credit) {
   val degree_dists = mutable.Buffer[Double]()
   val oracle_degree_dists = mutable.Buffer[Double]()
+  val error_histograms = mutable.HashMap[TemporalCoord,(Int, Double)]()
 
   def record_result(rank: Int, pred_true_dist: Double,
       pred_degree_dist: Double) {
     super.record_result(rank, pred_true_dist)
     degree_dists += pred_degree_dist
   }
+  
+  def record_histogram(true_center: TemporalCoord, pred_degdist: Double){
+    var value=error_histograms.get(true_center)
+    value match{
+      case Some(x) =>{error_histograms.put(true_center,(x._1+1,x._2+pred_degdist))}
+      case None => error_histograms.put(true_center,(1,pred_degdist))
+    }
+  }
 
   def record_oracle_result(oracle_true_dist: Double,
       oracle_degree_dist: Double) {
       mean(degree_dists))
     errprint("  Median error distance = %.2f Years",
       median(degree_dists))
+    for(coord <- error_histograms.keySet){
+      var value = error_histograms.get(coord)
+      println(coord.toString()+"\t",value.get._2/value.get._1,value.get._1)
+    }
 //    errprint("  Median oracle true error distance = %s",
 //      km_and_miles(median(oracle_true_dists)))
   }
   override def record_one_result(stats: TBasicEvalStats,
       res: TDocEvalRes) {
     stats.record_result(res.true_rank, res.pred_truedist, res.pred_degdist)
+    stats.record_histogram(res.true_center, res.pred_degdist)
   }
 
   override def record_one_oracle_result(stats: TBasicEvalStats,