de.jstacs.classifiers.assessment
Class RepeatedSubSamplingExperiment

java.lang.Object
  extended by de.jstacs.classifiers.assessment.ClassifierAssessment<RepeatedSubSamplingAssessParameterSet>
      extended by de.jstacs.classifiers.assessment.RepeatedSubSamplingExperiment

public class RepeatedSubSamplingExperiment
extends ClassifierAssessment<RepeatedSubSamplingAssessParameterSet>

This class implements a repeated subsampling experiment. A repeated subsampling experiment uses the following procedure to assess classifiers.
The user supplies data sets for each class the classifiers are capable to distinguish. In each step of the repeated subsampling these data sets are used to generate test and train data sets by subsampling of these data sets. Hence, the subsampled train and test data set of each class do not have to be disjoint. The user defines how many elements the subsampled test and train data sets should contain. After subampling the train data sets are used to train the classifiers and the test data sets are used to assess the performance of the classifiers to predict the elements therein. Additionally the user defines how often these procedure should be repeated and which assessment measures are used to assess the classifiers.

Author:
Andre Gohr (bioinf (nospam:.) ag (nospam:@) googlemail (nospam:.) com)

Field Summary
 
Fields inherited from class de.jstacs.classifiers.assessment.ClassifierAssessment
myAbstractClassifier, myModel, myTempMeanResultSets, skipLastClassifiersDuringClassifierTraining
 
Constructor Summary
  RepeatedSubSamplingExperiment(AbstractClassifier... aCs)
          Creates a new RepeatedSubSamplingExperiment from a set of AbstractClassifiers.
  RepeatedSubSamplingExperiment(AbstractClassifier[] aCs, boolean buildClassifiersByCrossProduct, TrainableStatisticalModel[]... aMs)
          This constructor allows to assess a collection of given AbstractClassifiers and those constructed using the given TrainableStatisticalModels by a RepeatedSubSamplingExperiment.
protected RepeatedSubSamplingExperiment(AbstractClassifier[] aCs, TrainableStatisticalModel[][] aMs, boolean buildClassifiersByCrossProduct, boolean checkAlphabetConsistencyAndLength)
          Creates a new RepeatedSubSamplingExperiment from an array of AbstractClassifiers and a two-dimensional array of TrainableStatisticalModel s, which are combined to additional classifiers.
  RepeatedSubSamplingExperiment(boolean buildClassifiersByCrossProduct, TrainableStatisticalModel[]... aMs)
          Creates a new RepeatedSubSamplingExperiment from a set of TrainableStatisticalModels.
 
Method Summary
protected  void evaluateClassifier(NumericalPerformanceMeasureParameterSet mp, RepeatedSubSamplingAssessParameterSet assessPS, DataSet[] s, double[][] weights, ProgressUpdater pU)
          Evaluates the classifier.
 RepeatedSubSamplingAssessParameterSet getAssessParameterSet()
          This method returns an instance of ClassifierAssessmentAssessParameterSet that can be used in the assess methods.
 
Methods inherited from class de.jstacs.classifiers.assessment.ClassifierAssessment
assess, assess, assess, assess, getClassifier, getNameOfAssessment, prepareAssessment, test, train
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepeatedSubSamplingExperiment

protected RepeatedSubSamplingExperiment(AbstractClassifier[] aCs,
                                        TrainableStatisticalModel[][] aMs,
                                        boolean buildClassifiersByCrossProduct,
                                        boolean checkAlphabetConsistencyAndLength)
                                 throws IllegalArgumentException,
                                        WrongAlphabetException,
                                        CloneNotSupportedException,
                                        ClassDimensionException
Creates a new RepeatedSubSamplingExperiment from an array of AbstractClassifiers and a two-dimensional array of TrainableStatisticalModel s, which are combined to additional classifiers. If buildClassifiersByCrossProduct is true, the cross-product of all TrainableStatisticalModels in aMs is built to obtain these classifiers.

Parameters:
aCs - the predefined classifiers
aMs - the TrainableStatisticalModels that are used to build additional classifiers
buildClassifiersByCrossProduct - 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.
Let S_i be the set of all models in aMs[i]. Let S be the set S_1 x S_2 x ... x S_k (cross-product).

true: all possible classifiers consisting of a subset (set of k models) of S are constructed
false: one classifier consisting of the models aMs[0][i],aMs[1][i],..., aMs[k][i] for a fixed i is constructed. In this case, all second dimensions of aMs have to be equal, say m. In total m classifiers are constructed.
checkAlphabetConsistencyAndLength - indicates if alphabets and lengths shall be checked for consistency
Throws:
IllegalArgumentException - if the classifiers have different lengths
WrongAlphabetException - if the classifiers use different alphabets
CloneNotSupportedException - if something went wrong while cloning
ClassDimensionException - if there is something wrong with the class dimension of the classifier
See Also:
ClassifierAssessment.ClassifierAssessment(AbstractClassifier[], TrainableStatisticalModel[][], boolean, boolean)

RepeatedSubSamplingExperiment

public RepeatedSubSamplingExperiment(AbstractClassifier... aCs)
                              throws IllegalArgumentException,
                                     WrongAlphabetException,
                                     CloneNotSupportedException,
                                     ClassDimensionException
Creates a new RepeatedSubSamplingExperiment from a set of AbstractClassifiers.

Parameters:
aCs - contains the classifiers to be assessed.
If model based classifiers are trained, the order of the models in the classifiers determines, which model will be trained using which data set in method assess( ... ).
For a two-class problem, it is recommended
  • to initiate the classifiers with models in order (foreground model (positive class), background model (negative class))
  • to initiate a assessment object using models in order (foreground model (positive class), background model (negative class))
  • to give data s in order (s[0] contains foreground data, s[1] contains background data)
Throws:
IllegalArgumentException - if the classifiers have different lengths
WrongAlphabetException - if not all given classifiers are defined on the same AlphabetContainer
CloneNotSupportedException - if something went wrong while cloning
ClassDimensionException - if there is something wrong with the class dimension of the classifier
See Also:
ClassifierAssessment.ClassifierAssessment(AbstractClassifier...)

RepeatedSubSamplingExperiment

public RepeatedSubSamplingExperiment(boolean buildClassifiersByCrossProduct,
                                     TrainableStatisticalModel[]... aMs)
                              throws IllegalArgumentException,
                                     WrongAlphabetException,
                                     CloneNotSupportedException,
                                     ClassDimensionException
Creates a new RepeatedSubSamplingExperiment from a set of TrainableStatisticalModels. The argument buildClassifiersByCrossProduct determines how these TrainableStatisticalModels are combined to classifiers.

Parameters:
buildClassifiersByCrossProduct -
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.
Let S_i be the set of all models in aMs[i]. Let S be the set S_1 x S_2 x ... x S_k (cross-product).

true: all possible classifiers consisting of a subset (set of k models) of S are constructed
false: one classifier consisting of the models aMs[0][i],aMs[1][i],..., aMs[k][i] for a fixed i is constructed. In this case, all second dimensions of aMs have to be equal, say m. In total m classifiers are constructed.
aMs -
Contains the models in the following way (suppose a k-class problem): the first dimension encodes the class (here it is k), the second dimension (aMs[i]) contains the models according to class i.
If the models are trained directly (during assessment), the order of given models during initiation of this assessment object determines, which data set will be used for training which model. In general the first model will be trained using the first data set in s... .
For a two-class problem, it is recommended
  • to initiate the classifiers with models in order (foreground model (positive class), background model (negative class))
  • to initiate an assessment object using models in order (foreground model (positive class), background model (negative class))
  • to give data s in order (s[0] contains foreground data, s[1] contains background data)
Throws:
IllegalArgumentException - if the classifiers have different lengths
WrongAlphabetException - if not all given classifiers are defined on the same AlphabetContainer
CloneNotSupportedException - if something went wrong while cloning
ClassDimensionException - if there is something wrong with the class dimension of the classifier
See Also:
ClassifierAssessment.ClassifierAssessment(boolean, TrainableStatisticalModel[][])

RepeatedSubSamplingExperiment

public RepeatedSubSamplingExperiment(AbstractClassifier[] aCs,
                                     boolean buildClassifiersByCrossProduct,
                                     TrainableStatisticalModel[]... aMs)
                              throws IllegalArgumentException,
                                     WrongAlphabetException,
                                     CloneNotSupportedException,
                                     ClassDimensionException
This constructor allows to assess a collection of given AbstractClassifiers and those constructed using the given TrainableStatisticalModels by a RepeatedSubSamplingExperiment.

Parameters:
aCs - contains some AbstractClassifier that should be assessed in addition to the AbstractClassifier constructed using the given TrainableStatisticalModels
buildClassifiersByCrossProduct -
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.
Let S_i be the set of all models in aMs[i]. Let S be the set S_1 x S_2 x ... x S_k (cross-product).

true: all possible classifiers consisting of a subset (set of k models) of S are constructed
false: one classifier consisting of the models aMs[0][i],aMs[1][i],..., aMs[k][i] for a fixed i is constructed. In this case, all second dimensions of aMs have to be equal, say m. In total m classifiers are constructed.
aMs -
Contains the models in the following way (suppose a k-class problem): the first dimension encodes the class (here it is k), the second dimension (aMs[i]) contains the models according to class i.
If models are trained directly (during assessment), the order of given models during initiation of this assessment object determines, which data set will be used for training which model. In general the first model will be trained using the first data set in s... .
For a two-class problem, it is recommended
  • to initiate the classifiers with models in order (foreground model (positive class), background model (negative class))
  • to initiate an assessment object using models in order (foreground model (positive class), background model (negative class))
  • to give data s in order (s[0] contains foreground data, s[1] contains background data)
Throws:
IllegalArgumentException - if the classifiers have different lengths
WrongAlphabetException - if not all given classifiers are defined on the same AlphabetContainer
CloneNotSupportedException - if something went wrong while cloning
ClassDimensionException - if there is something wrong with the class dimension of the classifier
See Also:
ClassifierAssessment.ClassifierAssessment(AbstractClassifier[], boolean, TrainableStatisticalModel[][])
Method Detail

evaluateClassifier

protected void evaluateClassifier(NumericalPerformanceMeasureParameterSet mp,
                                  RepeatedSubSamplingAssessParameterSet assessPS,
                                  DataSet[] s,
                                  double[][] weights,
                                  ProgressUpdater pU)
                           throws IllegalArgumentException,
                                  Exception
Evaluates the classifier.

Specified by:
evaluateClassifier in class ClassifierAssessment<RepeatedSubSamplingAssessParameterSet>
Parameters:
mp - defines which performance measures are used to assess classifiers
pU - allows to abort this assessment by setting pU.isCancelled()=true. The last step of this assessment is continued afterwards this assessment stops.
s - contains the data to be used for assessment. The order of the data sets is important.
If model based classifiers are trained, the order of the models in the classifiers determines, which model will be trained using which data set. The first model in the classifier will be trained using the first data set in s. If the models are trained directly, the order of given models during initiation of this assessment object determines, which data set will be used for training which model. In general the first model will be trained using the first data set in s... .
For a two-class problem, it is recommended
  • to initiate the classifiers with models in order (foreground model (positive class), background model (negative class))
  • to initiate a assessment object using models in order (foreground model (positive class), background model (negative class))
  • to give data s in order (s[0] contains foreground data, s[1] contains background data)
assessPS - contains parameters for a run of this RepeatedSubSamplingExperiment. Must be of type RepeatedSubSamplingExperiment.
weights - the (non-negative) weights for the data; weight for each data set (first dimension) and each sequence (second dimension), can be null which is the same as weight 1 for all sequences in all data sets
Throws:
IllegalArgumentException - if the given assessPS is not of type RepeatedSubSamplingExperiment
Exception - if something went wrong

getAssessParameterSet

public RepeatedSubSamplingAssessParameterSet getAssessParameterSet()
                                                            throws Exception
Description copied from class: ClassifierAssessment
This method returns an instance of ClassifierAssessmentAssessParameterSet that can be used in the assess methods.

Specified by:
getAssessParameterSet in class ClassifierAssessment<RepeatedSubSamplingAssessParameterSet>
Returns:
an instance of ClassifierAssessmentAssessParameterSet that can be used in the assess methods.
Throws:
Exception - if the parameter set could not be created properly
See Also:
ClassifierAssessment.assess(NumericalPerformanceMeasureParameterSet, ClassifierAssessmentAssessParameterSet, DataSet...), ClassifierAssessment.assess(NumericalPerformanceMeasureParameterSet, ClassifierAssessmentAssessParameterSet, ProgressUpdater, DataSet[]), #assess(NumericalPerformanceMeasureParameterSet, ClassifierAssessmentAssessParameterSet, ProgressUpdater, DataSet[][]...), ClassifierAssessment.assess(NumericalPerformanceMeasureParameterSet, ClassifierAssessmentAssessParameterSet, ProgressUpdater, DataSet[], double[][])