NoisyORCPD#
- class pgmpy.factors.discrete.NoisyORCPD(variable, prob_values, evidence)[source]#
Bases:
TabularCPDInitializes the NoisyORCPD class.
The NoisyOR CPD is a special case of TabularCPD for binary variables where a given variable can be activated by each of the parent variables with a specified probability. This activation probability is defined in the prob_values argument.
- Parameters:
- variable: str
The variable for which the CPD is to be defined.
- prob_values: iterable
A list of probabilities values for each evidence variable to activate variable.
- evidence: list
List of evidence variables, i.e., conditional variables.
Examples
>>> from pgmpy.factors.discrete import NoisyORCPD >>> cpd = NoisyORCPD(variable="Y", prob_values=[0.3, 0.5], evidence=["X1", "X2"]) >>> from pgmpy.models import DiscreteBayesianNetwork >>> model = DiscreteBayesianNetwork( ... [("A", "B")] ... ) # With nodes with no parents, we can not define a NoisyORCPD. >>> cpd_a = TabularCPD( ... variable="A", ... variable_card=2, ... values=[[0.2], [0.8]], ... state_names={"A": ["True", "False"]}, ... ) >>> cpd_b = NoisyORCPD(variable="B", prob_values=[0.8], evidence=["A"]) >>> model.add_cpds(cpd_a, cpd_b)