![]() ![]() Therefore, it is recommended to download the installation package from the official website. Tip: the Graphviz library downloaded by using the package management tool in pycharm does not seem to contain the tools we will use later. dot documents, but after all, I use the education mailbox just in case, and the effect loaded through the extension is not very good, the definition is very low, and it can't be scaled and saved) (in fact, the pycharm professional I use can download and parse the extension of. If you want to parse the decision tree in graphical form, you also need to install the Graphviz library This is obviously not the intuitive representation I want. Because Windows itself will edit the document according to the format of the document Open dot, so you can see such a document: This method generates a Dot document, which stores information about the decision tree. Tree.export_graphviz(dtc, out_file=dot_file, feature_names=feature_names) With open('breast_tree_graph.dot', 'w') as dot_file: However, this representation method is still too lengthy and not very readable, so I decided to adopt the second method: # Export a visual decision tree Try: tree.export_text(dtc, feature_names=list(feature_names)) He vaguely felt that there was a problem with the data type (my feature_names parameter specifies an array of ndarray), so he converted the array type of ndarray into a list. He searched the meaning of the last a.any() and a.all() of the error report. I took its source code and looked back and forth several times, but I didn't find the problem. I try to solve this problem, although there is a feature in this method_ The parameters of names, but I set them. What each feature is is is not reflected in the text. The following is the actual effect of printing What this method does, like its name, is to express the original tree object (called dtc in the code) as a piece of text. ![]() Let's take a look at the first method: tree.export_text(dtc) Therefore, the tree object itself defines some export methods to transform the decision tree algorithm originally an abstract data matrix into a text language with high readability. ![]() Due to the training model generated in this way, the internal information is not intuitive, and only some functions such as The value of score() to roughly judge the adaptability of the model to a new dataset is obviously not in line with the current trend of visualization. Of course, this is not the focus of this paper. In the process of learning decision tree, I saw the related operations of decision tree visualization.įirstly, the tree object of sklearn library is used for tree building and model training: from sklearn import tree Recently, because of the great innovation, I began to learn machine learning. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |