I tried to run the following code:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
df = pd.read_csv("...")
pd.set_option("expand_frame_repr", False)
print(df.head)
X = df[["age", "interest"]].values
y = df["success"].values
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0, test_size=0.25)
model = DecisionTreeClassifier(criterion="entropy")
model.fit(X_train, y_train)
print(model.score(X_test, y_test))
from sklearn.tree import export_graphviz
tree = export_graphviz(model, None)
print(tree)
import graphviz
graphviz.Source(tree)
no errors are displayed whatsoever. I assumed that graphviz.Source would be sufficient to display the decision tree, but apparently no graphic displays.
Any hints are appreciated.
question from:
https://stackoverflow.com/questions/65862140/what-could-be-the-reason-that-pycharm-is-not-rendering-graphviz-source-ma 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…