to create figure we used the python method make_blobs from the sklearn module to produce training set of size with ten-dimensional feature vectors (thusp and )each of which is classified into one of classes the full code is given below treedepthcv py import numpy as np from sklearn datasets import make_blobs from sklearn model_selection import cross_val_score from sklearn tree import decisiontreeclassifier from sklearn metrics import zero_one_loss import matplotlib pyplot as plt def zeroonescore (clf xy)y_pred clf predict (xreturn zero_one_loss (yy_pred construct the training set xy make_blobs n_samples = n_features = centers = random_state = cluster_std = construct decision tree classifier clf decisiontreeclassifier random_state = cross validation loss as function of tree depth ( to xdepthlist [cvlist [tree_depth range ( , for in tree_depth xdepthlist append (dclf max_depth = cv np meancross_val_score (clf xycv = scoring zeroonescore )cvlist append (cvplt xlabel ('tree depth 'fontsize = color ='black 'plt ylabel ('loss 'fontsize = color ='black 'plt plotxdepthlist cvlist ,-*linewidth = the code above relies heavily on sklearn and hides the implementation details to show how decision trees are actually constructed using the previous theorywe proceed with very basic implementation basic implementation in this section we implement regression treestep by step to run the programamalgamate the code snippets below into one filein the order presented firstwe import various packages and define function to generate the training and test data the data used for figure was produced in similar way