class_docstr: Class used to compute parameters for a model using Bayesian Parameter Estimation.
  See `MaximumLikelihoodEstimator` for constructor parameters.
class_docstr_tok: ["Class","used","to","compute","parameters","for","a","model","using","Bayesian","Parameter","Estimation",".","See","`","MaximumLikelihoodEstimator","`","for","constructor","parameters","."]
docstr: Method to estimate the model parameters (CPDs).
  
  Parameters
  ----------
  prior_type: 'dirichlet', 'BDeu', or 'K2'
      string indicting which type of prior to use for the model parameters.
      - If 'prior_type' is 'dirichlet', the following must be provided:
          'pseudo_counts' = dirichlet hyperparameters; a single number or a dict containing, for each
           variable, a 2-D array of the shape (node_card, product of parents_card) with a "virtual"
           count for each variable state in the CPD, that is added to the state counts.
           (lexicographic ordering of states assumed)
      - If 'prior_type' is 'BDeu', then an 'equivalent_sample_size'
          must be specified instead of 'pseudo_counts'. This is equivalent to
          'prior_type=dirichlet' and using uniform 'pseudo_counts' of
          `equivalent_sample_size/(node_cardinality*np.prod(parents_cardinalities))` for each node.
          'equivalent_sample_size' can either be a numerical value or a dict that specifies
          the size for each variable separately.
      - A prior_type of 'K2' is a shorthand for 'dirichlet' + setting every pseudo_count to 1,
          regardless of the cardinality of the variable.
  
  equivalent_sample_size: int
      Refer `priort_type` for more details.
  
  pseudo_counts: int (default: None)
      Refer `priort_type` for more details.
  
  n_jobs: int (default: 1)
      Number of jobs to run in parallel. Default: 1 uses all the processors.
      Using n_jobs > 1 for small models might be slower.
  
  weighted: bool
      If weighted=True, the data must contain a `_weight` column specifying the
      weight of each datapoint (row). If False, assigns an equal weight to each
      datapoint.
  
  Returns
  -------
  parameters: list
      List of TabularCPDs, one for each variable of the model
  
  Examples
  --------
  >>> import numpy as np
  >>> import pandas as pd
  >>> from pgmpy.models import BayesianNetwork
  >>> from pgmpy.estimators import BayesianEstimator
  >>> values = pd.DataFrame(np.random.randint(low=0, high=2, size=(1000, 4)),
  ...                       columns=['A', 'B', 'C', 'D'])
  >>> model = BayesianNetwork([('A', 'B'), ('C', 'B'), ('C', 'D')])
  >>> estimator = BayesianEstimator(model, values)
  >>> estimator.get_parameters(prior_type='BDeu', equivalent_sample_size=5)
  [<TabularCPD representing P(C:2) at 0x7f7b534251d0>,
  <TabularCPD representing P(B:2 | C:2, A:2) at 0x7f7b4dfd4da0>,
  <TabularCPD representing P(A:2) at 0x7f7b4dfd4fd0>,
  <TabularCPD representing P(D:2 | C:2) at 0x7f7b4df822b0>]
docstr_tok: ["Method","to","estimate","the","model","parameters","(","CPDs",")",".","Parameters","--","--","--","--","--","prior_type",":","'dirichlet","'",",","'BDeu","'",",","or","'K2'","string","indicting","which","type","of","prior","to","use","for","the","model","parameters",".","-","If","'prior_type","'","is","'dirichlet","'",",","the","following","must","be","provided",":","'pseudo_counts","'","=","dirichlet","hyperparameters",";","a","single","number","or","a","dict","containing",",","for","each","variable",",","a","2-D","array","of","the","shape","(","node_card",",","product","of","parents_card",")","with","a","``","virtual","''","count","for","each","variable","state","in","the","CPD",",","that","is","added","to","the","state","counts",".","(","lexicographic","ordering","of","states","assumed",")","-","If","'prior_type","'","is","'BDeu","'",",","then","an","'equivalent_sample_size'","must","be","specified","instead","of","'pseudo_counts","'",".","This","is","equivalent","to","'prior_type=dirichlet","'","and","using","uniform","'pseudo_counts","'","of","`","equivalent_sample_size\/","(","node_cardinality","*","np.prod","(","parents_cardinalities",")",")","`","for","each","node",".","'equivalent_sample_size","'","can","either","be","a","numerical","value","or","a","dict","that","specifies","the","size","for","each","variable","separately",".","-","A","prior_type","of","'K2","'","is","a","shorthand","for","'dirichlet","'","+","setting","every","pseudo_count","to","1",",","regardless","of","the","cardinality","of","the","variable",".","equivalent_sample_size",":","int","Refer","`","priort_type","`","for","more","details",".","pseudo_counts",":","int","(","default",":","None",")","Refer","`","priort_type","`","for","more","details",".","n_jobs",":","int","(","default",":","1",")","Number","of","jobs","to","run","in","parallel",".","Default",":","1","uses","all","the","processors",".","Using","n_jobs",">","1","for","small","models","might","be","slower",".","weighted",":","bool","If","weighted=True",",","the","data","must","contain","a","`","_weight","`","column","specifying","the","weight","of","each","datapoint","(","row",")",".","If","False",",","assigns","an","equal","weight","to","each","datapoint",".","Returns","--","--","--","-","parameters",":","list","List","of","TabularCPDs",",","one","for","each","variable","of","the","model","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","import","pandas","as","pd",">",">",">","from","pgmpy.models","import","BayesianNetwork",">",">",">","from","pgmpy.estimators","import","BayesianEstimator",">",">",">","values","=","pd.DataFrame","(","np.random.randint","(","low=0",",","high=2",",","size=","(","1000",",","4",")",")",",","...","columns=","[","'","A","'",",","'","B","'",",","'","C","'",",","'D","'","]",")",">",">",">","model","=","BayesianNetwork","(","[","(","'","A","'",",","'","B","'",")",",","(","'","C","'",",","'","B","'",")",",","(","'","C","'",",","'D","'",")","]",")",">",">",">","estimator","=","BayesianEstimator","(","model",",","values",")",">",">",">","estimator.get_parameters","(","prior_type='BDeu","'",",","equivalent_sample_size=5",")","[","<","TabularCPD","representing","P","(","C:2",")","at","0x7f7b534251d0",">",",","<","TabularCPD","representing","P","(","B:2","|","C:2",",","A:2",")","at","0x7f7b4dfd4da0",">",",","<","TabularCPD","representing","P","(","A:2",")","at","0x7f7b4dfd4fd0",">",",","<","TabularCPD","representing","P","(","D:2","|","C:2",")","at","0x7f7b4df822b0",">","]"]
code: def get_parameters(
      self,
      prior_type="BDeu",
      equivalent_sample_size=5,
      pseudo_counts=None,
      n_jobs=1,
      weighted=False,
  ):
      """
      Method to estimate the model parameters (CPDs).
  
      Parameters
      ----------
      prior_type: 'dirichlet', 'BDeu', or 'K2'
          string indicting which type of prior to use for the model parameters.
          - If 'prior_type' is 'dirichlet', the following must be provided:
              'pseudo_counts' = dirichlet hyperparameters; a single number or a dict containing, for each
               variable, a 2-D array of the shape (node_card, product of parents_card) with a "virtual"
               count for each variable state in the CPD, that is added to the state counts.
               (lexicographic ordering of states assumed)
          - If 'prior_type' is 'BDeu', then an 'equivalent_sample_size'
              must be specified instead of 'pseudo_counts'. This is equivalent to
              'prior_type=dirichlet' and using uniform 'pseudo_counts' of
              `equivalent_sample_size/(node_cardinality*np.prod(parents_cardinalities))` for each node.
              'equivalent_sample_size' can either be a numerical value or a dict that specifies
              the size for each variable separately.
          - A prior_type of 'K2' is a shorthand for 'dirichlet' + setting every pseudo_count to 1,
              regardless of the cardinality of the variable.
  
      equivalent_sample_size: int
          Refer `priort_type` for more details.
  
      pseudo_counts: int (default: None)
          Refer `priort_type` for more details.
  
      n_jobs: int (default: 1)
          Number of jobs to run in parallel. Default: 1 uses all the processors.
          Using n_jobs > 1 for small models might be slower.
  
      weighted: bool
          If weighted=True, the data must contain a `_weight` column specifying the
          weight of each datapoint (row). If False, assigns an equal weight to each
          datapoint.
  
      Returns
      -------
      parameters: list
          List of TabularCPDs, one for each variable of the model
  
      Examples
      --------
      >>> import numpy as np
      >>> import pandas as pd
      >>> from pgmpy.models import BayesianNetwork
      >>> from pgmpy.estimators import BayesianEstimator
      >>> values = pd.DataFrame(np.random.randint(low=0, high=2, size=(1000, 4)),
      ...                       columns=['A', 'B', 'C', 'D'])
      >>> model = BayesianNetwork([('A', 'B'), ('C', 'B'), ('C', 'D')])
      >>> estimator = BayesianEstimator(model, values)
      >>> estimator.get_parameters(prior_type='BDeu', equivalent_sample_size=5)
      [<TabularCPD representing P(C:2) at 0x7f7b534251d0>,
      <TabularCPD representing P(B:2 | C:2, A:2) at 0x7f7b4dfd4da0>,
      <TabularCPD representing P(A:2) at 0x7f7b4dfd4fd0>,
      <TabularCPD representing P(D:2 | C:2) at 0x7f7b4df822b0>]
      """
  
      def _get_node_param(node):
          _equivalent_sample_size = (
              equivalent_sample_size[node]
              if isinstance(equivalent_sample_size, dict)
              else equivalent_sample_size
          )
          if isinstance(pseudo_counts, numbers.Real):
              _pseudo_counts = pseudo_counts
          else:
              _pseudo_counts = (
                  pseudo_counts[node] if pseudo_counts else None
              )
  
          cpd = self.estimate_cpd(
              node,
              prior_type=prior_type,
              equivalent_sample_size=_equivalent_sample_size,
              pseudo_counts=_pseudo_counts,
              weighted=weighted,
          )
          return cpd
  
      parameters = Parallel(n_jobs=n_jobs)(
          delayed(_get_node_param)(node) for node in self.model.nodes()
      )
      # TODO: A hacky solution to return correct value for the chosen backend. Ref #1675
      parameters = [p.copy() for p in parameters]
  
      return parameters
  
file_path: pgmpy/pgmpy/estimators/BayesianEstimator.py
imports: import numbers
  from itertools import chain
  import numpy
  from joblib import Parallel, delayed
  from pgmpy.estimators import ParameterEstimator
  from pgmpy.factors.discrete import TabularCPD
  from pgmpy.global_vars import logger
  from pgmpy.models import BayesianNetwork
label_desc: Use image node_id 2 for calling the BayesianEstimator obj's underlying member method code with example usage: obj.get_parameters(prior_type, equivalent_sample_size, pseudo_counts, n_jobs, weighted) and returns: parameters, cpd