Package de.jungblut.classification.eval
Class EvaluationListener<A extends Classifier>
- java.lang.Object
-
- de.jungblut.classification.eval.EvaluationListener<A>
-
- 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 theMinimizerof choice and will be triggered at a configurable interval of iterations (throughsetRunInterval(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
-
-
Field Summary
Fields Modifier and Type Field Description protected WeightMapper<A>mapperprotected intrunIntervalprotected EvaluationSplitsplit
-
Constructor Summary
Constructors Constructor Description EvaluationListener(WeightMapper<A> mapper, EvaluationSplit split)Initializes this listener.EvaluationListener(WeightMapper<A> mapper, EvaluationSplit split, int runInterval)Initializes this listener.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonIterationFinished(int iteration, double cost, de.jungblut.math.DoubleVector currentWeights)This callback is called from aAbstractMinimizerwhen a iteration of a minimization objective is finished.protected voidonResult(int iteration, double cost, Evaluator.EvaluationResult trainEval, Evaluator.EvaluationResult testEval)Will be called on a result of the evaluation.voidsetRunInterval(int runInterval)Sets the run intervall of this listener.
-
-
-
Field Detail
-
split
protected final EvaluationSplit split
-
mapper
protected final WeightMapper<A extends Classifier> mapper
-
runInterval
protected int runInterval
-
-
Constructor Detail
-
EvaluationListener
public EvaluationListener(WeightMapper<A> mapper, EvaluationSplit split)
Initializes this listener.- Parameters:
mapper- the mapper that converts theDoubleVectorfrom the minimizableCostFunctionto 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 theDoubleVectorfrom the minimizableCostFunctionto 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:IterationCompletionListenerThis callback is called from aAbstractMinimizerwhen a iteration of a minimization objective is finished.- Specified by:
onIterationFinishedin interfaceIterationCompletionListener- 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.
-
-