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'
4

1 回答 1

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')
于 2016-11-02T10:04:07.547 回答