private void eval(Event @event, bool real) { string outcome = @event.Outcome; // Is ignored string[] context = @event.Context; double[] ocs; if (!real) { ocs = _model.eval(context); } else { float[] values = RealValueFileEventStream.parseContexts(context); ocs = _model.eval(context, values); } int numOutcomes = ocs.Length; DoubleStringPair[] result = new DoubleStringPair[numOutcomes]; for (int i = 0; i < numOutcomes; i++) { result[i] = new DoubleStringPair(ocs[i], _model.getOutcome(i)); } Array.Sort(result); // Print the most likely outcome first, down to the least likely. for (int i = numOutcomes - 1; i >= 0; i--) { Console.Write(result[i].stringValue + " " + result[i].doubleValue + " "); } Console.WriteLine(); }
public static void eval(MaxentModel model, Reader r, Evalable e, bool verbose) { float totPos = 0, truePos = 0, falsePos = 0; Event[] events = (e.getEventCollector(r)).getEvents(true); //MaxentModel model = e.getModel(dir, name); string negOutcome = e.NegativeOutcome; foreach (Event @event in events) { string guess = model.getBestOutcome(model.eval(@event.Context)); string ans = @event.Outcome; if (verbose) { Console.WriteLine(ans + " " + guess); } if (!ans.Equals(negOutcome)) { totPos++; } if (!guess.Equals(negOutcome) && !guess.Equals(ans)) { falsePos++; } else if (ans.Equals(guess)) { truePos++; } } Console.WriteLine("Precision: " + truePos / (truePos + falsePos)); Console.WriteLine("Recall: " + truePos / totPos); }