class_docstr: Abstract base class for structure scoring classes in pgmpy. Use any of the derived classes
  K2Score, BDeuScore, BicScore or AICScore. Scoring classes are
  used to measure how well a model is able to describe the given data set.
  
  Parameters
  ----------
  data: pandas DataFrame object
      dataframe object where each column represents one variable.
      (If some values in the data are missing the data cells should be set to `numpy.NaN`.
      Note that pandas converts each column containing `numpy.NaN`s to dtype `float`.)
  
  state_names: dict (optional)
      A dict indicating, for each variable, the discrete set of states (or values)
      that the variable can take. If unspecified, the observed values in the data set
      are taken to be the only possible states.
  
  Reference
  ---------
  Koller & Friedman, Probabilistic Graphical Models - Principles and Techniques, 2009
  Section 18.3
class_docstr_tok: ["Abstract","base","class","for","structure","scoring","classes","in","pgmpy",".","Use","any","of","the","derived","classes","K2Score",",","BDeuScore",",","BicScore","or","AICScore",".","Scoring","classes","are","used","to","measure","how","well","a","model","is","able","to","describe","the","given","data","set",".","Parameters","--","--","--","--","--","data",":","pandas","DataFrame","object","dataframe","object","where","each","column","represents","one","variable",".","(","If","some","values","in","the","data","are","missing","the","data","cells","should","be","set","to","`","numpy.NaN","`",".","Note","that","pandas","converts","each","column","containing","`","numpy.NaN","`","s","to","dtype","`","float","`",".",")","state_names",":","dict","(","optional",")","A","dict","indicating",",","for","each","variable",",","the","discrete","set","of","states","(","or","values",")","that","the","variable","can","take",".","If","unspecified",",","the","observed","values","in","the","data","set","are","taken","to","be","the","only","possible","states",".","Reference","--","--","--","--","-","Koller","&","Friedman",",","Probabilistic","Graphical","Models","-","Principles","and","Techniques",",","2009","Section","18.3"]
docstr: Computes a score to measure how well the given `BayesianNetwork` fits
  to the data set.  (This method relies on the `local_score`-method that
  is implemented in each subclass.)
  
  Parameters
  ----------
  model: BayesianNetwork instance
      The Bayesian network that is to be scored. Nodes of the BayesianNetwork need to coincide
      with column names of data set.
  
  Returns
  -------
  score: float
      A number indicating the degree of fit between data and model
  
  Examples
  --------
  >>> import pandas as pd
  >>> import numpy as np
  >>> from pgmpy.models import BayesianNetwork
  >>> from pgmpy.estimators import K2Score
  >>> # create random data sample with 3 variables, where B and C are identical:
  >>> data = pd.DataFrame(np.random.randint(0, 5, size=(5000, 2)), columns=list('AB'))
  >>> data['C'] = data['B']
  >>> K2Score(data).score(BayesianNetwork([['A','B'], ['A','C']]))
  -24242.367348745247
  >>> K2Score(data).score(BayesianNetwork([['A','B'], ['B','C']]))
  -16273.793897051042
docstr_tok: ["Computes","a","score","to","measure","how","well","the","given","`","BayesianNetwork","`","fits","to","the","data","set",".","(","This","method","relies","on","the","`","local_score","`","-method","that","is","implemented","in","each","subclass",".",")","Parameters","--","--","--","--","--","model",":","BayesianNetwork","instance","The","Bayesian","network","that","is","to","be","scored",".","Nodes","of","the","BayesianNetwork","need","to","coincide","with","column","names","of","data","set",".","Returns","--","--","--","-","score",":","float","A","number","indicating","the","degree","of","fit","between","data","and","model","Examples","--","--","--","--",">",">",">","import","pandas","as","pd",">",">",">","import","numpy","as","np",">",">",">","from","pgmpy.models","import","BayesianNetwork",">",">",">","from","pgmpy.estimators","import","K2Score",">",">",">","#","create","random","data","sample","with","3","variables",",","where","B","and","C","are","identical",":",">",">",">","data","=","pd.DataFrame","(","np.random.randint","(","0",",","5",",","size=","(","5000",",","2",")",")",",","columns=list","(","'AB","'",")",")",">",">",">","data","[","'","C","'","]","=","data","[","'","B","'","]",">",">",">","K2Score","(","data",")",".score","(","BayesianNetwork","(","[","[","'","A","'",",","'","B","'","]",",","[","'","A","'",",","'","C","'","]","]",")",")","-24242.367348745247",">",">",">","K2Score","(","data",")",".score","(","BayesianNetwork","(","[","[","'","A","'",",","'","B","'","]",",","[","'","B","'",",","'","C","'","]","]",")",")","-16273.793897051042"]
code: def score(self, model):
      """
      Computes a score to measure how well the given `BayesianNetwork` fits
      to the data set.  (This method relies on the `local_score`-method that
      is implemented in each subclass.)
  
      Parameters
      ----------
      model: BayesianNetwork instance
          The Bayesian network that is to be scored. Nodes of the BayesianNetwork need to coincide
          with column names of data set.
  
      Returns
      -------
      score: float
          A number indicating the degree of fit between data and model
  
      Examples
      --------
      >>> import pandas as pd
      >>> import numpy as np
      >>> from pgmpy.models import BayesianNetwork
      >>> from pgmpy.estimators import K2Score
      >>> # create random data sample with 3 variables, where B and C are identical:
      >>> data = pd.DataFrame(np.random.randint(0, 5, size=(5000, 2)), columns=list('AB'))
      >>> data['C'] = data['B']
      >>> K2Score(data).score(BayesianNetwork([['A','B'], ['A','C']]))
      -24242.367348745247
      >>> K2Score(data).score(BayesianNetwork([['A','B'], ['B','C']]))
      -16273.793897051042
      """
  
      score = 0
      for node in model.nodes():
          score += self.local_score(node, model.predecessors(node))
      score += self.structure_prior(model)
      return score
  
imports: from math import lgamma, log
  import numpy
  from scipy.special import gammaln
  from pgmpy.estimators import BaseEstimator
label_desc: Use image node_id 2 for calling the StructureScore obj's underlying member method code with example usage: obj.score(model) and returns: score