Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
101 views
in Technique[技术] by (71.8m points)

python - What could be the reason that Pycharm is not rendering graphviz.Source(...)? (Mac)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...