|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.classifier.assessment.ClassifierAssessment
public abstract class ClassifierAssessment
Class defining an assessment of classifiers.
It should be used as a super-class for specialized classifier-assessments like k-fold-crossvalidation or
subsampling-crossvalidation.
Several standard tasks like classifier- or model-management (testing, training) are implemented. The method
assess
should be used the standard-method to start a classifier-assessment. Subclasses have to
implement the method evaluateClassifier()
. This method mainly has to execute the construction of
test- and training-subsets of the given data. These test- and training-subsets may be used by the methods
test()
and train()
which already are implemented in a standard way.
Field Summary | |
---|---|
protected AbstractClassifier[] |
myAbstractClassifier
This array contains the internal used classifiers. |
protected boolean |
myBuildClassifierByCrossProduct
|
protected Model[][] |
myModel
This array contains for each class the internal used models. |
protected MeanResultSet[] |
myTempMeanResultSets
|
protected int |
skipLastClassifiersDuringClassifierTraining
|
Constructor Summary | |
---|---|
|
ClassifierAssessment(AbstractClassifier... aCs)
Creates a new ClassifierAssessment from a set of AbstractClassifier s. |
|
ClassifierAssessment(AbstractClassifier[] aCs,
boolean buildClassifiersByCrossProduct,
Model[]... aMs)
This constructor allows to assess a collection of given AbstractClassifier s and those constructed
using the given AbstractModel s. |
protected |
ClassifierAssessment(AbstractClassifier[] aCs,
Model[][] aMs,
boolean buildClassifiersByCrossProduct,
boolean checkAlphabetConsistencyAndLength)
Creates a new ClassifierAssessment from an array of AbstractClassifier s and a two-dimensional array
of Model s, which are combined to additional classifiers. |
|
ClassifierAssessment(boolean buildClassifiersByCrossProduct,
Model[]... aMs)
Creates a new ClassifierAssessment from a set of Model s. |
Method Summary | |
---|---|
ListResult |
assess(MeasureParameters mp,
ClassifierAssessmentAssessParameterSet assessPS,
ProgressUpdater pU,
Sample... s)
Assesses the contained classifiers. |
ListResult |
assess(MeasureParameters mp,
ClassifierAssessmentAssessParameterSet assessPS,
ProgressUpdater pU,
Sample[][]... s)
|
ListResult |
assess(MeasureParameters mp,
ClassifierAssessmentAssessParameterSet assessPS,
Sample... s)
Assesses the contained classifiers. |
protected abstract boolean |
evaluateClassifier(MeasureParameters mp,
ClassifierAssessmentAssessParameterSet assessPS,
Sample[] s,
ProgressUpdater pU)
This method must be implemented in all subclasses. |
AbstractClassifier[] |
getClassifier()
Returns a deep copy of all classifiers that have been or will be used in this assessment. |
String |
getNameOfAssessment()
|
protected void |
prepareAssessment(Sample... s)
Prepares an assessment. |
protected void |
test(MeasureParameters mp,
boolean exception,
Sample... testS)
Uses the given test-Samples to call the evaluate -methods of the local
AbstractClassifier s. |
protected void |
train(Sample... trainS)
Trains the local classifiers using the given trainingSamples. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected AbstractClassifier[] myAbstractClassifier
protected Model[][] myModel
protected MeanResultSet[] myTempMeanResultSets
protected int skipLastClassifiersDuringClassifierTraining
protected boolean myBuildClassifierByCrossProduct
Constructor Detail |
---|
protected ClassifierAssessment(AbstractClassifier[] aCs, Model[][] aMs, boolean buildClassifiersByCrossProduct, boolean checkAlphabetConsistencyAndLength) throws IllegalArgumentException, WrongAlphabetException, CloneNotSupportedException, ClassDimensionException
ClassifierAssessment
from an array of AbstractClassifier
s and a two-dimensional array
of Model
s, which are combined to additional classifiers. If buildClassifiersByCrossProduct
is true
,
the cross product of all Model
s in aMs
is built to obtain these classifiers.
aCs
- the pre-defined classifiersaMs
- the Model
s that are used to build additional classifiersbuildClassifiersByCrossProduct
- Determines how classifiers are constructed using the given models. Suppose a k-class problem. In this
case, each classifier is supposed to consist of k models, one responsible for each class. checkAlphabetConsistencyAndLength
- indicates if alphabets and lengths shall be checked for consistency
IllegalArgumentException
WrongAlphabetException
CloneNotSupportedException
ClassDimensionException
public ClassifierAssessment(AbstractClassifier... aCs) throws IllegalArgumentException, WrongAlphabetException, CloneNotSupportedException, ClassDimensionException
ClassifierAssessment
from a set of AbstractClassifier
s.
aCs
- contains the classifiers to be assessedIllegalArgumentException
WrongAlphabetException
- if not all given classifiers are defined on the same AlphabetContainer
ClassDimensionException
CloneNotSupportedException
public ClassifierAssessment(boolean buildClassifiersByCrossProduct, Model[]... aMs) throws IllegalArgumentException, WrongAlphabetException, CloneNotSupportedException, ClassDimensionException
ClassifierAssessment
from a set of Model
s. The argument buildClassifiersByCrossProduct
determines how these Model
s are combined to classifiers.
buildClassifiersByCrossProduct
- aMs
- WrongAlphabetException
- if not all given models are defines on the same AlphabetContainer
IllegalArgumentException
CloneNotSupportedException
ClassDimensionException
public ClassifierAssessment(AbstractClassifier[] aCs, boolean buildClassifiersByCrossProduct, Model[]... aMs) throws IllegalArgumentException, WrongAlphabetException, CloneNotSupportedException, ClassDimensionException
AbstractClassifier
s and those constructed
using the given AbstractModel
s.
aCs
- contains some AbstractClassifier
that should be assessed in addition to the
AbstractClassifiers
constructed using the given AbstractModels
buildClassifiersByCrossProduct
- aMs
- WrongAlphabetException
- if not all given models are defines on the same AlphabetContainer
IllegalArgumentException
CloneNotSupportedException
ClassDimensionException
Method Detail |
---|
public ListResult assess(MeasureParameters mp, ClassifierAssessmentAssessParameterSet assessPS, Sample... s) throws IllegalArgumentException, WrongAlphabetException, Exception
s
- contains the data to be used for assessment. The order of samples is important. mp
- defines which performance-measure should be used to assess classifiersassessPS
- contains some parameters necessary for assessment (depends on the kind of assessment!)
MeasureParameters
.
IllegalArgumentException
- if given assessPS is not of right type (see method evaluateClassifier())
WrongAlphabetException
- if given Samples s do not use the same AlphabetContainer
as contained
classifiers/models
Exception
- forwarded from training/testing of classifiers/modelspublic ListResult assess(MeasureParameters mp, ClassifierAssessmentAssessParameterSet assessPS, ProgressUpdater pU, Sample... s) throws IllegalArgumentException, WrongAlphabetException, Exception
s
- contains the data to be used for assessment. The order of samples is important. mp
- defines which performance-measure should be used to assess classifiersassessPS
- contains some parameters necessary for assessment (depends on the kind of assessment!)pU
- this ProgressUpdater
may be used to cancel this method assess()
by
setting pU.isCandeled=true
. In that case, assess
will abort but return
results already computed.KFoldCrossValidation
. In this case it might be wise to override this method such that
it just returns an error-message. null
although in this case it may be more convenient to use the
second method code
not requiring a ProgressUpdater
.
MeasureParameters
.
IllegalArgumentException
- if given assessPS is not of right type (see method evaluateClassifier())
WrongAlphabetException
- if given Samples s do not use the same AlphabetContainer
as contained
classifiers/models
Exception
- forwarded from training/testing of classifiers/modelspublic ListResult assess(MeasureParameters mp, ClassifierAssessmentAssessParameterSet assessPS, ProgressUpdater pU, Sample[][]... s) throws IllegalArgumentException, WrongAlphabetException, Exception
s
- Contains the data to be used for assessment.assess(MeasureParameters, AssessParameterSet, Sample)
.mp
- defines which performance-measure should be used to assess classifiersassessPS
- Contains some parameters necessary for assessment. Must be of type
ClassifierAssessmentAssessParameterSet
pU
- This ProgressUpdater
allows to abort this classifier assessment. If
pU.isCalceled()
is true, all results already computed will be returned. It is allowed
to give a null-reference.
MeasureParameters
.
IllegalArgumentException
- if given assessPS is not of right type (see method evaluateClassifier())
WrongAlphabetException
- if given Samples s do not use the same AlphabetContainer
as contained
classifiers/models
Exception
- forwarded from training/testing of classifiers/modelspublic AbstractClassifier[] getClassifier() throws CloneNotSupportedException
CloneNotSupportedException
- if it is imppossible to get an deep copy for at least one classifierpublic String getNameOfAssessment()
protected abstract boolean evaluateClassifier(MeasureParameters mp, ClassifierAssessmentAssessParameterSet assessPS, Sample[] s, ProgressUpdater pU) throws IllegalArgumentException, Exception
mp
- defines which performance-measures are used to assess classifiersassessPS
- containes assessment-specific parameters (like: number of iterations of a k-fold-crossvalidation)s
- data to be used for assessment (both: test- and train-data)pU
- a ProgressUpdater
that mainly has to be used to allow the user to cancel a current
running alssifier assessment. This ProgressUpdater
is guaranteed to be not
null
. In certain cases aborting a classifier assessment will not be allowed for
example in case of KFoldCrossValidation
. In this case the given
ProgressUpdater
should be ignored. pU.setMax()
= number of iterations of the assessment-loop
assessment-loop
pU.setValue()
=iteration+1;
Sample
treatment
train()
;
test()
;
repeat unless(ready or not(pU.isCanceled()))
IllegalArgumentException
- if the given AssessParameterSet
is of wrong type
Exception
- that occured during training or using classifiers/modelsprotected void prepareAssessment(Sample... s) throws WrongAlphabetException
Sample
may not be used for this assessment, this method
throws an exception. MeanResultSet
s are initiated for this assessment (one for each contained classifier).
s
- the Sample
to be checked
WrongAlphabetException
- if AlphabetContainer
of s are not consistent with AlphabetContainer
of
local models or classifiersprotected void test(MeasureParameters mp, boolean exception, Sample... testS) throws SimpleParameter.IllegalValueException, MeanResultSet.InconsistentResultNumberException, MeanResultSet.AdditionImpossibleException, Exception
evaluate
-methods of the local
AbstractClassifier
s. The returned NumericalResults
as well as the numerical
characteristics are added to each classifiers MeanResultSet
.
mp
- determines which performance-measures are used to assess the classifiersexception
- whether an Exception
should be thrown if some MeasureParameters.Measure
could not be evaluatedtestS
- samples used as test-sets (has to contain one Sample
for each class)
IllegalArgumentException
- if the length of testS is not equal to the dimension of the classification-problem
(testS.length!=this.myAbstractClassifier[0].getNumberOfClasses())
SimpleParameter.IllegalValueException
MeanResultSet.InconsistentResultNumberException
MeanResultSet.AdditionImpossibleException
Exception
AbstractClassifier.evaluate(MeasureParameters, boolean, Sample...)
protected void train(Sample... trainS) throws IllegalArgumentException, Exception
ClassifierAssessment
-object was constructed using AbstractModel
s.
trainS
- samples used as train-sets (has to contain one Sample
for each class)
IllegalArgumentException
- if the length of trainS is not equal to the dimension of the classification-problem
(trainS.length!=this.myAbstractClassifier[0].getNumberOfClasses())
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |