代码之家  ›  专栏  ›  技术社区  ›  anitasp

export\u graphviz extratreesclassifier python可视化

  •  3
  • anitasp  · 技术社区  · 7 年前

    有没有办法使用export\u graphviz来表示extratreesclasiffier的最终树?如果没有,如何在视觉上表现?

    1 回复  |  直到 7 年前
        1
  •  2
  •   probitaille    7 年前

    我认为没有办法从 sklearn。表演团体树外分类器 .

    但是你可以用一棵树从 sklearn。树外部分类器 .

    from sklearn import tree
    ...
    
    #Fit an Extra Tree model to the data
    model = tree.ExtraTreeClassifier()
    model.fit(X_train, y_train)
    
    #Use http://webgraphviz.com to visualize the graph of this file
    with open("tree_classifier.txt", "w") as f:
        f = tree.export_graphviz(model, out_file=f)
    

    下面是一个决策树示例,该示例也适用于额外的树: http://dataaspirant.com/2017/04/21/visualize-decision-tree-python-graphviz/