class_docstr: Search class for exhaustive searches over all DAGs with a given set of variables.
  Takes a `StructureScore`-Instance as parameter; `estimate` finds the model with maximal score.
  
  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`.)
  
  scoring_method: Instance of a `StructureScore`-subclass (`K2Score` is used as default)
      An instance of `K2Score`, `BDeuScore`, `BicScore` or 'AICScore'.
      This score is optimized during structure estimation by the `estimate`-method.
  
  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.
  
  use_caching: boolean
      If True, uses caching of score for faster computation.
      Note: Caching only works for scoring methods which are decomposable. Can
      give wrong results in case of custom scoring methods.
class_docstr_tok: ["Search","class","for","exhaustive","searches","over","all","DAGs","with","a","given","set","of","variables",".","Takes","a","`","StructureScore","`","-Instance","as","parameter",";","`","estimate","`","finds","the","model","with","maximal","score",".","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","`",".",")","scoring_method",":","Instance","of","a","`","StructureScore","`","-subclass","(","`","K2Score","`","is","used","as","default",")","An","instance","of","`","K2Score","`",",","`","BDeuScore","`",",","`","BicScore","`","or","'AICScore","'",".","This","score","is","optimized","during","structure","estimation","by","the","`","estimate","`","-method",".","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",".","use_caching",":","boolean","If","True",",","uses","caching","of","score","for","faster","computation",".","Note",":","Caching","only","works","for","scoring","methods","which","are","decomposable",".","Can","give","wrong","results","in","case","of","custom","scoring","methods","."]
docstr: Estimates the `DAG` structure that fits best to the given data set,
  according to the scoring method supplied in the constructor.
  Exhaustively searches through all models. Only estimates network structure, no parametrization.
  
  Returns
  -------
  Estimated Model: pgmpy.base.DAG
      A `DAG` with maximal score.
  
  Examples
  --------
  >>> import pandas as pd
  >>> import numpy as np
  >>> from pgmpy.estimators import ExhaustiveSearch
  >>> # 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']
  >>> est = ExhaustiveSearch(data)
  >>> best_model = est.estimate()
  >>> best_model
  <pgmpy.base.DAG.DAG object at 0x7f695c535470>
  >>> best_model.edges()
  [('B', 'C')]
docstr_tok: ["Estimates","the","`","DAG","`","structure","that","fits","best","to","the","given","data","set",",","according","to","the","scoring","method","supplied","in","the","constructor",".","Exhaustively","searches","through","all","models",".","Only","estimates","network","structure",",","no","parametrization",".","Returns","--","--","--","-","Estimated","Model",":","pgmpy.base.DAG","A","`","DAG","`","with","maximal","score",".","Examples","--","--","--","--",">",">",">","import","pandas","as","pd",">",">",">","import","numpy","as","np",">",">",">","from","pgmpy.estimators","import","ExhaustiveSearch",">",">",">","#","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","'","]",">",">",">","est","=","ExhaustiveSearch","(","data",")",">",">",">","best_model","=","est.estimate","(",")",">",">",">","best_model","<","pgmpy.base.DAG.DAG","object","at","0x7f695c535470",">",">",">",">","best_model.edges","(",")","[","(","'","B","'",",","'","C","'",")","]"]
code: def estimate(self):
      """
      Estimates the `DAG` structure that fits best to the given data set,
      according to the scoring method supplied in the constructor.
      Exhaustively searches through all models. Only estimates network structure, no parametrization.
  
      Returns
      -------
      Estimated Model: pgmpy.base.DAG
          A `DAG` with maximal score.
  
      Examples
      --------
      >>> import pandas as pd
      >>> import numpy as np
      >>> from pgmpy.estimators import ExhaustiveSearch
      >>> # 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']
      >>> est = ExhaustiveSearch(data)
      >>> best_model = est.estimate()
      >>> best_model
      <pgmpy.base.DAG.DAG object at 0x7f695c535470>
      >>> best_model.edges()
      [('B', 'C')]
      """
  
      best_dag = max(self.all_dags(), key=self.scoring_method.score)
  
      best_model = DAG()
      best_model.add_nodes_from(sorted(best_dag.nodes()))
      best_model.add_edges_from(sorted(best_dag.edges()))
      return best_model
  
file_path: pgmpy/pgmpy/estimators/ExhaustiveSearch.py
imports: from itertools import combinations
  import networkx
  from pgmpy.base import DAG
  from pgmpy.estimators import K2Score, ScoreCache, StructureEstimator
  from pgmpy.global_vars import logger
  from pgmpy.utils.mathext import powerset
label_desc: Use image node_id 4 for calling the ExhaustiveSearch obj's underlying member method code with example usage: obj.estimate() and returns: best_model