Class EvaluationListener<A extends Classifier>

  • Type Parameters:
    A - the type of the classifier.
    All Implemented Interfaces:
    IterationCompletionListener

    public class EvaluationListener<A extends Classifier>
    extends java.lang.Object
    implements IterationCompletionListener
    The evaluation listener is majorly used to track the overfitting of a classifier while training. This is usually hooked into the Minimizer of choice and will be triggered at a configurable interval of iterations (through setRunInterval(int)). This class is designed to be subclasses and enhanced with other print statements or functionality to save the best performing parameters.
    Author:
    thomas.jungblut
    • Constructor Detail

      • EvaluationListener

        public EvaluationListener​(WeightMapper<A> mapper,
                                  EvaluationSplit split)
        Initializes this listener.
        Parameters:
        mapper - the mapper that converts the DoubleVector from the minimizable CostFunction to a classifier.
        split - the train/test split.
      • EvaluationListener

        public EvaluationListener​(WeightMapper<A> mapper,
                                  EvaluationSplit split,
                                  int runInterval)
        Initializes this listener.
        Parameters:
        mapper - the mapper that converts the DoubleVector from the minimizable CostFunction to a classifier.
        split - the train/test split.
        runInterval - test interval.
    • Method Detail

      • onIterationFinished

        public void onIterationFinished​(int iteration,
                                        double cost,
                                        de.jungblut.math.DoubleVector currentWeights)
        Description copied from interface: IterationCompletionListener
        This callback is called from a AbstractMinimizer when a iteration of a minimization objective is finished.
        Specified by:
        onIterationFinished in interface IterationCompletionListener
        Parameters:
        iteration - the number of the current iteration.
        cost - the cost at the current iteration.
        currentWeights - the current optimal weights.
      • setRunInterval

        public final void setRunInterval​(int runInterval)
        Sets the run intervall of this listener. For example: if set to 5, the evaluator will run only every five iterations.
      • onResult

        protected void onResult​(int iteration,
                                double cost,
                                Evaluator.EvaluationResult trainEval,
                                Evaluator.EvaluationResult testEval)
        Will be called on a result of the evaluation. This method does nothing, is designed to be overridden though.
        Parameters:
        iteration - the current number of iteration.
        cost - the identified cost of the costfunction.
        trainEval - the evaluation on the trainingset.
        testEval - the evaluation on the testset.