Mac安装 画图工具pydotplus

Mac下安装graphviz

终端执行

brew install graphviz

然后安装

pip install pydotplus

到 notebook 里测试下

mport numpy as np
import pandas as pd
from sklearn.tree import DecisionTreeClassifier
# 仍然使用自带的iris数据
from sklearn.datasets import load_iris
iris = load_iris()
X = pd.DataFrame(iris.data[:, :-1])
Y = pd.DataFrame(iris.target)
model = DecisionTreeClassifier(criterion="entropy").fit(X,Y)
model.predict(X)
model
from IPython.display import Image  
from sklearn import tree
import pydotplus 
dot_data = tree.export_graphviz(model, out_file=None, 
                         filled=True, rounded=True,  
                         special_characters=True)  
graph = pydotplus.graph_from_dot_data(dot_data)  
Image(graph.create_png()) 

Mac安装 画图工具pydotplus_第1张图片

你可能感兴趣的:(机器学习)