In [9]:
from sklearn.tree import DecisionTreeRegressor
from bokeh.sampledata.autompg import autompg
In [10]:
d=DecisionTreeRegressor()
In [11]:
autompg.info()
autompg.columns
Out[11]:
In [13]:
y=autompg.pop('mpg')
x=autompg[[u'cyl', u'displ', u'hp', u'weight', u'accel', u'yr', u'origin']]
In [15]:
d.fit(x,y)
Out[15]:
In [24]:
from IPython.display import Image
from sklearn.externals.six import StringIO
dot_data = StringIO()
tree.export_graphviz(d, out_file=dot_data,
feature_names=iris.feature_names,
class_names=iris.target_names,
filled=True, rounded=True,
special_characters=True)
graph = pydot.graph_from_dot_data(dot_data.getvalue())
Image(graph.create_png())