Visualizing decision tree in scikit-learn

后端 未结 11 2189
广开言路
广开言路 2020-12-02 10:26

I am trying to design a simple Decision Tree using scikit-learn in Python (I am using Anaconda\'s Ipython Notebook with Python 2.7.3 on Windows OS) and visualize it as follo

11条回答
  •  情话喂你
    2020-12-02 11:26

    Simple way founded here with pydotplus (graphviz must be installed):

    from IPython.display import Image  
    from sklearn import tree
    import pydotplus # installing pyparsing maybe needed
    

    ...

    dot_data = tree.export_graphviz(best_model, out_file=None, feature_names = X.columns)
    graph = pydotplus.graph_from_dot_data(dot_data)
    Image(graph.create_png())
    

提交回复
热议问题