Scope Management¶
Scope representation and manipulation for feature and random variable management in probabilistic circuits.
Scope¶
Represents scopes over random variables with query and evidence designations.
- class spflow.meta.data.scope.Scope(query=None, evidence=None)[source]¶
Bases:
objectScopes over random variables (RVs).
Represents scope over random variables (RVs). Contains both RVs that are part of the query (i.e., RVs that are represented by the scope) as well as evidence of the scope (i.e., RVs that the scope is conditioned on).
- query¶
List of non-negative integers representing query RVs.
- evidence¶
List of non-negative integers representing evidence variables.
- static join_all(scopes)[source]¶
Computes the joint scope of the scope and a sequence of scopes.
The union of multiple scopes results in the union of the queries and evidences, respectively.
- __init__(query=None, evidence=None)[source]¶
Initializes Scope object.
- Parameters:
query (
int|list[int] |tuple[int,...] |None) – List of non-negative integers representing query RVs (may not contain duplicates). If a single integer is provided, it is converted to a list containing that integer.evidence (
int|list[int] |tuple[int,...] |None) – Optional list of non-negative integers representing evidence variables (may not contain duplicates or RVs that are in the query). If a single integer is provided, it is converted to a list containing that integer. Defaults to None, in which case it is initialized to an empty list.
- Raises:
ValueError – Invalid arguments.
- copy()[source]¶
Creates a copy of the scope.
- Return type:
- Returns:
Scope object representing the copy of the scope.
- empty()[source]¶
Checks if the scope is empty.
A scope is considered empty if its query is empty, i.e., the scope does not represent any RVs.
- Return type:
- Returns:
Boolean indicating whether the scope is empty (True) or not (False).
- equal_evidence(other)[source]¶
Checks if the evidence of the scope is identical to that of another.
The order of the evidence RVs is not important.
- equal_query(other)[source]¶
Checks if the query of the scope is identical to that of another.
The order of the query RVs is not important.
- is_conditional()[source]¶
Checks if the scope is conditional.
A scope is conditional if it contains evidence RVs.
- Return type:
- Returns:
Boolean indicating whether the scope is conditional (True) or not (False).
- isdisjoint(other)[source]¶
Checks if the scope is disjoint to another scope.
Two scopes are considered disjoint if their queries are disjoint, i.e., they do not represent any common RVs.
- join(other)[source]¶
Computes the joint scope of the scope and another scope.
Follows probabilistic semantics, i.e.: - p(X) * p(Z) = p(X,Z) - p(X) * p(Y|Z)= p(X,Y|Z) - p(X) * p(Y|X)= p(X,Y) - p(X|Y) * p(Z|W) = p(X,Z|Y,W) - p(X|Y) * p(Z|Y) = p(X,Z|Y) - p(X|Y) * p(Y|Z) = p(X,Y|Z)