列表索引超出范围,Graphviz

时间:2019-01-13 18:10:10

标签: python pygraphviz

我正在尝试可视化我在以下协作笔记本中生成的决策树:https://colab.research.google.com/drive/1jw7ZSHsQEV4ueBi7paEl7w0Dhjbe_CDK

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-21-4c74a23b947f> in <module>()
      3     feature_names = X.columns,
      4     class_names=['',''],
----> 5     filled=True
      6 )
      7 #graph = pydotplss.graph_from_dot_data(dot_data)

/usr/local/lib/python3.6/dist-packages/sklearn/tree/export.py in export_graphviz(decision_tree, out_file, max_depth, feature_names, class_names, label, filled, leaves_parallel, impurity, node_ids, proportion, rotate, rounded, special_characters, precision)
    457 
    458         # Now recurse the tree and add node & edge attributes
--> 459         recurse(decision_tree.tree_, 0, criterion=decision_tree.criterion)
    460 
    461         # If required, draw leaf nodes at same depth as each other

/usr/local/lib/python3.6/dist-packages/sklearn/tree/export.py in recurse(tree, node_id, criterion, parent, depth)
    334             out_file.write('%d [label=%s'
    335                            % (node_id,
--> 336                               node_to_str(tree, node_id, criterion)))
    337 
    338             if filled:

/usr/local/lib/python3.6/dist-packages/sklearn/tree/export.py in node_to_str(tree, node_id, criterion)
    299                 node_string += 'class = '
    300             if class_names is not True:
--> 301                 class_name = class_names[np.argmax(value)]
    302             else:
    303                 class_name = "y%s%s%s" % (characters[1],

IndexError: list index out of range

0 个答案:

没有答案