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

Class IncrementalCompactFactor

source code


Instance Methods [hide private]
 
__init__(self, rawdata, domain=None, rmin=200)
Construct a SubDomain object
source code
SubDomain
copy(self)
Return a 'copy' of a subdomain
source code
 
__getitem__(self, variables) source code
 
update(self, rawdata) source code
 
__str__(self)
str(x)
source code
Factor object
makeFactor(self, variables, check=False)
Return a marginal factor with variables
source code
 
makeCPT(self, child, parents, force_cpt=False, check=False, prior=0) source code
 
family_score(self, child, parents, precision=1.0) source code
int
size(self)
Return the number of nodes in the underlying ADTree
source code

Inherited from Variables.SubDomain: __add__, __div__, __iadd__, __idiv__, __imul__, __isub__, __mul__, __rdiv__, __repr__, __rmul__, __sub__, drop_variable, drop_variables, inst2index, insts, insts_indices, marginalise_onto, sumout, table_size, uses_default_domain, variables, varvalues

Inherited from Variables.Domain: add_domain_variable, add_domain_variables, add_domain_variables_from_rawdata, change_domain_variable, change_domain_variables, common_domain, known_variable, numvals, values

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

Instance Variables [hide private]

Inherited from Variables.SubDomain (private): _variables

Inherited from Variables.Domain (private): _domain, _instd, _numvals

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, rawdata, domain=None, rmin=200)
(Constructor)

source code 

Construct a SubDomain object

Parameters:
  • variables - The subset of domain variables for the object.
  • domain - A domain for the model. If None the internal default domain is used. If the string 'new', a new empty domain is used.
  • new_domain_variables - A dictionary containing a mapping from any new variables to their values. domain is updated with these values
  • must_be_new - Whether domain variables in new_domain_variables have to be new
  • check - Whether to check that all variables exist in domain
Raises:
  • VariableError - If a variable in new_domain_variables already exists with values different from its values in new_domain_variables; Or if must_be_new is set and the variable already exists. Or if check is set and a variable in variables is not in the domain
Overrides: object.__init__
(inherited documentation)

copy(self)

source code 

Return a 'copy' of a subdomain

Parameters:
  • copy_domain - If true self's domain is copied, otherwise the copy shares self's domain
Returns: SubDomain
The copy
Overrides: Variables.Domain.copy
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

makeFactor(self, variables, check=False)

source code 

Return a marginal factor with variables

Unless variables is empty in which case return the sum of self's data

Parameters:
  • variables (Iterable) - Variables to project onto
  • check (Boolean) - Whether to bother with an initial check that every member of variables is in the CompactFactor. (If this check is omitted and there is an extra variable, then a Factor with the wrong number of values will be created.)
Returns: Factor object
The marginal factor
Raises:
  • KeyError - if variables contains a variable not contained in the CompactFactor.

makeCPT(self, child, parents, force_cpt=False, check=False, prior=0)

source code 
Parameters:
  • prior - the Dirichlet prior parameter (the same parameter value is used for all instances!) Note there may be some problems with this method: a different prior is used by the BDeu score. However, in practice, for parameter estimation, this prior method seems to be ok. I was lazy and it was simple to implement (cb). If prior is zero, then the parameters are the maximum likelihood estimation solutions.

size(self)

source code 

Return the number of nodes in the underlying ADTree

Returns: int
The number of nodes in the tree