Package gPy :: Module Data
[hide private]
[frames] | no frames]

Module Data

source code

For storing and retrieving data (contingency tables)

Classes [hide private]
  Data2
Attempt to implement ADTrees as a single flat dictionary
  Data
Factors whose data is stored in a table in an sqlite database
  CompactFactor
Factors whose data is not explicity represented (because there's too much of it).
  _ADTree
ADTree implementation
  _IncrementalADTree
  IncrementalCompactFactor
Functions [hide private]
 
_merge_records(destination, source, how)
Given two sets of records, combing them according to the function how
source code
tuple
_distribute_records(numvals, depth, records)
For each child at depth depth generate the list of records (children_records) and the number of instances (counts).
source code
Variables [hide private]
String _version = '$Id: Data.py,v 1.2 2008/10/07 08:57:06 jc Exp jc $'
Version of this module

Imports: SubDomain, extdiv, Domain, log, Factor, CPT, operator


Function Details [hide private]

_merge_records(destination, source, how)

source code 

Given two sets of records, combing them according to the function how

Parameters:
  • destination (list of tuples whose last element is a positive integer) - the target set of records where the result is stored and the left hand side of how
  • source (list of tuples whose last element is a positive integer) - the right hand side of how
  • how (binary function) - operator to combine destination and source

_distribute_records(numvals, depth, records)

source code 

For each child at depth depth generate the list of records (children_records) and the number of instances (counts).

Parameters:
  • numvals (list) - The ith element of this list is the number of values for the ith variable in the tree
  • records (iterable) - The data as a list. Each element is a tuple of value indices, one for each variable, plus an extra count field as the final element.
  • depth (int) - The depth of this tree within its containing CompactFactor. Also the index of the variable associated with the top node of this tree
Returns: tuple
A 2-tuple: children_records and counts, as described above.