class_docstr: Class to represent Naive Bayes. Naive Bayes is a special case of Bayesian Model
  where the only edges in the model are from the feature variables to the dependent variable.
class_docstr_tok: ["Class","to","represent","Naive","Bayes",".","Naive","Bayes","is","a","special","case","of","Bayesian","Model","where","the","only","edges","in","the","model","are","from","the","feature","variables","to","the","dependent","variable","."]
docstr: Computes the CPD for each node from a given data in the form of a pandas dataframe.
  If a variable from the data is not present in the model, it adds that node into the model.
  
  Parameters
  ----------
  data : pandas DataFrame object
      A DataFrame object with column names same as the variable names of network
  
  parent_node: any hashable python object (optional)
      Parent node of the model, if not specified it looks for a previously specified
      parent node.
  
  estimator: Estimator class
      Any pgmpy estimator. If nothing is specified, the default ``MaximumLikelihoodEstimator``
      would be used.
  
  Examples
  --------
  >>> import numpy as np
  >>> import pandas as pd
  >>> from pgmpy.models import NaiveBayes
  >>> model = NaiveBayes()
  >>> values = pd.DataFrame(np.random.randint(low=0, high=2, size=(1000, 5)),
  ...                       columns=['A', 'B', 'C', 'D', 'E'])
  >>> model.fit(values, 'A')
  >>> model.get_cpds()
  [<TabularCPD representing P(D:2 | A:2) at 0x4b72870>,
   <TabularCPD representing P(E:2 | A:2) at 0x4bb2150>,
   <TabularCPD representing P(A:2) at 0x4bb23d0>,
   <TabularCPD representing P(B:2 | A:2) at 0x4bb24b0>,
   <TabularCPD representing P(C:2 | A:2) at 0x4bb2750>]
  >>> model.edges()
  [('A', 'D'), ('A', 'E'), ('A', 'B'), ('A', 'C')]
docstr_tok: ["Computes","the","CPD","for","each","node","from","a","given","data","in","the","form","of","a","pandas","dataframe",".","If","a","variable","from","the","data","is","not","present","in","the","model",",","it","adds","that","node","into","the","model",".","Parameters","--","--","--","--","--","data",":","pandas","DataFrame","object","A","DataFrame","object","with","column","names","same","as","the","variable","names","of","network","parent_node",":","any","hashable","python","object","(","optional",")","Parent","node","of","the","model",",","if","not","specified","it","looks","for","a","previously","specified","parent","node",".","estimator",":","Estimator","class","Any","pgmpy","estimator",".","If","nothing","is","specified",",","the","default","``","MaximumLikelihoodEstimator","``","would","be","used",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","import","pandas","as","pd",">",">",">","from","pgmpy.models","import","NaiveBayes",">",">",">","model","=","NaiveBayes","(",")",">",">",">","values","=","pd.DataFrame","(","np.random.randint","(","low=0",",","high=2",",","size=","(","1000",",","5",")",")",",","...","columns=","[","'","A","'",",","'","B","'",",","'","C","'",",","'D","'",",","'","E","'","]",")",">",">",">","model.fit","(","values",",","'","A","'",")",">",">",">","model.get_cpds","(",")","[","<","TabularCPD","representing","P","(","D:2","|","A:2",")","at","0x4b72870",">",",","<","TabularCPD","representing","P","(","E:2","|","A:2",")","at","0x4bb2150",">",",","<","TabularCPD","representing","P","(","A:2",")","at","0x4bb23d0",">",",","<","TabularCPD","representing","P","(","B:2","|","A:2",")","at","0x4bb24b0",">",",","<","TabularCPD","representing","P","(","C:2","|","A:2",")","at","0x4bb2750",">","]",">",">",">","model.edges","(",")","[","(","'","A","'",",","'D","'",")",",","(","'","A","'",",","'","E","'",")",",","(","'","A","'",",","'","B","'",")",",","(","'","A","'",",","'","C","'",")","]"]
code: def fit(self, data, parent_node=None, estimator=None):
      """
      Computes the CPD for each node from a given data in the form of a pandas dataframe.
      If a variable from the data is not present in the model, it adds that node into the model.
  
      Parameters
      ----------
      data : pandas DataFrame object
          A DataFrame object with column names same as the variable names of network
  
      parent_node: any hashable python object (optional)
          Parent node of the model, if not specified it looks for a previously specified
          parent node.
  
      estimator: Estimator class
          Any pgmpy estimator. If nothing is specified, the default ``MaximumLikelihoodEstimator``
          would be used.
  
      Examples
      --------
      >>> import numpy as np
      >>> import pandas as pd
      >>> from pgmpy.models import NaiveBayes
      >>> model = NaiveBayes()
      >>> values = pd.DataFrame(np.random.randint(low=0, high=2, size=(1000, 5)),
      ...                       columns=['A', 'B', 'C', 'D', 'E'])
      >>> model.fit(values, 'A')
      >>> model.get_cpds()
      [<TabularCPD representing P(D:2 | A:2) at 0x4b72870>,
       <TabularCPD representing P(E:2 | A:2) at 0x4bb2150>,
       <TabularCPD representing P(A:2) at 0x4bb23d0>,
       <TabularCPD representing P(B:2 | A:2) at 0x4bb24b0>,
       <TabularCPD representing P(C:2 | A:2) at 0x4bb2750>]
      >>> model.edges()
      [('A', 'D'), ('A', 'E'), ('A', 'B'), ('A', 'C')]
      """
      if not parent_node:
          if not self.dependent:
              raise ValueError(
                  "parent node must be specified for the model"
              )
          else:
              parent_node = self.dependent
      if parent_node not in data.columns:
          raise ValueError(
              f"Dependent variable: {parent_node} is not present in the data"
          )
      for child_node in data.columns:
          if child_node != parent_node:
              self.add_edge(parent_node, child_node)
      super(NaiveBayes, self).fit(data, estimator)
  
file_path: pgmpy/pgmpy/models/NaiveBayes.py
imports: from pgmpy.independencies import Independencies
  from pgmpy.models import BayesianNetwork
label_desc: Use image node_id 7 for calling the NaiveBayes obj's underlying member method code with example usage: obj.fit(data, parent_node, estimator) without return types