1

I have run a RandomForestRegression model in sklearn and saved the output of my decisions trees (n_estimators=50) into 50 .dot files.

Now I want to save them so I can view them as actual trees.

I am trying this:

import pydotplus

dot_data=r'F:\Sheyenne\Random_Forest\my_tree0.dot'

graph = pydotplus.graph_from_dot_data(dot_data) 

graph.write_pdf(r'F:\Sheyenne\Random_Forest\my_tree0.pdf')

but this returns:

AttributeError: 'NoneType' object has no attribute 'write_pdf'
javad
  • 498
  • 4
  • 15
Stefano Potter
  • 3,467
  • 10
  • 45
  • 82

1 Answers1

1

Looks like you are trying to load a file. Try this:

import pydotplus

dot_file=r'F:\Sheyenne\Random_Forest\my_tree0.dot'

graph = pydotplus.graph_from_dot_file(dot_file) 

graph.write_pdf(r'F:\Sheyenne\Random_Forest\my_tree0.pdf')
javad
  • 498
  • 4
  • 15