dodiscover.ContextBuilder#
- class dodiscover.ContextBuilder[source]#
A builder class for creating observational data Context objects ergonomically.
The ContextBuilder is meant solely to build Context objects that work with observational datasets.
The context builder provides a way to capture assumptions, domain knowledge, and data. This should NOT be instantiated directly. One should instead use
dodiscover.make_context
to build a Context data structure.Methods
build
()Build the Context object.
edges
([include, exclude])Set edge constraints to apply in discovery.
excluded_edges
(exclude)Set exclusion edge constraints to apply in discovery.
included_edges
(include)Set inclusion edge constraints to apply in discovery.
init_graph
(graph)Set the partial graph to start with.
latent_variables
([latents])Set latent variables.
observed_variables
([observed])Set observed variables.
state_variable
(name, var)Add a state variable.
state_variables
(state_variables)Set the state variables to use in discovery.
variables
([observed, latents, data])Set variable-list information to utilize in discovery.
- edges(include=None, exclude=None)[source]#
Set edge constraints to apply in discovery.
- Parameters:
- included
Optional
[NetworkxGraph
] Edges that should be included in the resultant graph
- excluded
Optional
[NetworkxGraph
] Edges that must be excluded in the resultant graph
- included
- Returns:
- self
ContextBuilder
The builder instance
- self
- excluded_edges(exclude)[source]#
Set exclusion edge constraints to apply in discovery.
- Parameters:
- excluded
Optional
[NetworkxGraph
] Edges that should be excluded in the resultant graph
- excluded
- Returns:
- self
ContextBuilder
The builder instance
- self
- included_edges(include)[source]#
Set inclusion edge constraints to apply in discovery.
- Parameters:
- included
Optional
[NetworkxGraph
] Edges that should be included in the resultant graph
- included
- Returns:
- self
ContextBuilder
The builder instance
- self
- init_graph(graph)[source]#
Set the partial graph to start with.
- Parameters:
- graph
Graph
The new graph instance.
- graph
- Returns:
- self
ContextBuilder
The builder instance
- self
- latent_variables(latents=None)[source]#
Set latent variables.
- Parameters:
- latents
Optional
[Set
[Column
]] Set of latent “unobserved” variables, by default None. If neither
latents
, norvariables
is set, then it is presumed thatvariables
consists of the columns ofdata
andlatents
is the empty set.
- latents
- observed_variables(observed=None)[source]#
Set observed variables.
- Parameters:
- observed
Optional
[Set
[Column
]] Set of observed variables, by default None. If neither
latents
, norvariables
is set, then it is presumed thatvariables
consists of the columns ofdata
andlatents
is the empty set.
- observed
- state_variable(name, var)[source]#
Add a state variable.
Called by an algorithm to persist data objects that are used in intermediate steps.
- state_variables(state_variables)[source]#
Set the state variables to use in discovery.
- Parameters:
- state_variables
Dict
[str
,Any
] The state variables to use in discovery.
- state_variables
- Returns:
- self
ContextBuilder
The builder instance
- self
- variables(observed=None, latents=None, data=None)[source]#
Set variable-list information to utilize in discovery.
- Parameters:
- observed
Optional
[Set
[Column
]] Set of observed variables, by default None. If neither
latents
, norvariables
is set, then it is presumed thatvariables
consists of the columns ofdata
andlatents
is the empty set.- latents
Optional
[Set
[Column
]] Set of latent “unobserved” variables, by default None. If neither
latents
, norvariables
is set, then it is presumed thatvariables
consists of the columns ofdata
andlatents
is the empty set.- data
Optional
[pd.DataFrame
] the data to use for variable inference.
- observed
- Returns:
- self
ContextBuilder
The builder instance
- self
Examples using dodiscover.ContextBuilder
#
Causal discovery with interventional data - Sachs dataset