Scikit learn 可视化随机回归树
我在sklearn中运行了一个随机森林回归模型,并将我的决策树(n_估计器=50)的输出保存到50个Scikit learn 可视化随机回归树,scikit-learn,pydot,Scikit Learn,Pydot,我在sklearn中运行了一个随机森林回归模型,并将我的决策树(n_估计器=50)的输出保存到50个.dot文件中 现在我想保存它们,以便将它们视为实际的树 我正在尝试: 导入pydotplus dot\u data=r'F:\Sheyenne\Random\u Forest\my\u tree0.dot' graph=pydotplus.graph_from_dot_数据(dot_数据) graph.write_pdf(r'F:\Sheyenne\Random_Forest\my_tree0.
.dot
文件中
现在我想保存它们,以便将它们视为实际的树
我正在尝试:
导入pydotplus
dot\u data=r'F:\Sheyenne\Random\u Forest\my\u tree0.dot'
graph=pydotplus.graph_from_dot_数据(dot_数据)
graph.write_pdf(r'F:\Sheyenne\Random_Forest\my_tree0.pdf')
但这也带来了:
AttributeError: 'NoneType' object has no attribute 'write_pdf'
看起来您正在尝试加载文件。试试这个:
导入pydotplus
dot\u file=r'F:\Sheyenne\Random\u Forest\my\u tree0.dot'
graph=pydotplus.graph\u来自dot\u文件(dot\u文件)
graph.write_pdf(r'F:\Sheyenne\Random_Forest\my_tree0.pdf')