Package PyML :: Package classifiers :: Module baseClassifiers :: Class Classifier
[frames] | no frames]

Class Classifier

source code

base.pymlObject.PyMLobject --+
                             |
                            Classifier

base class for PyML classifiers, specifying the classifier api
Nested Classes
  resultsObject
Instance Methods
 
test(classifier, data, **args)
test a classifier on a given dataset
source code
 
cv(classifier, data, numFolds=5, **args)
perform k-fold cross validation
source code
 
stratifiedCV(classifier, data, numFolds=5, **args)
perform k-fold stratified cross-validation; in each fold the number of patterns from each class is proportional to the relative fraction of the class in the dataset
source code
 
loo(classifier, data, **args)
perform Leave One Out
source code
 
trainTest(classifierTemplate, data, trainingPatterns, testingPatterns, **args)
Train a classifier on the list of training patterns, and test it on the test patterns
source code
 
nCV(classifier, data, **args)
runs CV n times, returning a 'ResultsList' object.
source code
 
__init__(self, arg=None, **args) source code
 
logger(self) source code
 
__repr__(self) source code
 
project(self, data)
project a test dataset to the training data features.
source code
 
save(self, fileHandle) source code
 
train(self, data, **args) source code
 
trainFinalize(self) source code
 
getTrainingTime(self) source code
 
classify(self, data, i) source code
 
twoClassClassify(self, data, i) source code
Class Variables
  type = 'classifier'
  deepcopy = False
Method Details

test(classifier, data, **args)

source code 
test a classifier on a given dataset
Parameters:
  • classifier - a trained classifier
  • data - a dataset
  • stats - whether to compute the statistics of the match between the predicted labels and the given labels [True by default]
Returns:
a Results class instance

cv(classifier, data, numFolds=5, **args)

source code 
perform k-fold cross validation
Parameters:
  • classifier - a classifier template
  • data - a dataset
  • numFolds - number of cross validation folds (default = 5)
  • numFolds - number of cross validation folds (default = 5)
  • seed - random number generator seed
  • foldsToPerform - number of folds to actually perform (in case you're doing n fold CV, and want to save time, and only do some of the folds)
Returns:
a Results object.

stratifiedCV(classifier, data, numFolds=5, **args)

source code 
perform k-fold stratified cross-validation; in each fold the number of patterns from each class is proportional to the relative fraction of the class in the dataset
Parameters:
  • classifier - a classifier template
  • data - a dataset
  • numFolds - number of cross validation folds (default = 5)
  • numFolds - number of cross-validation folds -- overrides the numFolds parameter
  • seed - random number generator seed
  • trainingAllFolds - a list of patterns that are to be used as training examples in all CV folds.
  • intermediateFile - a file name to save intermediate results under if this argument is not given, not intermediate results are saved
  • foldsToPerform - number of folds to actually perform (in case you're doing n fold CV, and want to save time, and only do some of the folds)
Returns:
a Results object.

loo(classifier, data, **args)

source code 

perform Leave One Out

USAGE: loo(classifier, data)

Returns:
a results object

nCV(classifier, data, **args)

source code 
runs CV n times, returning a 'ResultsList' object.
Parameters:
  • classifier - classifier template
  • data - dataset
  • cvType - which CV function to apply (default: stratifiedCV)
  • seed - random number generator seed (default: 1) This is used as the seed for the first CV run. Subsequent runs use seed + 1, seed + 2...
  • iterations - number of times to run CV (default: 10)
  • numFolds - number of folds to use with CV (default: 5)
  • intermediateFile - a file name to save intermediate results under if this argument is not given, no intermediate results are saved
Returns:
ResultsList - a list of the results of each CV run as a ResultsList object