December 2018
Beginner to intermediate
684 pages
21h 9m
English
The notebook also illustrates how to run cross-validation more manually to obtain custom tree attributes, such as the total number of nodes or leaf nodes associated with certain hyperparameter settings. The following function accesses the internal .tree_ attribute to retrieve information about the total node count, and how many of these nodes are leaf nodes:
def get_leaves_count(tree): t = tree.tree_ n = t.node_count leaves = len([i for i in range(t.node_count) if t.children_left[i]== -1]) return leaves
We can combine this information with the train and test scores to gain detailed knowledge about the model behavior throughout the cross-validation process, as follows:
train_scores, val_scores, leaves = {} ...
Read now
Unlock full access