docs: def predict(self, data):
          """
          Predicts states of all the missing variables.
  
          Parameters
          ----------
          data : pandas DataFrame object
              A DataFrame object with column names same as the variables in the model.
  
          Examples
          --------
          >>> import numpy as np
          >>> import pandas as pd
          >>> from pgmpy.models import BayesianModel
          >>> values = pd.DataFrame(np.random.randint(low=0, high=2, size=(1000, 5)),
          ...                       columns=['A', 'B', 'C', 'D', 'E'])
          >>> train_data = values[:800]
          >>> predict_data = values[800:]
          >>> model = BayesianModel([('A', 'B'), ('C', 'B'), ('C', 'D'), ('B', 'E')])
          >>> model.fit(values)
          >>> predict_data = predict_data.copy()
          >>> predict_data.drop('E', axis=1, inplace=True)
          >>> y_pred = model.predict(predict_data)
          >>> y_pred
              E
          800 0
          801 1
          802 1
          803 1
          804 0
          ... ...
          993 0
          994 0
          995 1
          996 1
          997 0
          998 0
          999 0
          """
          from pgmpy.inference import VariableElimination
  
          if set(data.columns) == set(self.nodes()):
              raise ValueError("No variable missing in data. Nothing to predict")
  
          elif set(data.columns) - set(self.nodes()):
              raise ValueError("Data has variables which are not in the model")
  
          missing_variables = set(self.nodes()) - set(data.columns)
          pred_values = defaultdict(list)
  
          # Send state_names dict from one of the estimated CPDs to the inference class.
          model_inference = VariableElimination(self, state_names=self.get_cpds()[0].state_names)
          for index, data_point in data.iterrows():
              states_dict = model_inference.map_query(variables=missing_variables, evidence=data_point.to_dict())
              for k, v in states_dict.items():
                  pred_values[k].append(v)
          return pd.DataFrame(pred_values, index=data.index)