Package mvpa :: Package misc :: Module state :: Class Harvestable
[hide private]
[frames] | no frames]

Class Harvestable

source code


Classes inherited from this class intend to collect attributes within internal processing.

Subclassing Harvestable we gain ability to collect any internal data from the processing which is especially important if an object performs something in loop and discards some intermidiate possibly interesting results (like in case of CrossValidatedTransferError and states of the trained classifier or TransferError).

Nested Classes [hide private]

Inherited from ClassWithCollections: __metaclass__

Instance Methods [hide private]
 
__init__(self, harvest_attribs=None, copy_attribs='copy', **kwargs)
Initialize state of harvestable
source code
 
_setAttribs(self, attribs)
Set attributes to harvest
source code
 
_harvest(self, vars)
The harvesting function: must obtain dictionary of variables from the caller.
source code

Inherited from ClassWithCollections: __getattribute__, __new__, __repr__, __setattr__, __str__, reset

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

Class Variables [hide private]
  harvested = StateVariable(enabled= False, doc= """Store specif...
  _KNOWN_COPY_METHODS = [None, 'copy', 'deepcopy']
  harvest_attribs = property(fget= lambda self: self.__attribs, ...

Inherited from ClassWithCollections: _DEV__doc__, descr

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, harvest_attribs=None, copy_attribs='copy', **kwargs)
(Constructor)

source code 
Initialize state of harvestable
Parameters:
  • harvest_attribs (list of basestr or dicts) - What attributes of call to store and return within harvested state variable. If an item is a dictionary, following keys are used ['name', 'copy']
  • copy_attribs (None or basestr) - Default copying. If None -- no copying, 'copy' - shallow copying, 'deepcopy' -- deepcopying
Overrides: object.__init__

_setAttribs(self, attribs)

source code 

Set attributes to harvest

Each attribute in self.__attribs must have following fields
  • name : functional (or arbitrary if 'obj' or 'attr' is set)

    description of the thing to harvest, e.g. 'transerror.clf.training_time'

  • obj : name of the object to harvest from (if empty,

    'self' is assumed), e.g 'transerror'

  • attr : attribute of 'obj' to harvest,

    e.g. 'clf.training_time'

  • copy : None, 'copy' or 'deepcopy' - way to copy attribute

_harvest(self, vars)

source code 
The harvesting function: must obtain dictionary of variables from the caller.
Parameters:
  • vars (dict) - Dictionary of available data. Most often locals() could be passed as vars. Mention that desired to be harvested private attributes better be bound locally to some variable
Returns:
nothing

Class Variable Details [hide private]

harvested

Value:
StateVariable(enabled= False, doc= """Store specified attributes of cl\
assifiers at each split""")

harvest_attribs

Value:
property(fget= lambda self: self.__attribs, fset= _setAttribs)