class_docstr: Base class for Joint Probability Distribution
class_docstr_tok: ["Base","class","for","Joint","Probability","Distribution"]
docstr: Returns a Bayesian Model which is minimal IMap of the Joint Probability Distribution
  considering the order of the variables.
  
  Parameters
  ----------
  order: array-like
      The order of the random variables.
  
  Examples
  --------
  >>> import numpy as np
  >>> from pgmpy.factors.discrete import JointProbabilityDistribution
  >>> prob = JointProbabilityDistribution(['x1', 'x2', 'x3'], [2, 3, 2], np.ones(12)/12)
  >>> bayesian_model = prob.minimal_imap(order=['x2', 'x1', 'x3'])
  >>> bayesian_model
  <pgmpy.models.models.models at 0x7fd7440a9320>
  >>> bayesian_model.edges()
  [('x1', 'x3'), ('x2', 'x3')]
docstr_tok: ["Returns","a","Bayesian","Model","which","is","minimal","IMap","of","the","Joint","Probability","Distribution","considering","the","order","of","the","variables",".","Parameters","--","--","--","--","--","order",":","array-like","The","order","of","the","random","variables",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","pgmpy.factors.discrete","import","JointProbabilityDistribution",">",">",">","prob","=","JointProbabilityDistribution","(","[","'x1","'",",","'x2","'",",","'x3","'","]",",","[","2",",","3",",","2","]",",","np.ones","(","12",")","\/12",")",">",">",">","bayesian_model","=","prob.minimal_imap","(","order=","[","'x2","'",",","'x1","'",",","'x3","'","]",")",">",">",">","bayesian_model","<","pgmpy.models.models.models","at","0x7fd7440a9320",">",">",">",">","bayesian_model.edges","(",")","[","(","'x1","'",",","'x3","'",")",",","(","'x2","'",",","'x3","'",")","]"]
code: def minimal_imap(self, order):
      """
      Returns a Bayesian Model which is minimal IMap of the Joint Probability Distribution
      considering the order of the variables.
  
      Parameters
      ----------
      order: array-like
          The order of the random variables.
  
      Examples
      --------
      >>> import numpy as np
      >>> from pgmpy.factors.discrete import JointProbabilityDistribution
      >>> prob = JointProbabilityDistribution(['x1', 'x2', 'x3'], [2, 3, 2], np.ones(12)/12)
      >>> bayesian_model = prob.minimal_imap(order=['x2', 'x1', 'x3'])
      >>> bayesian_model
      <pgmpy.models.models.models at 0x7fd7440a9320>
      >>> bayesian_model.edges()
      [('x1', 'x3'), ('x2', 'x3')]
      """
      from pgmpy.models import BayesianNetwork
  
      def get_subsets(u):
          for r in range(len(u) + 1):
              for i in itertools.combinations(u, r):
                  yield i
  
      G = BayesianNetwork()
      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
  
file_path: pgmpy/pgmpy/factors/discrete/JointProbabilityDistribution.py
imports: import itertools
  from functools import reduce
  from operator import mul
  import numpy
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.independencies import Independencies
label_desc: Use image node_id 9 for calling the JointProbabilityDistribution obj's underlying member method code with example usage: obj.minimal_imap(order) and returns: G