

def minimal_imap(self, order):
    "\n        Returns a Bayesian Model which is minimal IMap of the Joint Probability Distribution\n        considering the order of the variables.\n\n        Parameters\n        ----------\n        order: array-like\n            The order of the random variables.\n\n        Examples\n        --------\n        >>> import numpy as np\n        >>> from pgmpy.factors import JointProbabilityDistribution\n        >>> prob = JointProbabilityDistribution(['x1', 'x2', 'x3'], [2, 3, 2], np.ones(12)/12)\n        >>> bayesian_model = prob.minimal_imap(order=['x2', 'x1', 'x3'])\n        >>> bayesian_model\n        <pgmpy.models.models.models at 0x7fd7440a9320>\n        >>> bayesian_model.edges()\n        [('x1', 'x3'), ('x2', 'x3')]\n        "
    from pgmpy.models import BayesianModel

    def get_subsets(u):
        for r in range((len(u) + 1)):
            for i in itertools.combinations(u, r):
                (yield i)
    G = BayesianModel()
    for variable_index in range(len(order)):
        u = order[:variable_index]
        for subset in get_subsets(u):
            if ((len(subset) < len(u)) and self.check_independence([order[variable_index]], (set(u) - set(subset)), subset, True)):
                G.add_edges_from([(variable, order[variable_index]) for variable in subset])
    return G

dataset/ETHPy150Open pgmpy/pgmpy/pgmpy/factors/JointProbabilityDistribution.py JointProbabilityDistribution.minimal_imap/original