2016-11-02 4 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') 
관련 문제