2016-11-02 14 views
1

私はsklearnでRandomForestRegressionモデルを実行し、決定木(n_estimators = 50)の出力を50 .dotファイルに保存しました。RandomForestRegressionツリーの可視化

今私はそれらを実際の木として見ることができるように保存したいと思います。

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

をこれが返されます:

私はこれをしようとしていますあなたがファイルをロードしようとしているよう

AttributeError: 'NoneType' object has no attribute 'write_pdf' 

答えて

1

が見えます。試してみてください:

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