Package PyML :: Package classifiers :: Module multi :: Class OneAgainstOne
[frames] | no frames]

Class OneAgainstOne

source code

base.pymlObject.PyMLobject --+        
                             |        
    baseClassifiers.Classifier --+    
                                 |    
     composite.CompositeClassifier --+
                                     |
                                    OneAgainstOne

One-against-one Multi-class classification using a two class classifier.

For a k class problem k(k-1) binary classes are trained for all pairs of classes; an instance is classified to the class that receives the highest number of votes; an instance is constructed using a classifier that is used as a template for constructing the actual classifiers.

Nested Classes
    Inherited from baseClassifiers.Classifier
  resultsObject
Instance Methods
 
train(self, data, **args)
train k(k-1)/2 classifiers
source code
 
classify(self, data, p)
Suppose that x is classified to class c, then the margin is defined as the minimum margin found against the k-1 other classes
source code
 
preproject(self, data) source code
 
test(classifier, data, **args)
test a classifier on a given dataset
source code
    Inherited from composite.CompositeClassifier
 
__init__(self, classifier, **args) source code
 
__repr__(self) source code
 
decisionFunc(self, data, i) source code
 
getTest(self) source code
 
setTest(self) source code
    Inherited from baseClassifiers.Classifier
 
cv(classifier, data, numFolds=5, **args)
perform k-fold cross validation
source code
 
getTrainingTime(self) source code
 
logger(self) source code
 
loo(classifier, data, **args)
perform Leave One Out
source code
 
nCV(classifier, data, **args)
runs CV n times, returning a 'ResultsList' object.
source code
 
project(self, data)
project a test dataset to the training data features.
source code
 
save(self, fileHandle) 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
 
trainFinalize(self) 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
 
twoClassClassify(self, data, i) source code
Class Variables
    Inherited from composite.CompositeClassifier
  deepcopy = True
    Inherited from baseClassifiers.Classifier
  type = 'classifier'
Method Details

train(self, data, **args)

source code 
train k(k-1)/2 classifiers
Overrides: baseClassifiers.Classifier.train

classify(self, data, p)

source code 
Suppose that x is classified to class c, then the margin is defined as the minimum margin found against the k-1 other classes
Overrides: baseClassifiers.Classifier.classify

preproject(self, data)

source code 
Overrides: composite.CompositeClassifier.preproject

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
Overrides: evaluators.assess.test