NameError Traceback (most recent call last) <ipython-input-5-66fc4f9977e5> in <module> 213 mytree = createTree(dataSet,labels) 214 print(f'决策树:{mytree}') --> 215 tree_plotter.create_plot(mytree) 216 217 #测试数据 NameError: name 'tree_plotter' is not defined
时间: 2024-02-14 19:03:14 浏览: 95
The error message "NameError: name 'tree_plotter' is not defined" suggests that the name "tree_plotter" was not defined in the code. In other words, the code is trying to call a function or variable named "tree_plotter" but it has not been defined or imported into the current scope.
To fix this error, you may need to check if the module or library containing the "tree_plotter" function has been imported correctly. You can try adding an import statement at the beginning of the code, for example:
```
import tree_plotter
```
If the "tree_plotter" function is part of a class or object, you may also need to make sure that you have created an instance of the class or object before calling the function.
Alternatively, if the "tree_plotter" function is not available in any module or library, you may need to define it yourself or find a suitable implementation online.
阅读全文