Home > other >  CART decision tree runs to finally produce IndexError: list index out of range error, the great god
CART decision tree runs to finally produce IndexError: list index out of range error, the great god

Time:09-25

 the from IPython. Display the import Image 
Dot_data=https://bbs.csdn.net/topics/tree.export_graphviz (CLF, out_file=None,
Feature_names=feature. The columns. Tolist (),
Class_names=target_names,
Filled=True, rounded=True,
Special_characters=True, node_ids=True, rotate=True, the label='all')
Graph=pydotplus. Graph_from_dot_data (dot_data. Replace (' \ n ', '). The replace (' helvetica ', '" Microsoft YaHei "))
Image (graph. Create_png ())
this is my last a code block, then run after an error, error below
 IndexError Traceback (the most recent call last) 

4 class_names=target_names,
5 filled=True, rounded=True,
- & gt; 6 special_characters=True, node_ids=True, rotate=True, the label='all')
7 graph=pydotplus. Graph_from_dot_data (dot_data. Replace (' \ n ', '). The replace (' helvetica ', '" Microsoft YaHei "))
8 Image (graph. Create_png ())

~ \ Anaconda3 \ lib \ site - 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 & amp; Edge attributes
- & gt; 459 recurse (decision_tree. Tree_, 0, criterion=decision_tree, criterion)
460
461 # If required, the draw the leaf nodes at same the depth as each other

~ \ Anaconda3 \ lib \ site - packages \ sklearn \ tree \ export py in recurse (tree, node_id, criterion, the parent, the depth)
377 if left_child!=_tree. TREE_LEAF:
378 recurse (tree, left_child, criterion=criterion, the parent=node_id,
- & gt; 379 the depth the depth of=+ 1)
380 recurse (tree, right_child, criterion=criterion, the parent=node_id,
381 the depth the depth of=+ 1)

~ \ Anaconda3 \ lib \ site - packages \ sklearn \ tree \ export py in recurse (tree, node_id, criterion, the parent, the depth)
334 out_file. Write (' [label=% d % s'
335% (node_id,
- & gt; 336 node_to_str (tree, node_id, criterion)))
337
338 if filled:

~ \ Anaconda3 \ lib \ site - packages \ sklearn \ tree \ export py in node_to_str (tree, node_id, criterion)
299 node_string +="class="
300 if class_names is not True:
- & gt; 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

Try a variety of solution are not good, have a great god give directions! urgent
  • Related