On 8/18/11 5:00 PM, [email protected] wrote:
+ public synchronized void addListener(EvaluationSampleListener<T> listener) {
+ this.listeners.add(listener);
+ }
+
+ public synchronized void removeListener(EvaluationSampleListener<T>
listener) {
+ this.listeners.remove(listener);
+ }
+
Why did you declared these as synchronized? Anyway I think the way it
was before was
actually better. There we just had one listener per evaluator, which
could be set in the
constructor.
An evaluator is not something which lives long, and you really want to
make sure to
hook up your listeners, before you started with the evaluation,
otherwise you might
miss samples.
We need to spend a little time to think about how these
correctly/miss-classified notifications
can be done for the cross validator. Maybe we need to extend the interface
a little to make that meaningful.
+ protected void notifyCorrectlyClassified(T reference, T prediction) {
+ for (EvaluationSampleListener<T> listener : listeners) {
+ listener.correctlyClassified(reference, prediction);
+ }
+ }
+
+ protected void notifyMissclassified(T reference, T prediction) {
+ for (EvaluationSampleListener<T> listener : listeners) {
+ listener.missclassified(reference, prediction);
+ }
+ }
These you declared later as private, we can then just inline that. Makes the
code easier to read.
Jörn