In [4]:
from sklearn.datasets import fetch_openml
df = fetch_openml(name='Weather', version='1')
y = df.target
X = df.data
In [11]:
X
Out[11]:
In [5]:
from sklearn.tree import DecisionTreeClassifier
tree_model = DecisionTreeClassifier(criterion='entropy', max_depth=4, random_state=1)
tree_model.fit(X, y)
Out[5]:
In [6]:
from sklearn import tree
import matplotlib.pyplot as plt
tree.plot_tree(tree_model)
plt.show()