class_docstr: Initializer for XBNReader class.
  
  Parameters
  ----------
  path: str or file
      Path of the file containing XBN data.
  
  string: str
      String of XBN data
  
  Examples
  --------
  >>> reader = XBNReader('test_XBN.xml')
  
  Reference
  ---------
  [1] Microsoft Research. XML belief network file format.
      http://xml.coverpages.org/xbn-MSdefault19990414.html, 1999.
class_docstr_tok: ["Initializer","for","XBNReader","class",".","Parameters","--","--","--","--","--","path",":","str","or","file","Path","of","the","file","containing","XBN","data",".","string",":","str","String","of","XBN","data","Examples","--","--","--","--",">",">",">","reader","=","XBNReader","(","'test_XBN.xml","'",")","Reference","--","--","--","--","-","[","1","]","Microsoft","Research",".","XML","belief","network","file","format",".","http",":","\/\/xml.coverpages.org\/xbn-MSdefault19990414.html",",","1999","."]
docstr: Returns a dictionary of name and its distribution. Distribution is a ndarray.
  
  The ndarray is stored in the standard way such that the rightmost variable
  changes most often. Consider a CPD of variable 'd' which has parents 'b' and
  'c' (distribution['CONDSET'] = ['b', 'c'])
  
            |  d_0     d_1
  ---------------------------
  b_0, c_0  |  0.8     0.2
  b_0, c_1  |  0.9     0.1
  b_1, c_0  |  0.7     0.3
  b_1, c_1  |  0.05    0.95
  
  The value of distribution['d']['DPIS'] for the above example will be:
  array([[ 0.8 ,  0.2 ], [ 0.9 ,  0.1 ], [ 0.7 ,  0.3 ], [ 0.05,  0.95]])
  
  Examples
  --------
  >>> reader = XBNReader('xbn_test.xml')
  >>> reader.get_distributions()
  {'a': {'TYPE': 'discrete', 'DPIS': array([[ 0.2,  0.8]])},
   'e': {'TYPE': 'discrete', 'DPIS': array([[ 0.8,  0.2],
           [ 0.6,  0.4]]), 'CONDSET': ['c'], 'CARDINALITY': [2]},
   'b': {'TYPE': 'discrete', 'DPIS': array([[ 0.8,  0.2],
           [ 0.2,  0.8]]), 'CONDSET': ['a'], 'CARDINALITY': [2]},
   'c': {'TYPE': 'discrete', 'DPIS': array([[ 0.2 ,  0.8 ],
           [ 0.05,  0.95]]), 'CONDSET': ['a'], 'CARDINALITY': [2]},
   'd': {'TYPE': 'discrete', 'DPIS': array([[ 0.8 ,  0.2 ],
           [ 0.9 ,  0.1 ],
           [ 0.7 ,  0.3 ],
           [ 0.05,  0.95]]), 'CONDSET': ['b', 'c']}, 'CARDINALITY': [2, 2]}
docstr_tok: ["Returns","a","dictionary","of","name","and","its","distribution",".","Distribution","is","a","ndarray",".","The","ndarray","is","stored","in","the","standard","way","such","that","the","rightmost","variable","changes","most","often",".","Consider","a","CPD","of","variable","'d","'","which","has","parents","'","b","'","and","'","c","'","(","distribution","[","'CONDSET","'","]","=","[","'","b","'",",","'","c","'","]",")","|","d_0","d_1","--","--","--","--","--","--","--","--","--","--","--","--","--","-","b_0",",","c_0","|","0.8","0.2","b_0",",","c_1","|","0.9","0.1","b_1",",","c_0","|","0.7","0.3","b_1",",","c_1","|","0.05","0.95","The","value","of","distribution","[","'d","'","]","[","'DPIS","'","]","for","the","above","example","will","be",":","array","(","[","[","0.8",",","0.2","]",",","[","0.9",",","0.1","]",",","[","0.7",",","0.3","]",",","[","0.05",",","0.95","]","]",")","Examples","--","--","--","--",">",">",">","reader","=","XBNReader","(","'xbn_test.xml","'",")",">",">",">","reader.get_distributions","(",")","{","'","a","'",":","{","'TYPE","'",":","'discrete","'",",","'DPIS","'",":","array","(","[","[","0.2",",","0.8","]","]",")","}",",","'","e","'",":","{","'TYPE","'",":","'discrete","'",",","'DPIS","'",":","array","(","[","[","0.8",",","0.2","]",",","[","0.6",",","0.4","]","]",")",",","'CONDSET","'",":","[","'","c","'","]",",","'CARDINALITY","'",":","[","2","]","}",",","'","b","'",":","{","'TYPE","'",":","'discrete","'",",","'DPIS","'",":","array","(","[","[","0.8",",","0.2","]",",","[","0.2",",","0.8","]","]",")",",","'CONDSET","'",":","[","'","a","'","]",",","'CARDINALITY","'",":","[","2","]","}",",","'","c","'",":","{","'TYPE","'",":","'discrete","'",",","'DPIS","'",":","array","(","[","[","0.2",",","0.8","]",",","[","0.05",",","0.95","]","]",")",",","'CONDSET","'",":","[","'","a","'","]",",","'CARDINALITY","'",":","[","2","]","}",",","'d","'",":","{","'TYPE","'",":","'discrete","'",",","'DPIS","'",":","array","(","[","[","0.8",",","0.2","]",",","[","0.9",",","0.1","]",",","[","0.7",",","0.3","]",",","[","0.05",",","0.95","]","]",")",",","'CONDSET","'",":","[","'","b","'",",","'","c","'","]","}",",","'CARDINALITY","'",":","[","2",",","2","]","}"]
code: def get_distributions(self):
      """
      Returns a dictionary of name and its distribution. Distribution is a ndarray.
  
      The ndarray is stored in the standard way such that the rightmost variable
      changes most often. Consider a CPD of variable 'd' which has parents 'b' and
      'c' (distribution['CONDSET'] = ['b', 'c'])
  
                |  d_0     d_1
      ---------------------------
      b_0, c_0  |  0.8     0.2
      b_0, c_1  |  0.9     0.1
      b_1, c_0  |  0.7     0.3
      b_1, c_1  |  0.05    0.95
  
      The value of distribution['d']['DPIS'] for the above example will be:
      array([[ 0.8 ,  0.2 ], [ 0.9 ,  0.1 ], [ 0.7 ,  0.3 ], [ 0.05,  0.95]])
  
      Examples
      --------
      >>> reader = XBNReader('xbn_test.xml')
      >>> reader.get_distributions()
      {'a': {'TYPE': 'discrete', 'DPIS': array([[ 0.2,  0.8]])},
       'e': {'TYPE': 'discrete', 'DPIS': array([[ 0.8,  0.2],
               [ 0.6,  0.4]]), 'CONDSET': ['c'], 'CARDINALITY': [2]},
       'b': {'TYPE': 'discrete', 'DPIS': array([[ 0.8,  0.2],
               [ 0.2,  0.8]]), 'CONDSET': ['a'], 'CARDINALITY': [2]},
       'c': {'TYPE': 'discrete', 'DPIS': array([[ 0.2 ,  0.8 ],
               [ 0.05,  0.95]]), 'CONDSET': ['a'], 'CARDINALITY': [2]},
       'd': {'TYPE': 'discrete', 'DPIS': array([[ 0.8 ,  0.2 ],
               [ 0.9 ,  0.1 ],
               [ 0.7 ,  0.3 ],
               [ 0.05,  0.95]]), 'CONDSET': ['b', 'c']}, 'CARDINALITY': [2, 2]}
      """
      distribution = {}
      for dist in self.bnmodel.find("DISTRIBUTIONS"):
          variable_name = dist.find("PRIVATE").get("NAME")
          distribution[variable_name] = {"TYPE": dist.get("TYPE")}
          if dist.find("CONDSET") is not None:
              distribution[variable_name]["CONDSET"] = [
                  var.get("NAME")
                  for var in dist.find("CONDSET").findall("CONDELEM")
              ]
              distribution[variable_name]["CARDINALITY"] = np.array(
                  [
                      len(
                          set(
                              np.array(
                                  [
                                      list(
                                          map(
                                              int,
                                              dpi.get(
                                                  "INDEXES"
                                              ).split(),
                                          )
                                      )
                                      for dpi in dist.find("DPIS")
                                  ]
                              )[:, i]
                          )
                      )
                      for i in range(
                          len(distribution[variable_name]["CONDSET"])
                      )
                  ]
              )
          distribution[variable_name]["DPIS"] = np.array(
              [
                  list(map(float, dpi.text.split()))
                  for dpi in dist.find("DPIS")
              ]
          ).transpose()
  
      return distribution
  
imports: import itertools
  import xml.etree.ElementTree
  import networkx
  import numpy
  from pgmpy.factors.discrete import TabularCPD
  from pgmpy.models import BayesianNetwork
label_desc: Use image node_id 7 for calling the XBNReader obj's underlying member method code with example usage: obj.get_distributions() and returns: distribution