#-*- coding: utf-8 -*-
from sklearn.tree import DecisionTreeClassifier as DTC
from sklearn.tree import export_graphviz
x = [
[1,1],[1,0],[0,]
y = [ 1,1,0]
dtc = DTC(criterion='entropy')
dtc.fit(x,y)
with open('af.dot','w') as f:
f = export_graphviz(dtc,feature_names=['no surfacing','flippers'],out_file = f)
运行dot命令将dot文件转换成pdf
dot -Tpdf af.dot -o af.pdf