【问题标题】:Visualizing RandomForestRegression trees可视化 RandomForestRegression 树
【发布时间】:2017-03-15 05:59:44
【问题描述】:

我在 sklearn 中运行了一个 RandomForestRegression 模型,并将我的决策树 (n_estimators=50) 的输出保存到 50 个.dot 文件中。

现在我想保存它们,以便将它们视为实际的树。

我正在尝试这个:

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'

【问题讨论】:

    标签: scikit-learn pydot


    【解决方案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')
    

    【讨论】:

      猜你喜欢
      • 2013-12-22
      • 2012-07-03
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-17
      相关资源
      最近更新 更多