{"id":7866,"date":"2023-10-06T15:00:01","date_gmt":"2023-10-06T23:00:01","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=7866"},"modified":"2025-04-24T17:05:45","modified_gmt":"2025-04-24T17:05:45","slug":"understanding-tree-based-machine-learning-methods","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/","title":{"rendered":"Understanding Tree-Based Machine Learning Methods"},"content":{"rendered":"\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\">\n\n\n\n<div class=\"mf bg\">\n<figure class=\"mg mh mi mj mk mf bg paragraph-image\"><picture><img loading=\"lazy\" decoding=\"async\" class=\"bg ml mm c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:2200\/1*yPNrgNEhV7_uA9V0BcTIVA.jpeg\" alt=\"\" width=\"2200\" height=\"1467\"><\/picture><figcaption class=\"mn mo mp mq mr ms mt be b bf z dw\" data-selectable-paragraph=\"\">Photo by <a class=\"af mu\" href=\"https:\/\/unsplash.com\/@jaymantri?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noopener ugc nofollow\">Jay Mantri<\/a> on <a class=\"af mu\" href=\"https:\/\/unsplash.com\/s\/photos\/forest?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noopener ugc nofollow\">Unsplash<\/a><\/figcaption><\/figure>\n<\/div>\n\n\n\n<div class=\"ab ca\">\n<div class=\"ch bg eu ev ew ex\">\n<p id=\"5c1b\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Tree-based machine learning methods are among the most commonly used supervised learning methods. They are constructed by two entities; branches and nodes. Tree-based ML methods are built by recursively splitting a training sample, using different features from a dataset at each node that splits the data most effectively. The splitting is based on learning simple decision rules inferred from the training data.<\/p>\n<p id=\"f538\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Generally, tree-based ML methods are simple and intuitive; to predict a class label or value, we start from the top of the tree or the root and, using branches, go to the nodes by comparing features on the basis of which will provide the best split.<\/p>\n<p id=\"e93c\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Tree-based methods also use the mean for continuous variables or mode for categorical variables when making predictions on training observations in the regions they belong to.<\/p>\n<p id=\"add7\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Since the set of rules used to segment the predictor space can be summarized in a visual representation with branches that show all the possible outcomes, these approaches are commonly referred to as <strong class=\"be nq\">decision tree methods<\/strong>.<\/p>\n<p id=\"9456\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">The methods are flexible and can be applied to either classification or regression problems. <em class=\"nr\">Classification and Regression Trees<\/em> (CART) is a commonly used term by Leo Breiman, referring to the flexibility of the methods in solving both linear and non-linear predictive modeling problems.<\/p>\n<h1 id=\"9683\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Types of Decision Trees<\/strong><\/h1>\n<p id=\"f31a\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">Decision trees can be classified based on the type of target or response variable.<\/p>\n<h2 id=\"01d1\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">i.<\/strong> <strong class=\"al\">Classification Trees<\/strong><\/h2>\n<p id=\"1286\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">The default type of decision trees, used when the response variable is categorical\u2014i.e. predicting whether a team will win or lose a game.<\/p>\n<h2 id=\"07b0\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">ii.<\/strong> <strong class=\"al\">Regression Trees<\/strong><\/h2>\n<p id=\"5455\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">Used when the target variable is continuous or numerical in nature\u2014i.e. predicting house prices based on year of construction, number of rooms, etc.<\/p>\n<h1 id=\"e324\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Advantages of Tree-based Machine Learning Methods<\/strong><\/h1>\n<ol class=\"\">\n<li id=\"d6a3\" class=\"mv mw fp be b gn oo my mz gq op nb nc nd pk nf ng nh pl nj nk nl pm nn no np pn po pp bj\" data-selectable-paragraph=\"\"><strong class=\"be nq\">Interpretability<\/strong>: Decision tree methods are easy to understand even for non-technical people.<\/li>\n<li id=\"e8f4\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">The <strong class=\"be nq\">data type isn\u2019t a constraint<\/strong>, as the methods can handle both categorical and numerical variables.<\/li>\n<li id=\"955d\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\"><strong class=\"be nq\">Data exploration<\/strong> \u2014 Decision trees help us easily identify the most significant variables and their correlation.<\/li>\n<\/ol>\n<h1 id=\"129b\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Disadvantages<\/strong> <strong class=\"al\">of Tree-based Machine Learning Methods<\/strong><\/h1>\n<ol class=\"\">\n<li id=\"a915\" class=\"mv mw fp be b gn oo my mz gq op nb nc nd pk nf ng nh pl nj nk nl pm nn no np pn po pp bj\" data-selectable-paragraph=\"\">Large decision trees are <strong class=\"be nq\">complex, time-consuming and less accurate<\/strong> in predicting outcomes.<\/li>\n<li id=\"5d3a\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Decision trees <strong class=\"be nq\">don\u2019t fit well for continuous variables<\/strong>, as they lose important information when segmenting the data into different regions.<\/li>\n<\/ol>\n<h1 id=\"6c0e\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Common Terminology<\/strong><\/h1>\n<figure class=\"mg mh mi mj mk mf mq mr paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ml mm c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:688\/1*UtNgeZ3E7YLln25VS5mwxg.png\" alt=\"\" width=\"688\" height=\"343\"><\/figure><div class=\"mq mr pv\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*UtNgeZ3E7YLln25VS5mwxg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*UtNgeZ3E7YLln25VS5mwxg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*UtNgeZ3E7YLln25VS5mwxg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*UtNgeZ3E7YLln25VS5mwxg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*UtNgeZ3E7YLln25VS5mwxg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*UtNgeZ3E7YLln25VS5mwxg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1376\/format:webp\/1*UtNgeZ3E7YLln25VS5mwxg.png 1376w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 688px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*UtNgeZ3E7YLln25VS5mwxg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*UtNgeZ3E7YLln25VS5mwxg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*UtNgeZ3E7YLln25VS5mwxg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*UtNgeZ3E7YLln25VS5mwxg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*UtNgeZ3E7YLln25VS5mwxg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*UtNgeZ3E7YLln25VS5mwxg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1376\/1*UtNgeZ3E7YLln25VS5mwxg.png 1376w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 688px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"mn mo mp mq mr ms mt be b bf z dw\" data-selectable-paragraph=\"\">Decision Tree structure<\/figcaption>\n<\/figure>\n<p id=\"2690\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">i) <strong class=\"be nq\">Root node<\/strong> \u2014 this represents the entire population or the sample, which gets divided into two or more homogenous subsets.<\/p>\n<p id=\"3174\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">ii) <strong class=\"be nq\">Splitting <\/strong>\u2014 subdividing a node into two or more sub-nodes.<\/p>\n<p id=\"5a73\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">iii) <strong class=\"be nq\">Decision node <\/strong>\u2014 this is when a sub-node is divided into further sub-nodes.<\/p>\n<p id=\"22e9\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">iv) <strong class=\"be nq\">Leaf\/Terminal node<\/strong> \u2014 this is the final\/last node that we consider for our model output. It cannot be split further.<\/p>\n<p id=\"2434\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">v) <strong class=\"be nq\">Pruning \u2014 <\/strong>removing unnecessary sub-nodes of a decision node to combat overfitting.<\/p>\n<p id=\"1472\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">vi) <strong class=\"be nq\">Branch\/Sub-tree<\/strong> \u2014 the sub-section of the entire tree.<\/p>\n<p id=\"f241\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">vii) <strong class=\"be nq\">Parent and Child node <\/strong>\u2014 a node that\u2019s subdivided into a sub-node is a parent, while the sub-node is the child node.<\/p>\n<h1 id=\"4ec6\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Algorithms in Tree-based Machine Learning Models<\/strong><\/h1>\n<p id=\"95d9\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">The decision of splitting a tree affects its accuracy. Tree-based machine learning models use multiple algorithms to decide where to split a node into two or more sub-nodes. The creation of sub-nodes increases the homogeneity of the resultant sub-nodes. Algorithm selection is based on the type of target variable.<\/p>\n<p id=\"fb17\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Suppose you\u2019re the basketball coach of a grade school. The inter-school basketball competitions are nearby and you want to do a survey to determine which students play basketball in their leisure time. The sample selected is 40 students. The selection criterion is based on a number of factors such as gender, height, and class.<\/p>\n<p id=\"c49e\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">As a coach, you\u2019d want to select the students based on the most significant input variable among the three variables.<\/p>\n<p id=\"9330\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Decision tree algorithms will help the coach identify the right sample of students using the variable, which creates the best homogenous set of student players.<\/p>\n<figure class=\"mg mh mi mj mk mf mq mr paragraph-image\">\n<div class=\"px py ec pz bg qa\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ml mm c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*jIvLFgIrpRbxFOpNitAFqQ.png\" alt=\"\" width=\"700\" height=\"469\"><\/figure><div class=\"mq mr pw\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*jIvLFgIrpRbxFOpNitAFqQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*jIvLFgIrpRbxFOpNitAFqQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*jIvLFgIrpRbxFOpNitAFqQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*jIvLFgIrpRbxFOpNitAFqQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*jIvLFgIrpRbxFOpNitAFqQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*jIvLFgIrpRbxFOpNitAFqQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*jIvLFgIrpRbxFOpNitAFqQ.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*jIvLFgIrpRbxFOpNitAFqQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*jIvLFgIrpRbxFOpNitAFqQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*jIvLFgIrpRbxFOpNitAFqQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*jIvLFgIrpRbxFOpNitAFqQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*jIvLFgIrpRbxFOpNitAFqQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*jIvLFgIrpRbxFOpNitAFqQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*jIvLFgIrpRbxFOpNitAFqQ.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"mn mo mp mq mr ms mt be b bf z dw\" data-selectable-paragraph=\"\">Decision tree for students playing basketball<\/figcaption>\n<\/figure>\n<h1 id=\"0464\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Classification and Regression Tree (CART) Training Algorithm<\/strong><\/h1>\n<p id=\"3712\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">CART is used to train a decision tree. It first splits the training set into two subsets using a single feature k and threshold tk\u2014i.e. height\u2265150cm. The algorithm searches for the pair (k, tk) that produces the purest subsets. The cost function for the classification the algorithm tries to minimize is given by:<\/p>\n<figure class=\"mg mh mi mj mk mf mq mr paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ml mm c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*ucy_glLBKAHjlrWgqOB_Lg.png\" alt=\"\" width=\"700\" height=\"159\"><\/figure><div class=\"mq mr qb\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*ucy_glLBKAHjlrWgqOB_Lg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*ucy_glLBKAHjlrWgqOB_Lg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*ucy_glLBKAHjlrWgqOB_Lg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*ucy_glLBKAHjlrWgqOB_Lg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*ucy_glLBKAHjlrWgqOB_Lg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*ucy_glLBKAHjlrWgqOB_Lg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*ucy_glLBKAHjlrWgqOB_Lg.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*ucy_glLBKAHjlrWgqOB_Lg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*ucy_glLBKAHjlrWgqOB_Lg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*ucy_glLBKAHjlrWgqOB_Lg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*ucy_glLBKAHjlrWgqOB_Lg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*ucy_glLBKAHjlrWgqOB_Lg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*ucy_glLBKAHjlrWgqOB_Lg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*ucy_glLBKAHjlrWgqOB_Lg.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/figure>\n<p id=\"cb7d\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">The CART algorithm splits the child nodes using the same approach recursively, and once it reaches the max-depth, it stops.<\/p>\n<p id=\"0fa6\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">We\u2019ll now have a look at the two commonly-used criteria for measuring the impurity of a node; the Gini index and entropy.<\/p>\n<h2 id=\"b6e8\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">i)<\/strong> <strong class=\"al\">Gini Index<\/strong><\/h2>\n<p id=\"3507\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">The Gini index states that if we select two items from a population at random, then they must be of the same class and probability if the population is pure. The target variable is normally categorical, such as pass or fail, and it performs only binary splits. The higher the value of the Gini index, the higher the homogeneity. The CART algorithm uses the Gini method to create binary splits.<\/p>\n<h2 id=\"0348\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Calculating the Gini index<\/strong><\/h2>\n<ol class=\"\">\n<li id=\"5653\" class=\"mv mw fp be b gn oo my mz gq op nb nc nd pk nf ng nh pl nj nk nl pm nn no np pn po pp bj\" data-selectable-paragraph=\"\">We first calculate Gini index for sub-nodes using the sum of the square of probability: p2+q2<\/li>\n<li id=\"27df\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">We then calculate Gini for the split using the weighted Gini score of each node of that split.<\/li>\n<\/ol>\n<p id=\"1738\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Referring to the example above, where the basketball coach wants to separate students based on whether they play basketball or not\u2014using the input variables gender, height, and class, we\u2019ll identify which split produces the most homogenous sub-nodes using the Gini index.<\/p>\n<h2 id=\"dda7\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Split on Gender<\/strong><\/h2>\n<p id=\"7eba\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">Calculating:<\/p>\n<ul class=\"\">\n<li id=\"c578\" class=\"mv mw fp be b gn mx my mz gq na nb nc nd qc nf ng nh qd nj nk nl qe nn no np qf po pp bj\" data-selectable-paragraph=\"\">Gini for sub node female: (0.2*0.2) + (0.8*0.8) =<strong class=\"be nq\">0.68<\/strong><\/li>\n<li id=\"423e\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np qf po pp bj\" data-selectable-paragraph=\"\">Gini for sub node male: (0.6*0.6) + (0.4*0.4) =<strong class=\"be nq\">0.52<\/strong><\/li>\n<li id=\"baab\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np qf po pp bj\" data-selectable-paragraph=\"\">Calculating weighted Gini for split on gender: (10\/40)*0.68+(30\/40)*0.52=<strong class=\"be nq\">0.56<\/strong><\/li>\n<\/ul>\n<h2 id=\"aafd\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Split on Height<\/strong><\/h2>\n<p id=\"2d36\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">Calculating:<\/p>\n<ul class=\"\">\n<li id=\"ef1d\" class=\"mv mw fp be b gn mx my mz gq na nb nc nd qc nf ng nh qd nj nk nl qe nn no np qf po pp bj\" data-selectable-paragraph=\"\">Gini for sub node &lt;5.5ft: (0.44*0.44) + (0.56*0.56) =<strong class=\"be nq\">0.51<\/strong><\/li>\n<li id=\"eb06\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np qf po pp bj\" data-selectable-paragraph=\"\">Gini for sub node &gt;5.5ft: (0.68*0.68) + (0.32*0.32) =<strong class=\"be nq\">0.56<\/strong><\/li>\n<li id=\"7088\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np qf po pp bj\" data-selectable-paragraph=\"\">Calculating weighted Gini for split on height: (18\/40)*0.51+(22\/40)*0.56=<strong class=\"be nq\">0.54<\/strong><\/li>\n<\/ul>\n<h2 id=\"6623\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Split on Class<\/strong><\/h2>\n<p id=\"7be4\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">Calculating:<\/p>\n<ul class=\"\">\n<li id=\"df5e\" class=\"mv mw fp be b gn mx my mz gq na nb nc nd qc nf ng nh qd nj nk nl qe nn no np qf po pp bj\" data-selectable-paragraph=\"\">Gini for sub-node class V: (0.47*0.47) + (0.53*0.53) =<strong class=\"be nq\">0.5<\/strong><\/li>\n<li id=\"cbbf\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np qf po pp bj\" data-selectable-paragraph=\"\">Gini for sub-node class VI: (0.62*0.62) + (0.38*0.38) =<strong class=\"be nq\">0.53<\/strong><\/li>\n<li id=\"dd75\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np qf po pp bj\" data-selectable-paragraph=\"\">Calculating weighted Gini for split on class: (19\/40)*0.5+(21\/40)*0.53=<strong class=\"be nq\">0.52<\/strong><\/li>\n<\/ul>\n<p id=\"6a2d\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">It\u2019s evident that the split based on gender has the highest Gini index, hence the split will take place on gender, which will result in the most homogenous sub-nodes.<\/p>\n<p id=\"55af\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">If we want to calculate the Gini impurity:<\/p>\n<p id=\"f27b\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">1 \u2014 Gini index<\/p>\n<ul class=\"\">\n<li id=\"ab0b\" class=\"mv mw fp be b gn mx my mz gq na nb nc nd qc nf ng nh qd nj nk nl qe nn no np qf po pp bj\" data-selectable-paragraph=\"\">Calculating Gini impurity for gender: 1\u20130.65=0.35<\/li>\n<li id=\"963a\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np qf po pp bj\" data-selectable-paragraph=\"\">Calculating Gini impurity for height: 1\u20130.54=0.46<\/li>\n<li id=\"a0cf\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np qf po pp bj\" data-selectable-paragraph=\"\">Calculating Gini impurity for class: 1\u20130.52=0.48<\/li>\n<\/ul>\n<p id=\"a379\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">The split on class has the highest Gini impurity and will produce the least homogenous sub-nodes.<\/p>\n<h2 id=\"a23b\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">ii)<\/strong> <strong class=\"al\">Entropy<\/strong><\/h2>\n<p id=\"fc55\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">In machine learning, entropy is commonly used as an impurity measure. If a sample is completely homogenous, the entropy is zero, and if the sample is equally divided (50%-50%), it has an entropy of one.<\/p>\n<p id=\"8850\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Entropy is calculated by the following equation:<\/p>\n<figure class=\"mg mh mi mj mk mf mq mr paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ml mm c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:351\/1*JA7aAIdMrBjTakoLn9I_sg.png\" alt=\"\" width=\"351\" height=\"46\"><\/figure><div class=\"mq mr qg\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*JA7aAIdMrBjTakoLn9I_sg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*JA7aAIdMrBjTakoLn9I_sg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*JA7aAIdMrBjTakoLn9I_sg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*JA7aAIdMrBjTakoLn9I_sg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*JA7aAIdMrBjTakoLn9I_sg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*JA7aAIdMrBjTakoLn9I_sg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:702\/format:webp\/1*JA7aAIdMrBjTakoLn9I_sg.png 702w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 351px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*JA7aAIdMrBjTakoLn9I_sg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*JA7aAIdMrBjTakoLn9I_sg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*JA7aAIdMrBjTakoLn9I_sg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*JA7aAIdMrBjTakoLn9I_sg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*JA7aAIdMrBjTakoLn9I_sg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*JA7aAIdMrBjTakoLn9I_sg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:702\/1*JA7aAIdMrBjTakoLn9I_sg.png 702w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 351px\" data-testid=\"og\"><\/picture><\/div>\n<\/figure>\n<p id=\"b0ad\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">P and q are the probability of, say, success and failure in a particular node. Entropy can also be applied to categorical target variables. The lesser the entropy, the better the split.<\/p>\n<h2 id=\"f7fb\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Calculating entropy for a split<\/strong><\/h2>\n<ol class=\"\">\n<li id=\"69ab\" class=\"mv mw fp be b gn oo my mz gq op nb nc nd pk nf ng nh pl nj nk nl pm nn no np pn po pp bj\" data-selectable-paragraph=\"\">Calculate the entropy of the parent node.<\/li>\n<li id=\"0a39\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Calculate the entropy of each individual node of the split.<\/li>\n<li id=\"5636\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Calculate the weighted average of all sub-nodes available on the split.<\/li>\n<\/ol>\n<p id=\"15b9\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">We\u2019ll now calculate the entropy for all the gender, height, and class nodes in the above example.<\/p>\n<ol class=\"\">\n<li id=\"22eb\" class=\"mv mw fp be b gn mx my mz gq na nb nc nd qc nf ng nh qd nj nk nl qe nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for the parent node = -(20\/40) log2 (20\/40) \u2014 (20\/40) log2 (20\/40) = 1. This implies the node is impure.<\/li>\n<li id=\"e3dc\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for the male node = -(18\/30) log2 (18\/30) \u2014 (12\/30) log2 (12\/30) = <strong class=\"be nq\">0.97<\/strong><\/li>\n<li id=\"9e1d\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for the female node = -(2\/10) log2 (2\/10) \u2014 (8\/10) log2 (8\/10) = <strong class=\"be nq\">0.72<\/strong><\/li>\n<li id=\"3219\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for split on gender = weighted entropy of sub nodes= (30\/40) *0.97+(10\/40)*0.72 = <strong class=\"be nq\">0.91<\/strong><\/li>\n<li id=\"5302\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for the &lt;5.5ft node = -(8\/18) log2 (8\/18) \u2014 (10\/18) log2 (10\/18) =<strong class=\"be nq\">0.99<\/strong><\/li>\n<li id=\"f708\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for the &gt;5.5ft node = -(15\/22) log2 (15\/22) \u2014 (7\/22) log2 (7\/22) =<strong class=\"be nq\">0.92<\/strong><\/li>\n<li id=\"91a2\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for split on height = weighted entropy of sub nodes=(18\/40)*0.99+(22\/40)*0.92=<strong class=\"be nq\">0.96<\/strong><\/li>\n<li id=\"2596\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for the class V node = -(9\/19) log2 (9\/19) \u2014 (10\/19) log2 (10\/19) =<strong class=\"be nq\">0.99<\/strong><\/li>\n<li id=\"d621\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for the class VI node = -(13\/21) log2 (13\/21) \u2014 (8\/21) log2 (8\/21) =<strong class=\"be nq\">0.96<\/strong><\/li>\n<li id=\"2e11\" class=\"mv mw fp be b gn pq my mz gq pr nb nc nd ps nf ng nh pt nj nk nl pu nn no np pn po pp bj\" data-selectable-paragraph=\"\">Entropy for split on class = weighted entropy of sub nodes=(19\/40)*0.99+(21\/40)*0.96= <strong class=\"be nq\">0.98<\/strong><\/li>\n<\/ol>\n<p id=\"ea2a\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">It\u2019s evident that the split on gender has the lowest entropy; hence, the most favorable split, which will give homogenous results.<\/p>\n<p id=\"c9b4\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Information gain can be calculated from entropy and is given as:<\/p>\n<p id=\"8a88\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\"><strong class=\"be nq\">Information gain = 1 \u2014 entropy<\/strong><\/p>\n<h1 id=\"1538\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Regularization of Hyperparameters<\/strong><\/h1>\n<p id=\"cfe0\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">Decision trees make very few assumptions about the training data, as opposed to linear models which assume the data is linear.<\/p>\n<p id=\"8a65\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">The tree structure adapts itself to the training data if left unconstrained, resulting in overfitting. Such a model is known as a non-parametric model. The number of parameters in such a model isn\u2019t determined prior to training and the model structure is free to fit closely to the data.<\/p>\n<p id=\"962b\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">A parametric model, such as a linear model, has a predetermined number of parameters; thus, its degree of freedom is limited. This reduces the risk of overfitting but increases the risk of underfitting. In order to avoid overfitting on the training data, we need to restrict the decision tree\u2019s freedom during training. This is known as regularization.<\/p>\n<p id=\"06bb\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">The regularization of hyperparameters depends on the algorithm used. Decision tree classifier algorithms use hyperparameters that restrict the shape of the decision tree, thus preventing both overfitting and underfitting. They include:<\/p>\n<h2 id=\"ed45\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">i)<\/strong> <strong class=\"al\">Min_samples_split<\/strong><\/h2>\n<p id=\"c8a7\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">This is the minimum number of samples a node must have before it can be split. It reduces overfitting.<\/p>\n<h2 id=\"6849\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">ii)<\/strong> <strong class=\"al\">Min_samples_leaf<\/strong><\/h2>\n<p id=\"f8db\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">The minimum number of samples a leaf node must have.<\/p>\n<h2 id=\"c5c2\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">iii)<\/strong> <strong class=\"al\">Max_depth<\/strong><\/h2>\n<p id=\"2f29\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">The maximum depth of a tree. A higher depth allows the model to learn relations that are very specific to a particular sample.<\/p>\n<h2 id=\"2ee7\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">iv)<\/strong> <strong class=\"al\">Max_leaf_nodes<\/strong><\/h2>\n<p id=\"d6ef\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">The maximum number of leaf nodes.<\/p>\n<h2 id=\"51b6\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">v)<\/strong> <strong class=\"al\">Max_features<\/strong><\/h2>\n<p id=\"cdc6\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">The maximum number of features that are evaluated for splitting at each node.<\/p>\n<h2 id=\"091a\" class=\"ot nt fp be nu ou ov ow nx ox oy oz oa nd pa pb pc nh pd pe pf nl pg ph pi pj bj\" data-selectable-paragraph=\"\"><strong class=\"al\">vi)<\/strong> <strong class=\"al\">Min_weight_fraction_leaf<\/strong><\/h2>\n<p id=\"39d4\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">It\u2019s the same as mini_samples_leaf but expressed as a fraction of the total number of weighted instances.<\/p>\n<p id=\"cb22\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Increasing the min_* hyperparameters or reducing max_* hyperparameters regularizes the model.<\/p>\n<figure class=\"mg mh mi mj mk mf mq mr paragraph-image\">\n<div class=\"px py ec pz bg qa\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ml mm c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*x1FhLOgO8NgpVEVoiouGyA.png\" alt=\"\" width=\"700\" height=\"250\"><\/figure><div class=\"mq mr qh\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*x1FhLOgO8NgpVEVoiouGyA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*x1FhLOgO8NgpVEVoiouGyA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*x1FhLOgO8NgpVEVoiouGyA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*x1FhLOgO8NgpVEVoiouGyA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*x1FhLOgO8NgpVEVoiouGyA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*x1FhLOgO8NgpVEVoiouGyA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*x1FhLOgO8NgpVEVoiouGyA.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*x1FhLOgO8NgpVEVoiouGyA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*x1FhLOgO8NgpVEVoiouGyA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*x1FhLOgO8NgpVEVoiouGyA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*x1FhLOgO8NgpVEVoiouGyA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*x1FhLOgO8NgpVEVoiouGyA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*x1FhLOgO8NgpVEVoiouGyA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*x1FhLOgO8NgpVEVoiouGyA.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"mn mo mp mq mr ms mt be b bf z dw\" data-selectable-paragraph=\"\">Regularization using min_samples_leaf<\/figcaption>\n<\/figure>\n<p id=\"053c\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">The figure above shows a decision tree trained with the default hyperparameters (no restrictions), and on the right, it\u2019s trained with min_samples_leaf=4. It\u2019s evident that the model on the left is overfitting, while the model on the right generalizes better to unseen data.<\/p>\n<h1 id=\"1698\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Pruning in Tree-based Algorithms<\/strong><\/h1>\n<p id=\"0611\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">How do we implement pruning in decision trees?<\/p>\n<p id=\"1e39\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">A decision tree without constraints such as <code class=\"cw qi qj qk ql b\">max_depth<\/code> uses a greedy approach and will recursively look for the best split, hence an exponential growth in the nodes. A node whose children are all leaf nodes is considered unnecessary if the purity improvement it provides isn\u2019t statistically significant.<\/p>\n<p id=\"65f1\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Standard statistical tests such as the X2 test are used to estimate the probability that the improvement is purely a result of chance (null hypothesis).<\/p>\n<p id=\"9866\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">If the probability (p-value) is higher than a given threshold (5%), then the node is considered unnecessary, and its children are deleted. Pruning continues until all the unnecessary nodes have been removed.<\/p>\n<h1 id=\"80e1\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Random Forest and Ensemble Learning<\/strong><\/h1>\n<p id=\"8f24\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">If we aggregate the predictions of a group of predictors (regressor or classifier), we\u2019ll often get better predictions than with the individual predictor.<\/p>\n<p id=\"3ec9\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">A group of predictive models that aim to achieve model accuracy and stability is called an ensemble, and the technique used to achieve accuracy is ensemble learning. An ensemble learning algorithm, such as random forest, is an ensemble method.<\/p>\n<p id=\"6196\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">We can train a group of decision tree classifiers, each on a different random subset of the training set. To make the final prediction, we obtain the predictions of all the individual trees, then predict the class that gets the most votes.<\/p>\n<p id=\"da21\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Such an ensemble of decision trees is called a random forest and is one of the most powerful machines learning algorithms out there for simple classification or regression tasks. It\u2019s able to undertake dimensional reduction methods, treat missing values, outlier values, and perform other exploratory data analysis steps.<\/p>\n<p id=\"4b19\" class=\"pw-post-body-paragraph mv mw fp be b gn mx my mz gq na nb nc nd ne nf ng nh ni nj nk nl nm nn no np fi bj\" data-selectable-paragraph=\"\">Random forest algorithms introduce extra randomness when growing trees\u2014 instead of searching for the very best feature when splitting a node, it searches for the best feature among a random subset of features. This results in a greater tree diversity, yielding an overall better model.<\/p>\n<h1 id=\"b4e3\" class=\"ns nt fp be nu nv nw gp nx ny nz gs oa ob oc od oe of og oh oi oj ok ol om on bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Conclusion<\/strong><\/h1>\n<p id=\"944d\" class=\"pw-post-body-paragraph mv mw fp be b gn oo my mz gq op nb nc nd oq nf ng nh or nj nk nl os nn no np fi bj\" data-selectable-paragraph=\"\">Tree-based algorithms are really important for every data scientist to learn. In this article, we\u2019ve covered a wide range of details about tree-based methods; their features and structure, attribute selection algorithms (entropy, Gini index), and random forests.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Photo by Jay Mantri on Unsplash Tree-based machine learning methods are among the most commonly used supervised learning methods. They are constructed by two entities; branches and nodes. Tree-based ML methods are built by recursively splitting a training sample, using different features from a dataset at each node that splits the data most effectively. The [&hellip;]<\/p>\n","protected":false},"author":71,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","footnotes":""},"categories":[6],"tags":[],"coauthors":[169],"class_list":["post-7866","post","type-post","status-publish","format-standard","hentry","category-machine-learning"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Understanding Tree-Based Machine Learning Methods - Comet<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding Tree-Based Machine Learning Methods\" \/>\n<meta property=\"og:description\" content=\"Photo by Jay Mantri on Unsplash Tree-based machine learning methods are among the most commonly used supervised learning methods. They are constructed by two entities; branches and nodes. Tree-based ML methods are built by recursively splitting a training sample, using different features from a dataset at each node that splits the data most effectively. The [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-06T23:00:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:05:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/miro.medium.com\/v2\/resize:fit:2200\/1*yPNrgNEhV7_uA9V0BcTIVA.jpeg\" \/>\n<meta name=\"author\" content=\"Brian Mwangi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brian Mwangi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Understanding Tree-Based Machine Learning Methods - Comet","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/","og_locale":"en_US","og_type":"article","og_title":"Understanding Tree-Based Machine Learning Methods","og_description":"Photo by Jay Mantri on Unsplash Tree-based machine learning methods are among the most commonly used supervised learning methods. They are constructed by two entities; branches and nodes. Tree-based ML methods are built by recursively splitting a training sample, using different features from a dataset at each node that splits the data most effectively. The [&hellip;]","og_url":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2023-10-06T23:00:01+00:00","article_modified_time":"2025-04-24T17:05:45+00:00","og_image":[{"url":"https:\/\/miro.medium.com\/v2\/resize:fit:2200\/1*yPNrgNEhV7_uA9V0BcTIVA.jpeg","type":"","width":"","height":""}],"author":"Brian Mwangi","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Brian Mwangi","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/#article","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/"},"author":{"name":"Brian Mwangi","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/11e566851d7c80669e55ab10e6191a68"},"headline":"Understanding Tree-Based Machine Learning Methods","datePublished":"2023-10-06T23:00:01+00:00","dateModified":"2025-04-24T17:05:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/"},"wordCount":2016,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:2200\/1*yPNrgNEhV7_uA9V0BcTIVA.jpeg","articleSection":["Machine Learning"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/","url":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/","name":"Understanding Tree-Based Machine Learning Methods - Comet","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:2200\/1*yPNrgNEhV7_uA9V0BcTIVA.jpeg","datePublished":"2023-10-06T23:00:01+00:00","dateModified":"2025-04-24T17:05:45+00:00","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/#primaryimage","url":"https:\/\/miro.medium.com\/v2\/resize:fit:2200\/1*yPNrgNEhV7_uA9V0BcTIVA.jpeg","contentUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:2200\/1*yPNrgNEhV7_uA9V0BcTIVA.jpeg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/understanding-tree-based-machine-learning-methods\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"Understanding Tree-Based Machine Learning Methods"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/11e566851d7c80669e55ab10e6191a68","name":"Brian Mwangi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/d5b4daae2a6d50ff0f7f08cf468e8eec","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/1632239369714-96x96.jpg","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/1632239369714-96x96.jpg","caption":"Brian Mwangi"},"url":"https:\/\/www.comet.com\/site\/blog\/author\/brynmwangygmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/71"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=7866"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7866\/revisions"}],"predecessor-version":[{"id":15507,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7866\/revisions\/15507"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=7866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=7866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=7866"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=7866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}