Package PyML :: Package containers :: Module labels :: Class Labels
[frames] | no frames]

Class Labels

source code

object --+
         |
        Labels

A class that holds the labels of a dataset.

Attributes:

L - labels provided by the user (strings)
Y - internal label representation - an integer from 0 to numClasses - 1
for multilabel problems each pattern has a list of integer labels
patternID - a list of the ids of each pattern
classDict - a mapping from L to Y
classLabels - a list providing the name of class i
classSize - a list with the number of patterns in each class
numClasses - the number of classes in the data
Instance Methods
 
__init__(self, arg=None, **args)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
copy(self, other, **args) source code
 
extend(self, other, patterns=None)
add to a dataset a list of patterns from another dataset
source code
 
processLabels(self, L, **args) source code
 
flip(self, patterns) source code
 
__len__(self) source code
 
__repr__(self)
repr(x)
source code
 
isLabeled(self) source code
 
save(self, fileName, delim='\t') source code
 
convertFromMultiLabel(self) source code
 
mergeClasses(self, classList, newLabel=None)
Merge a list of classes into a new class.
source code
 
oneAgainstRest(self, classLabels, className=None)
creates a one-against-the-rest labels object
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, arg=None, **args)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • arg - a file name from which to read labels, or a list of labels
  • patternID - a list of pattern IDs
  • patterns - in case of copy construction, which patterns to copy
  • numericLabels - a Boolean, indicating whether the labels are class labels or numeric values (class labels by default).
  • positiveClass - for a two class problem, the identity of the positive class. If the labels are '+1' and '-1' or '1' and '-1', the positive class is detected automatically.
  • classLabels
  • forgetClassLabels - when using copy construction the default behavior is to return a Labels object that remembers the set of classes that the original object had, even if some classes are no longer represented. this keyword allows you to change this behavior, so that the classes of the original object are forgotten.
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

mergeClasses(self, classList, newLabel=None)

source code 

Merge a list of classes into a new class.

  • classList - a list of classes to merge; can either provide the names of the classes or the index.
  • newLabel - the name of the new class (if not given then the label is formed by concatenating the names of the merged classes)

Parameters:  

oneAgainstRest(self, classLabels, className=None)

source code 
creates a one-against-the-rest labels object
Parameters:
  • classLabels - a single class name, or a list of class names (string or a list of strings)
  • className - if given, the new name given to the class