E - The type of objects being classified by the evaluated classifier.public class BaseClassifierEvaluator<E> extends Object implements ObjectHandler<Classified<E>>
BaseClassifierEvaluator provides an evaluation harness
for first-best classifiers. An evaluator is constructed from a classifier and
a complete list of the categories returned by the classifier.
Test cases are then added using the handle(Classified)
which accepts a string-based category and object to classify. The
evaluator will run the classifier over the input object and collect
results over multiple cases.
There are subtypes of this classifier that evaluate richer classifiers.
An exhaustive set of evaluation metrics for first-best
classification results is accessbile as a confusion matrix through
the confusionMatrix() method. Confusion matrices provide
dozens of statistics on classification which can be computed from
first-best results; see ConfusionMatrix for more
information.
This class requires concurrent read and synchronous write synchronization. Reads are any of the statistics gathering methods and write is just adding new test cases.
true, all input cases
are stored. This enables the output of true positives, false
positives, false negatives, and true negatives through the methods
of the same names.| Constructor and Description |
|---|
BaseClassifierEvaluator(BaseClassifier<E> classifier,
String[] categories,
boolean storeInputs)
Construct a classifier evaluator for the specified classifier
that records results for the specified set of categories,
storing cases or not based on the specified flag.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addClassification(String referenceCategory,
Classification classification,
E input)
Adds the specified classification as a response for the specified
reference category.
|
String[] |
categories()
Returns a copy of the the categories for which this evaluator
stores results.
|
BaseClassifier<E> |
classifier()
Returns the classifier for this evaluator.
|
ConfusionMatrix |
confusionMatrix()
Returns the confusion matrix of first-best classification
result statistics for this evaluator.
|
List<Classified<E>> |
falseNegatives(String category)
Returns the list of false negative cases along with their
classifications for items of the specified category.
|
List<Classified<E>> |
falsePositives(String category)
Returns the list of false positive cases along with their
classifications for items of the specified category.
|
void |
handle(Classified<E> classified)
Add the specified classified object to this evaluator.
|
int |
numCases()
Returns the number of test cases which have been provided
to this evaluator.
|
int |
numCategories()
Returns the number of categories for the classifier being
evaluated.
|
PrecisionRecallEvaluation |
oneVersusAll(String refCategory)
Returns the first-best one-versus-all precision-recall
evaluation of the classification of the specified reference
category versus all other categories.
|
void |
setClassifier(BaseClassifier<E> classifier)
Set the classfier for this evaluator to the specified value.
|
String |
toString()
Return a string-based representation of the results of the
evaluation.
|
List<Classified<E>> |
trueNegatives(String category)
Returns the list of true negative cases along with their
classifications for items of the specified category.
|
List<Classified<E>> |
truePositives(String category)
Returns the list of true positive cases along with their
classifications for items of the specified category.
|
public BaseClassifierEvaluator(BaseClassifier<E> classifier, String[] categories, boolean storeInputs)
If the classifier evaluator is only going to be populated
using the addClassification(String,Classification,Object)
method, then the classifier may be null.
classifier - Classifier to evaluate.categories - Categories of the classifier.storeInputs - Flag indicating whether input cases should be
stored.public int numCategories()
public String[] categories()
public BaseClassifier<E> classifier()
public void setClassifier(BaseClassifier<E> classifier)
This method will throw an exception if called from an evaluator with a more specific runtime type.
classifier - New classifier for this evaluator.IllegalArgumentException - If called from a class with
a runtime type other than BaseClassifierEvaluator.public List<Classified<E>> truePositives(String category)
The cases will be returned in decreasing order of conditional probability if applicable, decreasing order of score otherwise, and if not scored, in the order in which they were processed.
A true positive case for the specified category has reference category equal to the specified category and first-best classification result equal to the specified category.
category - Category whose cases are returned.UnsupportedOperationException - If this class does not
store its cases.public List<Classified<E>> falsePositives(String category)
A false positive case for the specified category has reference category unequal to the specified category and first-best classification result equal to the specified category.
category - Category whose cases are returned.UnsupportedOperationException - If this class does not
store its cases.public List<Classified<E>> falseNegatives(String category)
A false negative case for the specified category has reference category equal to the specified category and first-best classification result unequal to the specified category.
category - Category whose cases are returned.UnsupportedOperationException - If this class does not
store its cases.public List<Classified<E>> trueNegatives(String category)
A true negative case for the specified category has reference category unequal to the specified category and first-best classification result unequal to the specified category.
category - Category whose cases are returned.UnsupportedOperationException - If this class does not
store its cases.public void handle(Classified<E> classified)
handle in interface ObjectHandler<Classified<E>>classified - Classified object to add to evaluation.public void addClassification(String referenceCategory, Classification classification, E input)
referenceCategory - Reference category for case.classification - Response classification for case.input - Input for the specified classification.public int numCases()
public ConfusionMatrix confusionMatrix()
ConfusionMatrix for details of the numerous available
evaluation metrics provided by confusion matrices.public PrecisionRecallEvaluation oneVersusAll(String refCategory)
refCategory - Reference category.IllegalArgumentException - If the specified category
is unknown.Copyright © 2016 Alias-i, Inc.. All rights reserved.