## plot decision tree analysis of any features vs target
def analysis_tree(clf:'estimator',X:'array',y:'array',lx:list,ly:list)->'graph':
"""
Plot decision tree analysis of any features vs target.
clf -- Decision Tree estimator without being fitted (regressor or classificator).
X -- numpy array 2D of features.
y -- numpy array 1D of target.
lx -- list of feature names.
ly -- list of target name.
return -- graph (it is automatically ploted in Jupyter Notebook)
"""
# fit the estimator
clf = clf.fit(X, y)
# graph
import graphviz
dot_data = tree.export_graphviz(clf, out_file=None,
feature_names=lcol_weather,
class_names=['y'],
filled=True, rounded=True,
special_characters=True)
# return
return graphviz.Source(dot_data)
# define estimator
from sklearn import tree
clf = tree.DecisionTreeRegressor(max_depth=3)
# plot tree
analysis_tree(clf,X,y,lx,ly)