

def is_imap(self, model):
    "\n        Checks whether the given BayesianModel is Imap of JointProbabilityDistribution\n\n        Parameters\n        -----------\n        model : An instance of BayesianModel Class, for which you want to\n            check the Imap\n\n        Returns\n        --------\n        boolean : True if given bayesian model is Imap for Joint Probability Distribution\n                False otherwise\n        Examples\n        --------\n        >>> from pgmpy.models import BayesianModel\n        >>> from pgmpy.factors import TabularCPD\n        >>> from pgmpy.factors import JointProbabilityDistribution\n        >>> bm = BayesianModel([('diff', 'grade'), ('intel', 'grade')])\n        >>> diff_cpd = TabularCPD('diff', 2, [[0.2], [0.8]])\n        >>> intel_cpd = TabularCPD('intel', 3, [[0.5], [0.3], [0.2]])\n        >>> grade_cpd = TabularCPD('grade', 3,\n        ...                        [[0.1,0.1,0.1,0.1,0.1,0.1],\n        ...                         [0.1,0.1,0.1,0.1,0.1,0.1],\n        ...                         [0.8,0.8,0.8,0.8,0.8,0.8]],\n        ...                        evidence=['diff', 'intel'],\n        ...                        evidence_card=[2, 3])\n        >>> bm.add_cpds(diff_cpd, intel_cpd, grade_cpd)\n        >>> val = [0.01, 0.01, 0.08, 0.006, 0.006, 0.048, 0.004, 0.004, 0.032,\n                   0.04, 0.04, 0.32, 0.024, 0.024, 0.192, 0.016, 0.016, 0.128]\n        >>> JPD = JointProbabilityDistribution(['diff', 'intel', 'grade'], [2, 3, 3], val)\n        >>> JPD.is_imap(bm)\n        True\n        "
    from pgmpy.models import BayesianModel
    if (not isinstance(model, BayesianModel)):
        raise TypeError('model must be an instance of BayesianModel')
    factors = [self.to_factor() for cpd in model.get_cpds()]
    factor_prod = six.moves.reduce(mul, factors)
    JPD_fact = Factor(self.variables, self.cardinality, self.values)
    if (JPD_fact == factor_prod):
        return True
    else:
        return False

dataset/ETHPy150Open pgmpy/pgmpy/pgmpy/factors/JointProbabilityDistribution.py JointProbabilityDistribution.is_imap/VarMisuse@44/694 `cpd`->`self`