Package classifiers :: Module q_classifier_r :: Class classifier
[frames] | no frames]

Class classifier

source code


This is the base class for all kinds of classifers.

Instance Methods
 
__init__(self, typename, models, info=None, trainingset_name=None, uid=None, cdesc=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
add_model(self, classname, model)
Add a class to an existing classifier.
source code
 
list_classes(self) source code
 
add_info(self, k, v) source code
 
P(self, datum, whichclass=None)
Determine the probability of being in each class.
source code
 
logP(self, datum, whichclass=None) source code
 
logPw(self, datum, whichclass, constrain)
Determine the probability of datum being in whichclass.
source code
 
logPv(self, datum)
Determine the probability of being in each class.
source code
 
bestc(self, datum)
Determine the best class for a datum.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
str(x)
source code
 
list_wrong_classifications(self, classdata) source code
 
writer(self, dcw)
Write this classifier out (usually to a data file).
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Variables
  HUGE = 1e+30
Properties

Inherited from object: __class__

Method Details

__init__(self, typename, models, info=None, trainingset_name=None, uid=None, cdesc=None)
(Constructor)

source code 

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

Parameters:
  • models (dict(str: subclass of model_template)) - a dictionary containg a probabilistic model for each class
  • info (dict(str: whatever)) - not used in the internal operation of the classifier, but it is stuff that is important to write out.
Overrides: object.__init__

P(self, datum, whichclass=None)

source code 

Determine the probability of being in each class. If whichclass=None, then it returns a list of tuples [(classname,P), ...] for all classes. Otherwise, it returns the probability of the specified class.

logPv(self, datum)

source code 

Determine the probability of being in each class. If whichclass=None, then it returns a list of tuples [(classname,P), ...] for all classes.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

str(x)

Overrides: object.__repr__
(inherited documentation)

writer(self, dcw)

source code 

Write this classifier out (usually to a data file).

Parameters:
  • dcw (chunkio.chunk_w)