Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Decision tree learning
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Machine learning algorithm}} {{about|decision trees in machine learning|the use of the term in decision analysis|Decision tree}} {{Machine learning|Supervised learning}} '''Decision tree learning''' is a [[supervised learning]] approach used in [[statistics]], [[data mining]] and [[machine learning]]. In this formalism, a classification or regression [[decision tree]] is used as a [[predictive model]] to draw conclusions about a set of observations. Tree models where the target variable can take a discrete set of values are called '''[[Statistical classification|classification]] [[decision tree|trees]]'''; in these tree structures, [[leaf node|leaves]] represent class labels and branches represent [[Logical conjunction|conjunction]]s of features that lead to those class labels. Decision trees where the target variable can take continuous values (typically [[real numbers]]) are called '''[[regression analysis|regression]] [[decision tree|trees]]'''. More generally, the concept of regression tree can be extended to any kind of object equipped with pairwise dissimilarities such as categorical sequences.<ref name=":1">{{Cite journal |last1=Studer |first1=Matthias |last2=Ritschard |first2=Gilbert |last3=Gabadinho |first3=Alexis |last4=MΓΌller |first4=Nicolas S. |date=2011 |title=Discrepancy Analysis of State Sequences |url=http://journals.sagepub.com/doi/10.1177/0049124111415372 |journal=Sociological Methods & Research |language=en |volume=40 |issue=3 |pages=471β510 |doi=10.1177/0049124111415372 |s2cid=13307797 |issn=0049-1241}}</ref> Decision trees are among the most popular machine learning algorithms given their intelligibility and simplicity because they produce models that are easy to interpret and visualize, even for users without a statistical background.<ref>{{Cite journal|last1=Wu|first1=Xindong|last2=Kumar|first2=Vipin|last3=Ross Quinlan|first3=J.|last4=Ghosh|first4=Joydeep|last5=Yang|first5=Qiang|last6=Motoda|first6=Hiroshi|last7=McLachlan|first7=Geoffrey J.|last8=Ng|first8=Angus|last9=Liu|first9=Bing|last10=Yu|first10=Philip S.|last11=Zhou|first11=Zhi-Hua|date=2008-01-01|title=Top 10 algorithms in data mining|journal=Knowledge and Information Systems|language=en|volume=14|issue=1|pages=1β37|doi=10.1007/s10115-007-0114-2|s2cid=2367747|issn=0219-3116|hdl=10983/15329|hdl-access=free}}</ref> In decision analysis, a decision tree can be used to visually and explicitly represent decisions and [[decision making]]. In [[data mining]], a decision tree describes data (but the resulting classification tree can be an input for decision making). ==General== [[File:Decision Tree.jpg|thumb|A tree showing survival of passengers on the [[Titanic]] ("sibsp" is the number of spouses or siblings aboard). The figures under the leaves show the probability of survival and the percentage of observations in the leaf. Summarizing: Your chances of survival were good if you were (i) a female or (ii) a male at most 9.5 years old with strictly fewer than 3 siblings.]] Decision tree learning is a method commonly used in data mining.<ref name="tdidt">{{Cite book |last=Rokach |first=Lior |author2=Maimon, O. |title=Data mining with decision trees: theory and applications, 2nd Edition |year=2014 |publisher=World Scientific Pub Co Inc |doi=10.1142/9097 |isbn=978-9814590075 |s2cid=44697571 }}</ref> The goal is to create a model that predicts the value of a target variable based on several input variables. A decision tree is a simple representation for classifying examples. For this section, assume that all of the input [[Feature (machine learning)|feature]]s have finite discrete domains, and there is a single target feature called the "classification". Each element of the domain of the classification is called a ''class''. A decision tree or a classification tree is a tree in which each internal (non-leaf) node is labeled with an input feature. The arcs coming from a node labeled with an input feature are labeled with each of the possible values of the target feature or the arc leads to a subordinate decision node on a different input feature. Each leaf of the tree is labeled with a class or a probability distribution over the classes, signifying that the data set has been classified by the tree into either a specific class, or into a particular probability distribution (which, if the decision tree is well-constructed, is skewed towards certain subsets of classes). A tree is built by splitting the source [[Set (mathematics)|set]], constituting the root node of the tree, into subsetsβwhich constitute the successor children. The splitting is based on a set of splitting rules based on classification features.<ref>{{Cite book|title=Understanding Machine Learning|last1=Shalev-Shwartz|first1=Shai|publisher=Cambridge University Press|url=http://www.cs.huji.ac.il/~shais/UnderstandingMachineLearning|last2=Ben-David|first2=Shai|date=2014|chapter=18. Decision Trees}}</ref> This process is repeated on each derived subset in a recursive manner called [[recursive partitioning]]. The [[recursion]] is completed when the subset at a node has all the same values of the target variable, or when splitting no longer adds value to the predictions. This process of ''top-down induction of decision trees'' (TDIDT)<ref name="Quinlan86">{{Cite journal | url=https://link.springer.com/content/pdf/10.1007/BF00116251.pdf | doi=10.1007/BF00116251| title=Induction of decision trees| journal=Machine Learning| volume=1| pages=81β106| year=1986| last1=Quinlan| first1=J. R.| s2cid=189902138| doi-access=free}}</ref> is an example of a [[greedy algorithm]], and it is by far the most common strategy for learning decision trees from data.<ref name="top-downDT" /> In [[data mining]], decision trees can be described also as the combination of mathematical and computational techniques to aid the description, categorization and generalization of a given set of data. Data comes in records of the form: :<math>(\textbf{x},Y) = (x_1, x_2, x_3, ..., x_k, Y)</math> The dependent variable, <math>Y</math>, is the target variable that we are trying to understand, classify or generalize. The vector <math>\textbf{x}</math> is composed of the features, <math>x_1, x_2, x_3</math> etc., that are used for that task. [[File:Cart tree kyphosis.png|thumb|800px| alt=Three different representations of a regression tree of kyphosis data| An example tree which estimates the probability of [[kyphosis]] after spinal surgery, given the age of the patient and the vertebra at which surgery was started. The same tree is shown in three different ways. '''Left''' The colored leaves show the probability of kyphosis after spinal surgery, and percentage of patients in the leaf. '''Middle''' The tree as a perspective plot. '''Right''' Aerial view of the middle plot. The probability of kyphosis after surgery is higher in the darker areas. (Note: The treatment of [[kyphosis]] has advanced considerably since this rather small set of data was collected.{{citation needed|date=December 2019}}) ]] == Decision tree types == Decision trees used in [[data mining]] are of two main types: * '''[[Classification tree]]''' analysis is when the predicted outcome is the class (discrete) to which the data belongs. * '''Regression tree''' analysis is when the predicted outcome can be considered a real number (e.g. the price of a house, or a patient's length of stay in a hospital). The term '''classification and regression tree (CART)''' analysis is an [[umbrella term]] used to refer to either of the above procedures, first introduced by [[Leo Breiman|Breiman]] et al. in 1984.<ref name="bfos">{{Cite book |last=Breiman |first=Leo |author2=Friedman, J. H. |author3=Olshen, R. A. |author4=Stone, C. J. |title=Classification and regression trees |year=1984 |publisher=Wadsworth & Brooks/Cole Advanced Books & Software |location=Monterey, CA |isbn=978-0-412-04841-8 }}</ref> Trees used for regression and trees used for classification have some similarities β but also some differences, such as the procedure used to determine where to split.<ref name="bfos"/> Some techniques, often called ''ensemble'' methods, construct more than one decision tree: * '''[[Gradient boosted trees|Boosted trees]]''' Incrementally building an ensemble by training each new instance to emphasize the training instances previously mis-modeled. A typical example is [[AdaBoost]]. These can be used for regression-type and classification-type problems.<ref>Friedman, J. H. (1999). ''[https://astro.temple.edu/~msobel/courses_files/StochasticBoosting(gradient).pdf Stochastic gradient boosting] {{Webarchive|url=https://web.archive.org/web/20181128041212/https://astro.temple.edu/~msobel/courses_files/StochasticBoosting(gradient).pdf |date=2018-11-28 }}.'' Stanford University.</ref><ref>Hastie, T., Tibshirani, R., Friedman, J. H. (2001). ''The elements of statistical learning : Data mining, inference, and prediction.'' New York: Springer Verlag.</ref> * '''Committees of decision trees''' (also called k-DT<ref>Heath, D., Kasif, S. and Salzberg, S. (1993). ''k-DT: A multi-tree learning method.'' In ''Proceedings of the Second Intl. Workshop on Multistrategy Learning'', pp. 138-149.</ref>), an early method that used randomized decision tree algorithms to generate multiple different trees from the training data, and then combine them using majority voting to generate output.<ref>Heath, D., Kasif, S., and Salzberg, S. L. (1996). ''Committees of decision trees.'' In B. Gorayska and J. Mey (Eds.), ''Cognitive Technology: In Search of a Humane Interface'' (pp. 305β317). Amsterdam: Elsevier Science B.V.</ref> * '''[[Bootstrap aggregating|Bootstrap aggregated]]''' (or bagged) decision trees, an early ensemble method, builds multiple decision trees by repeatedly [[Bootstrapping (statistics)|resampling training data with replacement]], and voting the trees for a consensus prediction.<ref>{{cite journal |last=Breiman |first=L. |year=1996 |title=Bagging Predictors |journal=Machine Learning |volume=24 |issue=2 |pages=123β140 |doi=10.1007/BF00058655 |doi-access=free }}</ref> ** A '''[[random forest]]''' classifier is a specific type of [[bootstrap aggregating]] * '''Rotation forest''' β in which every decision tree is trained by first applying [[principal component analysis]] (PCA) on a random subset of the input features.<ref>{{cite journal |last1=Rodriguez |first1=J. J. |last2=Kuncheva |first2=L. I.|author2-link=Ludmila Kuncheva |last3=Alonso |first3=C. J. |year=2006 |title=Rotation forest: A new classifier ensemble method |journal=IEEE Transactions on Pattern Analysis and Machine Intelligence |volume=28 |issue=10 |pages=1619β1630 |doi=10.1109/TPAMI.2006.211 |pmid=16986543 |citeseerx=10.1.1.156.8277 |s2cid=6847493 }}</ref> A special case of a decision tree is a [[decision list]],<ref>{{cite journal|last1=Rivest|first1=Ron|title=Learning Decision Lists|journal=Machine Learning|date=Nov 1987|volume=3|issue=2|pages=229β246|doi=10.1023/A:1022607331053|s2cid=30625841|url=http://people.csail.mit.edu/rivest/pubs/Riv87b.pdf|doi-access=free}}</ref> which is a one-sided decision tree, so that every internal node has exactly 1 leaf node and exactly 1 internal node as a child (except for the bottommost node, whose only child is a single leaf node). While less expressive, decision lists are arguably easier to understand than general decision trees due to their added sparsity{{citation needed|date=December 2021}}, permit non-greedy learning methods<ref>{{cite journal|last1=Letham|first1=Ben|last2=Rudin|first2=Cynthia|author2-link= Cynthia Rudin |last3=McCormick|first3=Tyler|last4=Madigan|first4=David|title=Interpretable Classifiers Using Rules And Bayesian Analysis: Building A Better Stroke Prediction Model|journal=Annals of Applied Statistics|date=2015|volume=9|issue=3|pages=1350β1371|doi=10.1214/15-AOAS848|arxiv=1511.01644|s2cid=17699665}}</ref> and monotonic constraints to be imposed.<ref>{{cite journal|last1=Wang|first1=Fulton|last2=Rudin|first2=Cynthia|author2-link=Cynthia Rudin|title=Falling Rule Lists|journal=Journal of Machine Learning Research|date=2015|volume=38|url=http://www.jmlr.org/proceedings/papers/v38/wang15a.pdf|access-date=2016-01-22|archive-date=2016-01-28|archive-url=https://web.archive.org/web/20160128223950/http://www.jmlr.org/proceedings/papers/v38/wang15a.pdf|url-status=dead}}</ref> Notable decision tree algorithms include: * [[ID3 algorithm|ID3]] (Iterative Dichotomiser 3) * [[C4.5 algorithm|C4.5]] (successor of ID3) * CART (Classification And Regression Tree)<ref name="bfos" /> * OC1 (Oblique classifier 1). First method that created multivariate splits at each node.<ref>{{Cite journal | doi = 10.1613/jair.63 | last1 = Murthy | first1 = S. K. | year = 1994 | title = A System for Induction of Oblique Decision Trees | journal = Journal of Artificial Intelligence Research | volume = 2 | issue = 1 | pages = 1β32 | doi-access = free }}</ref> * [[Chi-square automatic interaction detection]] (CHAID). Performs multi-level splits when computing classification trees.<ref>{{Cite journal | doi = 10.2307/2986296 | last1 = Kass | first1 = G. V. | year = 1980 | title = An exploratory technique for investigating large quantities of categorical data | jstor = 2986296| journal = Applied Statistics | volume = 29 | issue = 2| pages = 119β127 }}</ref><ref>{{Cite journal|last1=Biggs|first1=David|last2=De Ville|first2=Barry|last3=Suen|first3=Ed|date=1991|title=A method of choosing multiway partitions for classification and decision trees|url=https://doi.org/10.1080/02664769100000005|journal=Journal of Applied Statistics|volume=18|issue=1|pages=49β62|doi=10.1080/02664769100000005|bibcode=1991JApSt..18...49B |issn=0266-4763}}</ref><ref>Ritschard, G. (2013), '''"'''CHAID and Earlier Supervised Tree Methods", in J.J. McArdle and G. Ritschard (eds), ''Contemporary Issues in Exploratory Data Mining in the Behavioral Sciences'', Quantitative Methodology Series, New York: Routledge, pages 48-74. [https://www.researchgate.net/publication/315476407_CHAID_and_Earlier_Supervised_Tree_Methods Preprint]</ref> * [[Multivariate adaptive regression splines|MARS]]: extends decision trees to handle numerical data better. * Conditional Inference Trees. Statistics-based approach that uses non-parametric tests as splitting criteria, corrected for multiple testing to avoid overfitting. This approach results in unbiased predictor selection and does not require pruning.<ref name="Hothorn2006">{{Cite journal | doi = 10.1198/106186006X133933 | last1 = Hothorn | first1 = T.| last2 = Hornik | first2 = K.| last3 = Zeileis | first3 = A.| year = 2006 | title = Unbiased Recursive Partitioning: A Conditional Inference Framework | jstor = 27594202| journal = Journal of Computational and Graphical Statistics | volume = 15 | issue = 3| pages = 651β674 | citeseerx = 10.1.1.527.2935 | s2cid = 6074128 }}</ref><ref name="Strobl2009">{{Cite journal | doi = 10.1037/a0016973 | pmid = 19968396 | pmc = 2927982 | last1 = Strobl | first1 = C.| last2 = Malley | first2 = J.| last3 = Tutz | first3 = G.| year = 2009 | title = An Introduction to Recursive Partitioning: Rationale, Application and Characteristics of Classification and Regression Trees, Bagging and Random Forests | journal = Psychological Methods | volume = 14 | issue = 4| pages = 323β348 }}</ref> ID3 and CART were invented independently at around the same time (between 1970 and 1980){{Citation needed|date=August 2014}}, yet follow a similar approach for learning a decision tree from training tuples. It has also been proposed to leverage concepts of [[fuzzy set theory]] for the definition of a special version of decision tree, known as Fuzzy Decision Tree (FDT).<ref name="Janikow1998">{{Cite journal | doi=10.1109/3477.658573| title=Fuzzy decision trees: issues and methods| journal=IEEE Transactions on Systems, Man, and Cybernetics - Part B: Cybernetics| volume=28| pages=1β14| year=1998| last1=Janikow| first1=C. Z.| issue=1| pmid=18255917}}</ref> In this type of fuzzy classification, generally, an input vector <math>\textbf{x}</math> is associated with multiple classes, each with a different confidence value. Boosted ensembles of FDTs have been recently investigated as well, and they have shown performances comparable to those of other very efficient fuzzy classifiers.<ref name="Barsacchi2020">{{Cite journal | url=http://www.sciencedirect.com/science/article/pii/S0957417420302608 | doi=10.1016/j.eswa.2020.113436| title=An analysis of boosted ensembles of binary fuzzy decision trees| journal=Expert Systems with Applications| volume=154| year=2020| last1=Barsacchi| first1=M.|last2=Bechini| first2=A.|last3=Marcelloni| first3=F.| page=113436| s2cid=216369273}}</ref> ==Metrics== Algorithms for constructing decision trees usually work top-down, by choosing a variable at each step that best splits the set of items.<ref name="top-downDT">{{cite journal |last1=Rokach |first1=L. |last2=Maimon |first2=O. |title=Top-down induction of decision trees classifiers-a survey |journal=IEEE Transactions on Systems, Man, and Cybernetics - Part C: Applications and Reviews |volume=35 |pages=476β487 |year=2005 |doi=10.1109/TSMCC.2004.843247 |issue=4|citeseerx=10.1.1.458.7031 |s2cid=14808716 }}</ref> Different algorithms use different metrics for measuring "best". These generally measure the homogeneity of the target variable within the subsets. Some examples are given below. These metrics are applied to each candidate subset, and the resulting values are combined (e.g., averaged) to provide a measure of the quality of the split. Depending on the underlying metric, the performance of various heuristic algorithms for decision tree learning may vary significantly.<ref name="thask">{{Cite thesis |last=Najmann |first=Oliver |title=Techniques and heuristics for acquiring symbolic knowledge from examples. |year=1992 |publisher=Doctoral thesis |url=https://d-nb.info/921171064 }}</ref> === Estimate of Positive Correctness === A simple and effective metric can be used to identify the degree to which true positives outweigh false positives (see [[Confusion matrix]]). This metric, "Estimate of Positive Correctness" is defined below: <math> E_P = TP - FP </math> In this equation, the total false positives (FP) are subtracted from the total true positives (TP). The resulting number gives an estimate on how many positive examples the feature could correctly identify within the data, with higher numbers meaning that the feature could correctly classify more positive samples. Below is an example of how to use the metric when the full confusion matrix of a certain feature is given: '''Feature A Confusion Matrix''' {| class="wikitable" ! {{diagonal split header|Actual Class|Predicted<br />Class}} !Cancer !Non-cancer |- !Cancer |<u>8</u> |3 |- !Non-cancer |<u>2</u> |5 |} Here we can see that the TP value would be 8 and the FP value would be 2 (the underlined numbers in the table). When we plug these numbers in the equation we are able to calculate the estimate: <math>E_p = TP - FP = 8 - 2 = 6</math>. This means that using the estimate on this feature would have it receive a score of 6. However, it should be worth noting that this number is only an estimate. For example, if two features both had a FP value of 2 while one of the features had a higher TP value, that feature would be ranked higher than the other because the resulting estimate when using the equation would give a higher value. This could lead to some inaccuracies when using the metric if some features have more positive samples than others. To combat this, one could use a more powerful metric known as [[Sensitivity and specificity|Sensitivity]] that takes into account the proportions of the values from the confusion matrix to give the actual [[Sensitivity and specificity|true positive rate]] (TPR). The difference between these metrics is shown in the example below: {| |+ |'''Feature A Confusion Matrix''' {| class="wikitable" ! {{diagonal split header|Actual Class|Predicted<br />Class}} !Cancer !Non-cancer |- !Cancer |8 |3 |- !Non-cancer |2 |5 |} |style="padding-left: 4em;" | '''Feature B Confusion Matrix''' {| class="wikitable" ! {{diagonal split header|Actual Class|Predicted<br />Class}} !Cancer !Non-cancer |- !Cancer |6 |2 |- !Non-cancer |2 |8 |} |- |<math>E_p = TP - FP = 8 - 2 = 6</math> <math>TPR = TP / (TP + FN) = 8 / (8 + 3) \approx 0.73 </math> |style="padding-left: 4em;" | <math>E_p = TP - FP = 6 - 2 = 4</math> <math>TPR = TP / (TP + FN) = 6 / (6 + 2) = 0.75 </math> |} In this example, Feature A had an estimate of 6 and a TPR of approximately 0.73 while Feature B had an estimate of 4 and a TPR of 0.75. This shows that although the positive estimate for some feature may be higher, the more accurate TPR value for that feature may be lower when compared to other features that have a lower positive estimate. Depending on the situation and knowledge of the data and decision trees, one may opt to use the positive estimate for a quick and easy solution to their problem. On the other hand, a more experienced user would most likely prefer to use the TPR value to rank the features because it takes into account the proportions of the data and all the samples that should have been classified as positive. ===Gini impurity=== '''Gini impurity''', '''Gini's diversity index''',<ref>{{cite web |title=Growing Decision Trees |url=https://www.mathworks.com/help/stats/growing-decision-trees.html |website=MathWorks }}</ref> or '''[[Diversity index#GiniβSimpson index|Gini-Simpson Index]]''' in biodiversity research, is named after Italian mathematician [[Corrado Gini]] and used by the CART (classification and regression tree) algorithm for classification trees. Gini impurity measures how often a randomly chosen element of a set would be incorrectly labeled if it were labeled randomly and independently according to the distribution of labels in the set. It reaches its minimum (zero) when all cases in the node fall into a single target category. For a set of items with <math>J</math> classes and relative frequencies <math>p_i</math>, <math>i \in \{1, 2, ...,J\}</math>, the probability of choosing an item with label <math>i</math> is <math>p_i</math>, and the probability of miscategorizing that item is <math>\sum_{k \ne i} p_k = 1-p_i</math>. The Gini impurity is computed by summing pairwise products of these probabilities for each class label: :<math>\operatorname{I}_G(p) = \sum_{i=1}^J \left( p_i \sum_{k\neq i} p_k \right) = \sum_{i=1}^J p_i (1-p_i) = \sum_{i=1}^J (p_i - p_i^2) = \sum_{i=1}^J p_i - \sum_{i=1}^J p_i^2 = 1 - \sum^J_{i=1} p_i^2. </math> The Gini impurity is also an information theoretic measure and corresponds to [[Tsallis Entropy]] with deformation coefficient <math>q=2</math>, which in physics is associated with the lack of information in out-of-equilibrium, non-extensive, dissipative and quantum systems. For the limit <math>q\to 1</math> one recovers the usual Boltzmann-Gibbs or Shannon entropy. In this sense, the Gini impurity is nothing but a variation of the usual entropy measure for decision trees. ===Information gain=== {{main|Information gain in decision trees}} Used by the [[ID3 algorithm|ID3]], [[C4.5 algorithm|C4.5]] and C5.0 tree-generation algorithms. [[Information gain]] is based on the concept of [[information entropy|entropy]] and [[information content]] from [[information theory]]. Entropy is defined as below :<math>\Eta(T) = \operatorname{I}_{E}\left(p_1, p_2, \ldots, p_J\right) = - \sum^J_{i=1} p_i \log_2 p_i</math> where <math>p_1, p_2, \ldots</math> are fractions that add up to 1 and represent the percentage of each class present in the child node that results from a split in the tree.<ref name="Witten 2011 102β103">{{Cite book|title=Data Mining|url=https://archive.org/details/dataminingpracti00witt_966|url-access=limited|last1=Witten|first1=Ian|last2=Frank|first2=Eibe|last3=Hall|first3=Mark|publisher=Morgan Kaufmann|year=2011|isbn=978-0-12-374856-0|location=Burlington, MA|pages=[https://archive.org/details/dataminingpracti00witt_966/page/n136 102]β103}}</ref> :<math display="block"> \overbrace{IG(T,a)}^\text{information gain} = \overbrace{\Eta(T)}^\text{entropy (parent)} - \overbrace{\Eta(T\mid a)}^\text{sum of entropies (children)} </math><math>=-\sum_{i=1}^J p_i\log_2 p_i - \sum_{i=1}^J - \Pr(i\mid a)\log_2 \Pr(i\mid a)</math> Averaging over the possible values of <math>A</math>, :<math display="block"> \overbrace{E_A(\operatorname{IG}(T,a))}^\text{expected information gain} = \overbrace{I(T; A)}^{\text{mutual information between } T \text{ and } A} = \overbrace{\Eta(T)}^\text{entropy (parent)} - \overbrace{\Eta(T\mid A)}^\text{weighted sum of entropies (children)} </math><math>=-\sum_{i=1}^J p_i\log_2 p_i - \sum_a p(a)\sum_{i=1}^J-\Pr(i\mid a) \log_2 \Pr(i\mid a) </math> :Where weighted sum of entropies is given by, :<math>{\Eta(T\mid A)}= \sum_a p(a)\sum_{i=1}^J-\Pr(i\mid a) \log_2 \Pr(i\mid a)</math> That is, the expected information gain is the [[mutual information]], meaning that on average, the reduction in the entropy of ''T'' is the mutual information. Information gain is used to decide which feature to split on at each step in building the tree. Simplicity is best, so we want to keep our tree small. To do so, at each step we should choose the split that results in the most consistent child nodes. A commonly used measure of consistency is called [[Information theory|information]] which is measured in [[bit]]s. For each node of the tree, the information value "represents the expected amount of information that would be needed to specify whether a new instance should be classified yes or no, given that the example reached that node".<ref name="Witten 2011 102β103"/> Consider an example data set with four attributes: ''outlook'' (sunny, overcast, rainy), ''temperature'' (hot, mild, cool), ''humidity'' (high, normal), and ''windy'' (true, false), with a binary (yes or no) target variable, ''play'', and 14 data points. To construct a decision tree on this data, we need to compare the information gain of each of four trees, each split on one of the four features. The split with the highest information gain will be taken as the first split and the process will continue until all children nodes each have consistent data, or until the information gain is 0. To find the information gain of the split using ''windy'', we must first calculate the information in the data before the split. The original data contained nine yes's and five no's. :<math> I_E([9,5]) = -\frac 9 {14}\log_2 \frac 9 {14} - \frac 5 {14}\log_2 \frac 5 {14} = 0.94 </math> The split using the feature ''windy'' results in two children nodes, one for a ''windy'' value of true and one for a ''windy'' value of false. In this data set, there are six data points with a true ''windy'' value, three of which have a ''play'' (where ''play'' is the target variable) value of yes and three with a ''play'' value of no. The eight remaining data points with a ''windy'' value of false contain two no's and six yes's. The information of the ''windy''=true node is calculated using the entropy equation above. Since there is an equal number of yes's and no's in this node, we have :<math> I_E([3,3]) = -\frac 3 6\log_2 \frac 3 6 - \frac 3 6\log_2 \frac 3 6 = -\frac 1 2\log_2 \frac 1 2 - \frac 1 2\log_2 \frac 1 2 = 1 </math> For the node where ''windy''=false there were eight data points, six yes's and two no's. Thus we have :<math> I_E([6,2]) = -\frac 6 8\log_2 \frac 6 8 - \frac 2 8\log_2 \frac 2 8 = -\frac 3 4\log_2 \frac 3 4 - \frac 1 4\log_2 \frac 1 4 = 0.81 </math> To find the information of the split, we take the weighted average of these two numbers based on how many observations fell into which node. :<math> I_E([3,3],[6,2]) = I_E(\text{windy or not}) = \frac 6 {14} \cdot 1 + \frac 8 {14} \cdot 0.81 = 0.89 </math> Now we can calculate the information gain achieved by splitting on the ''windy'' feature. :<math> \operatorname{IG}(\text{windy}) = I_E([9,5]) - I_E([3,3],[6,2]) = 0.94 - 0.89 = 0.05 </math> To build the tree, the information gain of each possible first split would need to be calculated. The best first split is the one that provides the most information gain. This process is repeated for each impure node until the tree is complete. This example is adapted from the example appearing in Witten et al.<ref name="Witten 2011 102β103"/> Information gain is also known as [[Diversity index#Shannon index|Shannon index]] in bio diversity research. ===Variance reduction=== Introduced in CART,<ref name="bfos"/> variance reduction is often employed in cases where the target variable is continuous (regression tree), meaning that use of many other metrics would first require discretization before being applied. The variance reduction of a node {{mvar|N}} is defined as the total reduction of the variance of the target variable {{mvar|Y}} due to the split at this node: :<math> I_V(N) = \frac{1}{|S|^2}\sum_{i\in S} \sum_{j\in S} \frac{1}{2}(y_i - y_j)^2 - \left(\frac{|S_t|^2}{|S|^2}\frac{1}{|S_t|^2}\sum_{i\in S_t} \sum_{j\in S_t} \frac{1}{2}(y_i - y_j)^2 + \frac{|S_f|^2}{|S|^2}\frac{1}{|S_f|^2}\sum_{i\in S_f} \sum_{j\in S_f} \frac{1}{2}(y_i - y_j)^2\right) </math> where <math>S</math>, <math>S_t</math>, and <math>S_f</math> are the set of presplit sample indices, set of sample indices for which the split test is true, and set of sample indices for which the split test is false, respectively. Each of the above summands are indeed [[variance]] estimates, though, written in a form without directly referring to the mean. By replacing <math>(y_i - y_j)^2</math> in the formula above with the dissimilarity <math>d_{ij}</math> between two objects <math>i</math> and <math>j</math>, the variance reduction criterion applies to any kind of object for which pairwise dissimilarities can be computed.<ref name=":1" /> ===Measure of "goodness"=== Used by CART in 1984,<ref name="ll">{{Cite book |last=Larose |first=Daniel T. |author2=Larose, Chantal D. |title=Discovering knowledge in data: an introduction to data mining |year=2014 |publisher=John Wiley & Sons, Inc |location=Hoboken, NJ |isbn=9781118874059 }}</ref> the measure of "goodness" is a function that seeks to optimize the balance of a candidate split's capacity to create pure children with its capacity to create equally-sized children. This process is repeated for each impure node until the tree is complete. The function <math>\varphi(s\mid t)</math>, where <math>s</math> is a candidate split at node <math>t</math>, is defined as below :<math> \varphi(s\mid t) = 2P_L P_R \sum_{j=1}^\text{class count}|P(j\mid t_L) - P(j\mid t_R)| </math> where <math>t_L</math> and <math>t_R</math> are the left and right children of node <math>t</math> using split <math>s</math>, respectively; <math>P_L</math> and <math>P_R</math> are the proportions of records in <math>t</math> in <math>t_L</math> and <math>t_R</math>, respectively; and <math>P(j\mid t_L)</math> and <math>P(j\mid t_R)</math> are the proportions of class <math>j</math> records in <math>t_L</math> and <math>t_R</math>, respectively. Consider an example data set with three attributes: ''savings''(low, medium, high), ''assets''(low, medium, high), ''income''(numerical value), and a binary target variable ''credit risk''(good, bad) and 8 data points.<ref name="ll"/> The full data is presented in the table below. To start a decision tree, we will calculate the maximum value of <math>\varphi(s\mid t)</math> using each feature to find which one will split the root node. This process will continue until all children are pure or all <math>\varphi(s\mid t)</math> values are below a set threshold. {| class="wikitable" |- ! Customer !! Savings !! Assets !! Income ($1000s) !! Credit risk |- | 1 || Medium || High || 75 || Good |- | 2 || Low || Low || 50 || Bad |- | 3 || High || Medium || 25 || Bad |- | 4 || Medium || Medium || 50 || Good |- | 5 || Low || Medium || 100 || Good |- | 6 || High || High || 25 || Good |- | 7 || Low || Low || 25 || Bad |- | 8 || Medium || Medium || 75 || Good |} To find <math>\varphi(s\mid t)</math> of the feature ''savings'', we need to note the quantity of each value. The original data contained three low's, three medium's, and two high's. Out of the low's, one had a good ''credit risk'' while out of the medium's and high's, 4 had a good ''credit risk''. Assume a candidate split <math>s</math> such that records with a low ''savings'' will be put in the left child and all other records will be put into the right child. :<math> \varphi(s\mid\text{root}) = 2\cdot\frac 3 8\cdot\frac 5 8\cdot \left(\left|\left(\frac 1 3 - \frac 4 5\right)\right| + \left|\left(\frac 2 3 - \frac 1 5\right)\right|\right) = 0.44 </math> To build the tree, the "goodness" of all candidate splits for the root node need to be calculated. The candidate with the maximum value will split the root node, and the process will continue for each impure node until the tree is complete. Compared to other metrics such as information gain, the measure of "goodness" will attempt to create a more balanced tree, leading to more-consistent decision time. However, it sacrifices some priority for creating pure children which can lead to additional splits that are not present with other metrics. ==Uses== ===Advantages=== Amongst other data mining methods, decision trees have various advantages: * '''Simple to understand and interpret.''' People are able to understand decision tree models after a brief explanation. Trees can also be displayed graphically in a way that is easy for non-experts to interpret.<ref name=":0">{{Cite book|title=An Introduction to Statistical Learning|url=https://archive.org/details/introductiontost00jame|url-access=limited|last1=Gareth|first1=James|last2=Witten|first2=Daniela|last3=Hastie|first3=Trevor|last4=Tibshirani|first4=Robert|publisher=Springer|year=2015|isbn=978-1-4614-7137-0|location=New York|pages=[https://archive.org/details/introductiontost00jame/page/n323 315]}}</ref> * '''Able to handle both numerical and [[Categorical variable|categorical]] data.'''<ref name=":0" /> Other techniques are usually specialized in analyzing datasets that have only one type of variable. (For example, relation rules can be used only with nominal variables while neural networks can be used only with numerical variables or categoricals converted to 0-1 values.) Early decision trees were only capable of handling categorical variables, but more recent versions, such as C4.5, do not have this limitation.<ref name="tdidt" /> * '''Requires little data preparation.''' Other techniques often require data normalization. Since trees can handle qualitative predictors, there is no need to create [[dummy variable (statistics)|dummy variables]].<ref name=":0" /> * '''Uses a [[white box (software engineering)|white box]] or open-box<ref name="tdidt" /> model.''' If a given situation is observable in a model the explanation for the condition is easily explained by [[Boolean logic]]. By contrast, in a [[black box]] model, the explanation for the results is typically difficult to understand, for example with an [[artificial neural network]]. * '''Possible to validate a model using statistical tests.''' That makes it possible to account for the reliability of the model. * Non-parametric approach that makes no assumptions of the training data or prediction residuals; e.g., no distributional, independence, or constant variance assumptions * '''Performs well with large datasets.''' Large amounts of data can be analyzed using standard computing resources in reasonable time. * '''Accuracy with flexible modeling'''. These methods may be applied to healthcare research with increased accuracy.<ref>{{Cite journal |last1=Hu |first1=Liangyuan |last2=Li |first2=Lihua |date=2022-12-01 |title=Using Tree-Based Machine Learning for Health Studies: Literature Review and Case Series |journal=International Journal of Environmental Research and Public Health |language=en |volume=19 |issue=23 |pages=16080 |doi=10.3390/ijerph192316080 |issn=1660-4601 |pmc=9736500 |pmid=36498153|doi-access=free }}</ref> * '''Mirrors human decision making more closely than other approaches.'''<ref name=":0" /> This could be useful when modeling human decisions/behavior. * '''Robust against co-linearity, particularly boosting.''' * '''In built''' '''[[feature selection]]'''. Additional irrelevant feature will be less used so that they can be removed on subsequent runs. The hierarchy of attributes in a decision tree reflects the importance of attributes.<ref>{{Cite book|last=Provost, Foster, 1964-|title=Data science for business : [what you need to know about data mining and data-analytic thinking]|date=2013|publisher=O'Reilly|others=Fawcett, Tom.|isbn=978-1-4493-6132-7|edition= 1st|location=Sebastopol, Calif.|oclc=844460899}}</ref> It means that the features on top are the most informative.<ref>{{Cite journal|last1=Piryonesi S. Madeh|last2=El-Diraby Tamer E.|date=2020-06-01|title=Role of Data Analytics in Infrastructure Asset Management: Overcoming Data Size and Quality Problems|journal=Journal of Transportation Engineering, Part B: Pavements|volume=146|issue=2|pages=04020022|doi=10.1061/JPEODX.0000175| s2cid=216485629 }}</ref> * '''Decision trees can approximate any [[Boolean function]] e.g. [[Exclusive or|XOR]].<ref>{{cite journal |first1=Dinesh |last1=Mehtaa |first2=Vijay |last2=Raghavan |title=Decision tree approximations of Boolean functions |journal=Theoretical Computer Science |volume=270 |issue=1β2 |year=2002 |pages=609β623 |doi=10.1016/S0304-3975(01)00011-1 |doi-access=free }}</ref>''' ===Limitations=== * Trees can be very non-robust. A small change in the [[Training, test, and validation sets|training data]] can result in a large change in the tree and consequently the final predictions.<ref name=":0" /> * The problem of learning an optimal decision tree is known to be [[NP-complete]] under several aspects of optimality and even for simple concepts.<ref>{{Cite journal | doi = 10.1016/0020-0190(76)90095-8 | last1 = Hyafil | first1 = Laurent | last2 = Rivest | first2 = RL | year = 1976 | title = Constructing Optimal Binary Decision Trees is NP-complete | journal = Information Processing Letters | volume = 5 | issue = 1| pages = 15β17 }}</ref><ref>Murthy S. (1998). [https://cs.nyu.edu/~roweis/csc2515-2006/readings/murthy_dt.pdf "Automatic construction of decision trees from data: A multidisciplinary survey"]. ''Data Mining and Knowledge Discovery''</ref> Consequently, practical decision-tree learning algorithms are based on heuristics such as the [[greedy algorithm]] where locally optimal decisions are made at each node. Such algorithms cannot guarantee to return the globally optimal decision tree. To reduce the greedy effect of local optimality, some methods such as the dual information distance (DID) tree were proposed.<ref>{{cite journal|url=http://www.eng.tau.ac.il/~bengal/DID.pdf|title=Efficient Construction of Decision Trees by the Dual Information Distance Method|author=Ben-Gal I. Dana A., Shkolnik N. and Singer|journal=Quality Technology & Quantitative Management|volume=11|issue=1|pages=133β147|year=2014|doi=10.1080/16843703.2014.11673330|s2cid=7025979|access-date=2014-02-13|archive-date=2016-06-04|archive-url=https://web.archive.org/web/20160604183738/http://www.eng.tau.ac.il/~bengal/DID.pdf|url-status=dead}}</ref> * Decision-tree learners can create over-complex trees that do not generalize well from the training data. (This is known as [[overfitting]].<ref>{{Cite book | title = Principles of Data Mining | doi = 10.1007/978-1-84628-766-4 | year = 2007 | isbn = 978-1-84628-765-7 | s2cid = 45746 }}</ref>) Mechanisms such as [[Pruning (decision trees)|pruning]] are necessary to avoid this problem (with the exception of some algorithms such as the Conditional Inference approach, that does not require pruning).<ref name="Hothorn2006" /><ref name="Strobl2009" /> * The average depth of the tree that is defined by the number of nodes or tests till classification is not guaranteed to be minimal or small under various splitting criteria.<ref name="Tris">{{cite web|author = Ben-Gal I. and Trister C. (2015)|title = Parallel Construction of Decision Trees with Consistently Non Increasing Expected Number of Tests|url = http://www.eng.tau.ac.il/~bengal/Trist.pdf|publisher = Applied Stochastic Models in Business and Industry, Vol. 31(1) 64-78|access-date = 2021-01-30|archive-date = 2021-02-05|archive-url = https://web.archive.org/web/20210205043215/http://www.eng.tau.ac.il/~bengal/Trist.pdf|url-status = dead}}</ref> * For data including categorical variables with different numbers of levels, [[information gain in decision trees]] is biased in favor of attributes with more levels.<ref>{{cite conference|author=Deng, H.|author2=Runger, G. |author3=Tuv, E. |title=Bias of importance measures for multi-valued attributes and solutions|conference=Proceedings of the 21st International Conference on Artificial Neural Networks (ICANN)|year=2011|pages= 293β300|url=https://www.researchgate.net/publication/221079908}}</ref> To counter this problem, instead of choosing the attribute with highest [[information gain]], one can choose the attribute with the highest [[information gain ratio]] among the attributes whose information gain is greater than the mean information gain.<ref>{{cite journal |doi=10.1007/BF00116251 |last=Quinlan |first=J. Ross |title=Induction of Decision Trees |journal=[[Machine Learning (journal)|Machine Learning]] |volume=1 |issue=1 |year=1986 |pages=81β106 |doi-access=free }}</ref> This biases the decision tree against considering attributes with a large number of distinct values, while not giving an unfair advantage to attributes with very low information gain. Alternatively, the issue of biased predictor selection can be avoided by the Conditional Inference approach,<ref name="Hothorn2006" /> a two-stage approach,<ref>{{Cite journal|last1=Brandmaier|first1=Andreas M.|last2=Oertzen|first2=Timo von|last3=McArdle|first3=John J.|last4=Lindenberger|first4=Ulman|title=Structural equation model trees.|journal=Psychological Methods|language=en|volume=18|issue=1|pages=71β86|doi=10.1037/a0030001|pmid=22984789|pmc=4386908|year=2012|hdl=11858/00-001M-0000-0024-EA33-9}}</ref> or adaptive leave-one-out feature selection.<ref>{{cite journal|last1=Painsky|first1=Amichai|last2=Rosset|first2=Saharon|title=Cross-Validated Variable Selection in Tree-Based Methods Improves Predictive Performance|journal=IEEE Transactions on Pattern Analysis and Machine Intelligence|date=2017|volume=39|issue=11|pages=2142β2153|pmid=28114007|doi=10.1109/TPAMI.2016.2636831|arxiv=1512.03444|s2cid=5381516}}</ref> ===Implementations=== Many data mining software packages provide implementations of one or more decision tree algorithms (e.g. random forest). Open source examples include: * [[ALGLIB]], a C++, C# and Java numerical analysis library with data analysis features (random forest) * [[KNIME]], a free and open-source data analytics, reporting and integration platform (decision trees, random forest) * [[Orange (software)|Orange]], an open-source data visualization, machine learning and data mining toolkit (random forest) * [[R (programming language)|R]] (an open-source software environment for statistical computing, which includes several CART implementations such as rpart, party and randomForest packages), * * [[scikit-learn]] (a free and open-source machine learning library for the [[Python (programming language)|Python]] programming language). * [[Weka (machine learning)|Weka]] (a free and open-source data-mining suite, contains many decision tree algorithms), Notable commercial software: * [[MATLAB]], * [[Microsoft SQL Server]], and * [[RapidMiner]], * * [[SAS (software)#Components|SAS Enterprise Miner]], * [[SPSS Modeler|IBM SPSS Modeler]], ==Extensions== ===Decision graphs=== In a decision tree, all paths from the root node to the leaf node proceed by way of conjunction, or ''AND''. In a decision graph, it is possible to use disjunctions (ORs) to join two more paths together using [[minimum message length]] (MML).<ref>{{cite web | url=http://citeseer.ist.psu.edu/oliver93decision.html | title=CiteSeerX}}</ref> Decision graphs have been further extended to allow for previously unstated new attributes to be learnt dynamically and used at different places within the graph.<ref>[http://www.csse.monash.edu.au/~dld/Publications/2003/Tan+Dowe2003_MMLDecisionGraphs.pdf Tan & Dowe (2003)]</ref> The more general coding scheme results in better predictive accuracy and log-loss probabilistic scoring.{{Citation needed|date=January 2012}} In general, decision graphs infer models with fewer leaves than decision trees. ===Alternative search methods=== Evolutionary algorithms have been used to avoid local optimal decisions and search the decision tree space with little ''a priori'' bias.<ref>{{cite book |last1=Papagelis |first1=A. |last2=Kalles |first2=D. |year=2001 |chapter=Breeding Decision Trees Using Evolutionary Techniques |title=Proceedings of the Eighteenth International Conference on Machine Learning, June 28βJuly 1, 2001 |pages=393β400 |chapter-url=http://www.gatree.com/wordpress/wp-content/uploads/2010/04/BreedinDecisioTreeUsinEvo.pdf }}</ref><ref>{{cite journal |last1=Barros |first1=Rodrigo C. |last2=Basgalupp |first2=M. P. |last3=Carvalho |first3=A. C. P. L. F. |last4=Freitas |first4=Alex A. |year=2012 |doi=10.1109/TSMCC.2011.2157494 |title=A Survey of Evolutionary Algorithms for Decision-Tree Induction |journal=IEEE Transactions on Systems, Man, and Cybernetics |series=Part C: Applications and Reviews |volume=42 |issue=3 |pages=291β312 |citeseerx=10.1.1.308.9068 |s2cid=365692 }}</ref> It is also possible for a tree to be sampled using [[Markov chain Monte Carlo|MCMC]].<ref>{{cite journal |last1=Chipman |first1=Hugh A. |first2=Edward I. |last2=George |first3=Robert E. |last3=McCulloch |title=Bayesian CART model search |journal=Journal of the American Statistical Association |volume=93 |issue=443 |year=1998 |pages=935β948 |doi=10.1080/01621459.1998.10473750 |citeseerx=10.1.1.211.5573 }}</ref> The tree can be searched for in a bottom-up fashion.<ref>{{cite book |last1=Barros |first1=R. C. |last2=Cerri |first2=R. |last3=Jaskowiak |first3=P. A. |last4=Carvalho |first4=A. C. P. L. F. |doi=10.1109/ISDA.2011.6121697 |chapter=A bottom-up oblique decision tree induction algorithm |title=Proceedings of the 11th International Conference on Intelligent Systems Design and Applications (ISDA 2011) |pages=450β456 |year=2011 |isbn=978-1-4577-1676-8 |s2cid=15574923 }}</ref> Or several trees can be constructed parallelly to reduce the expected number of tests till classification.<ref name="Tris" /> ==See also== {{Div col|colwidth=20em}} * [[Decision-tree pruning|Decision tree pruning]] * [[Binary decision diagram]] * [[CHAID]] * [[Predictive analytics#Classification and regression trees (CART)|CART]] * [[ID3 algorithm]] * [[C4.5 algorithm]] * [[Decision stump]]s, used in e.g. [[AdaBoost]]ing * [[Decision list]] * [[Incremental decision tree]] * [[Alternating decision tree]] * [[Structured data analysis (statistics)]] * [[Logistic model tree]] * [[Hierarchical clustering]]{{Div col end}} ==References== {{Reflist}} ==Further reading== * {{cite book |first1=Gareth |last1=James |first2=Daniela |last2=Witten |first3=Trevor |last3=Hastie |first4=Robert |last4=Tibshirani |chapter=Tree-Based Methods |title=An Introduction to Statistical Learning: with Applications in R |location=New York |publisher=Springer |year=2017 |isbn=978-1-4614-7137-0 |chapter-url=https://www-bcf.usc.edu/~gareth/ISL/ISLR%20Seventh%20Printing.pdf#page=317 |pages=303β336 }} ==External links== * [https://www.cs.kent.ac.uk/people/staff/mg483/code/evoldectrees/ Evolutionary Learning of Decision Trees in C++] * [http://christianherta.de/lehre/dataScience/machineLearning/decision-trees.html A very detailed explanation of information gain as splitting criterion] [[Category:Decision trees]] [[Category:Classification algorithms]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite book
(
edit
)
Template:Cite conference
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite thesis
(
edit
)
Template:Cite web
(
edit
)
Template:Diagonal split header
(
edit
)
Template:Div col
(
edit
)
Template:Div col end
(
edit
)
Template:Machine learning
(
edit
)
Template:Main
(
edit
)
Template:Mvar
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Webarchive
(
edit
)