[英]Huge problem to display decision tree in Jupyter Notebook in Python: ExecutableNotFound?
I have a problem to create and display decision tree in Jupyter Notebook using Python.我在使用 Python 在 Jupyter Notebook 中创建和显示决策树时遇到问题。 My code is as below:
我的代码如下:
X = data.drop(["Risk"], axis=1)
y = data["Risk"]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
from sklearn.tree import DecisionTreeClassifier
klasyfikator = DecisionTreeClassifier(criterion = "gini", random_state=0, max_depth=4, min_samples_leaf=1)
klasyfikator.fit(X = X, y = y)
data = export_graphviz(klasyfikator,out_file=None,feature_names=X.columns,class_names=["0", "1"],
filled=True, rounded=True,
special_characters=True)
graph = graphviz.Source(data)
graph
Generally this decision tree concerns credit risk research 0 - will not pay 1 - will pay.通常,此决策树涉及信用风险研究 0 - 不会支付 1 - 会支付。
When I use code above, I have error like this:当我使用上面的代码时,我有这样的错误:
ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH
ExecutableNotFound:无法执行 ['dot', '-Tsvg'],请确保 Graphviz 可执行文件在您系统的 PATH 中
I have already tried many solutions from StackOverflow, for example:我已经尝试过 StackOverflow 的许多解决方案,例如:
C:\\Program Files (x86)\\Graphviz2.38\\bin C:\\Program Files (x86)\\Graphviz2.38\\bin
And there is still error described above.并且仍然存在上述错误。 What can I do?
我能做什么? what should I do ?
我该怎么办 ? Please help me guys because I'm losing hope of being able to draw this tree.
请帮助我,因为我失去了能够画这棵树的希望。 Thank you!
谢谢!
Moreover, when I added by using this code:此外,当我使用此代码添加时:
import os
os.environ["PATH"] += os.pathsep + 'C:\Program Files (x86)\Graphviz2.38\bin'
I have in PATH something like this: C:\\\\Program Files (x86)\\\\Graphviz2.38\\x08in
it is not the same, what can I do ?我在 PATH 中有这样的东西:
C:\\\\Program Files (x86)\\\\Graphviz2.38\\x08in
它不一样,我该怎么办?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.