title: Python: NameError: global name 'dot_parser' is not defined
body: <p>Python is rather new to me. </p>
  
  <p>I am trying to run the titanic machine learning example of the "Machine Learning in Python with Scikit" book. The classification with decision trees works fine (clf is defined properly) but if I want to visualize the decision tree (see code snippet below) I got the following error message (copied from IPython). </p>
  
  <pre><code>---------------------------------------------------------------------------
  NameError                                 Traceback (most recent call last)
  &lt;ipython-input-34-15b1b4a5d909&gt; in &lt;module&gt;()
        3 dot_data = StringIO.StringIO()
        4 tree.export_graphviz(clf, out_file = dot_data, feature_names = ['PClass', 'AgeFill', 'Gender'])
  ----&gt; 5 graph = pydot.graph_from_dot_data(dot_data.getvalue())
        6 graph.write_png('titanic.png')
  
  C:\Users\885299\AppData\Local\Continuum\Anaconda32\lib\site-packages\pydot.pyc in graph_from_dot_data(data)
  
      218     """
      219 
  --&gt; 220     return dot_parser.parse_dot_data(data)
      221 
      222 
  NameError: global name 'dot_parser' is not defined
  </code></pre>
  
  <p>Can somebody help me? </p>
  
  <p>Code snippet that I used (similar to the book) was:</p>
  
  <pre><code>import pydot, StringIO
  
  dot_data = StringIO.StringIO()
  tree.export_graphviz(clf, out_file = dot_data, feature_names = ['Class', 'Age', 'Gender'])
  graph = pydot.graph_from_dot_data(dot_data.getvalue())
  graph.write_png('titanic.png')
  
  from IPython.core.display import Image
  Image(filename = 'titanic.png')
  </code></pre>