title: TypeError: 'DiscreteFactor' object is not subscriptable
body: <p>I have a Bayesian algorithm program to be executed, I am using python 3</p>
  <pre><code>import numpy as np
  import csv
  import pandas as pd
  from pgmpy.models import BayesianModel
  from pgmpy.estimators import MaximumLikelihoodEstimator
  from pgmpy.inference import VariableElimination
  
  
  heartDisease = pd.read_csv('heart.csv')
  heartDisease = heartDisease.replace('?',np.nan)
  
  print('Few examples from the dataset are given below')
  print(heartDisease.head())
  
  model = BayesianModel([('age','trestbps'),('age','fbs'),('sex','trestbps'),('exang','trestbps'),('trestbps','heartdisease'),('fbs','heartdisease'),('heartdisease','restecg'),('heartdisease','thalach'),('heartdisease','chol')])
  
  print('\nLearning CPD using Maximum likelihood estimators')
  model.fit(heartDisease,estimator=MaximumLikelihoodEstimator)
  
  print('\n Inferencing with Bayesian Network:')
  HeartDisease_infer = VariableElimination(model)
  
  print('\n 1. Probability of HeartDisease given Age=28')
  q=HeartDisease_infer.query(variables=['heartdisease'],evidence={'age':28})
  print(q['heartdisease'])
  
  print('\n 2. Probability of HeartDisease given cholesterol=100')
  q=HeartDisease_infer.query(variables=['heartdisease'],evidence={'chol':100})
  print(q['heartdisease'])
  </code></pre>
  <p>the error that i have recieved when i run my Bayesian network program is:</p>
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-7-84a6b48627b2&gt; in &lt;module&gt;
       23 print('\n 1. Probability of HeartDisease given Age=28')
       24 q=HeartDisease_infer.query(variables=['heartdisease'],evidence={'age':28})
  ---&gt; 25 print(q['heartdisease'])
       26 
       27 print('\n 2. Probability of HeartDisease given cholesterol=100')
  
  TypeError: 'DiscreteFactor' object is not subscriptable
  </code></pre>
  <p>So far I haven't seen this exact error here on stackoverflow. Can anyone explain why I am getting this error?</p>