Decision tree learning
Part of a series on |
Machine learning and data mining |
---|
Decision tree learning is a
Tree models where the target variable can take a discrete set of values are called
Decision trees are among the most popular machine learning algorithms given their intelligibility and simplicity.[2]
In decision analysis, a decision tree can be used to visually and explicitly represent decisions and
General
Decision tree learning is a method commonly used in data mining.[3] 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 features 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, 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.[4] 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)[5] is an example of a greedy algorithm, and it is by far the most common strategy for learning decision trees from data.[6]
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:
The dependent variable, , is the target variable that we are trying to understand, classify or generalize. The vector is composed of the features, etc., that are used for that task.
Decision tree types
Decision trees used in data mining are of two main types:
- Classification treeanalysis 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
Some techniques, often called ensemble methods, construct more than one decision tree:
- Bootstrap aggregated (or bagged) decision trees, an early ensemble method, builds multiple decision trees by repeatedly resampling training data with replacement, and voting the trees for a consensus prediction.[10]
- 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.[11]
A special case of a decision tree is a decision list,[12] 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], permit non-greedy learning methods[13] and monotonic constraints to be imposed.[14]
Notable decision tree algorithms include:
- ID3 (Iterative Dichotomiser 3)
- C4.5 (successor of ID3)
- CART (Classification And Regression Tree)[7]
- Chi-square automatic interaction detection (CHAID). Performs multi-level splits when computing classification trees.[15][16][17]
- 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.[18][19]
ID3 and CART were invented independently at around the same time (between 1970 and 1980)[citation needed], yet follow a similar approach for learning a decision tree from training tuples.
It has also been proposed to leverage concepts of
Metrics
Algorithms for constructing decision trees usually work top-down, by choosing a variable at each step that best splits the set of items.[6] 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.[22]
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:
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
Predicted Class Actual Class
|
Cancer | Non-cancer |
---|---|---|
Cancer | 8 | 3 |
Non-cancer | 2 | 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: . 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 that takes into account the proportions of the values from the confusion matrix to give the actual true positive rate (TPR). The difference between these metrics is shown in the example below:
Feature A Confusion Matrix
|
Feature B Confusion Matrix
| ||||||||||||||||||
|
|
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,[23] or 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 classes and relative frequencies , , the probability of choosing an item with label is , and the probability of miscategorizing that item is . The Gini impurity is computed by summing pairwise products of these probabilities for each class label:
The Gini impurity is also an information theoretic measure and corresponds to
Information gain
Used by the
Entropy is defined as below
where 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.[24]
Averaging over the possible values of ,
- Where weighted sum of entropies is given by,
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 which is measured in bits. 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".[24]
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.
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
For the node where windy=false there were eight data points, six yes's and two no's. Thus we have
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.
Now we can calculate the information gain achieved by splitting on the windy feature.
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.[24]
Information gain is also known as Shannon index in bio diversity research.
Variance reduction
Introduced in CART,[7] 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 N is defined as the total reduction of the variance of the target variable Y due to the split at this node:
where , , and 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 in the formula above with the dissimilarity between two objects and , the variance reduction criterion applies to any kind of object for which pairwise dissimilarities can be computed.[1]
Measure of "goodness"
Used by CART in 1984,[25] 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 , where is a candidate split at node , is defined as below
where and are the left and right children of node using split , respectively; and are the proportions of records in in and , respectively; and and are the proportions of class records in and , 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.[25] The full data is presented in the table below. To start a decision tree, we will calculate the maximum value of using each feature to find which one will split the root node. This process will continue until all children are pure or all values are below a set threshold.
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 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 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.
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.[26]
- Able to handle both numerical and categorical data.[26] 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.[3]
- Requires little data preparation. Other techniques often require data normalization. Since trees can handle qualitative predictors, there is no need to create dummy variables.[26]
- Uses a 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.[27]
- Mirrors human decision making more closely than other approaches.[26] 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.[28] It means that the features on top are the most informative.[29]
- Decision trees can approximate any Boolean function e.g. XOR.[30]
Limitations
- Trees can be very non-robust. A small change in the training data can result in a large change in the tree and consequently the final predictions.[26]
- The problem of learning an optimal decision tree is known to be NP-complete under several aspects of optimality and even for simple concepts.[31][32] 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.[33]
- Decision-tree learners can create over-complex trees that do not generalize well from the training data. (This is known as
- 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.[35]
- For data including categorical variables with different numbers of levels, 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.[37] 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,[18] a two-stage approach,[38] or adaptive leave-one-out feature selection.[39]
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, an open-source data visualization, machine learning and data mining toolkit (random forest)
- 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).
- Weka(a free and open-source data-mining suite, contains many decision tree algorithms),
Notable commercial software:
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).[40] 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.[41] The more general coding scheme results in better predictive accuracy and log-loss probabilistic scoring.[citation needed] 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.[42][43]
It is also possible for a tree to be sampled using MCMC.[44]
The tree can be searched for in a bottom-up fashion.[45] Or several trees can be constructed parallelly to reduce the expected number of tests till classification.[35]
See also
References
- ^ S2CID 13307797.
- S2CID 2367747.
- ^ S2CID 44697571.
- ^ Shalev-Shwartz, Shai; Ben-David, Shai (2014). "18. Decision Trees". Understanding Machine Learning. Cambridge University Press.
- S2CID 189902138.
- ^ S2CID 14808716.
- ^ ISBN 978-0-412-04841-8.
- ^ Friedman, J. H. (1999). Stochastic gradient boosting Archived 2018-11-28 at the Wayback Machine. Stanford University.
- ^ Hastie, T., Tibshirani, R., Friedman, J. H. (2001). The elements of statistical learning : Data mining, inference, and prediction. New York: Springer Verlag.
- .
- S2CID 6847493.
- S2CID 30625841.
- S2CID 17699665.
- ^ Wang, Fulton; Rudin, Cynthia (2015). "Falling Rule Lists" (PDF). Journal of Machine Learning Research. 38. Archived from the original (PDF) on 2016-01-28. Retrieved 2016-01-22.
- JSTOR 2986296.
- ISSN 0266-4763.
- ^ 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. Preprint
- ^ S2CID 6074128.
- ^ PMID 19968396.
- PMID 18255917.
- S2CID 216369273.
- ^ Najmann, Oliver (1992). Techniques and heuristics for acquiring symbolic knowledge from examples (Thesis). Doctoral thesis.
- ^ "Growing Decision Trees". MathWorks.
- ^ ISBN 978-0-12-374856-0.
- ^ ISBN 9781118874059.
- ^ ISBN 978-1-4614-7137-0.
- PMID 36498153.
- )
- S2CID 216485629.
- .
- .
- ^ Murthy S. (1998). "Automatic construction of decision trees from data: A multidisciplinary survey". Data Mining and Knowledge Discovery
- S2CID 7025979. Archived from the original(PDF) on 2016-06-04. Retrieved 2014-02-13.
- S2CID 45746.
- ^ a b Ben-Gal I. and Trister C. (2015). "Parallel Construction of Decision Trees with Consistently Non Increasing Expected Number of Tests" (PDF). Applied Stochastic Models in Business and Industry, Vol. 31(1) 64-78. Archived from the original (PDF) on 2021-02-05. Retrieved 2021-01-30.
{{cite web}}
: CS1 maint: numeric names: authors list (link) - ^ Deng, H.; Runger, G.; Tuv, E. (2011). Bias of importance measures for multi-valued attributes and solutions. Proceedings of the 21st International Conference on Artificial Neural Networks (ICANN). pp. 293–300.
- .
- PMID 22984789.
- S2CID 5381516.
- ^ "CiteSeerX".
- ^ Tan & Dowe (2003)
- ^ Papagelis, A.; Kalles, D. (2001). "Breeding Decision Trees Using Evolutionary Techniques" (PDF). Proceedings of the Eighteenth International Conference on Machine Learning, June 28–July 1, 2001. pp. 393–400.
- S2CID 365692.
- .
- S2CID 15574923.
Further reading
- James, Gareth; Witten, Daniela; Hastie, Trevor; Tibshirani, Robert (2017). "Tree-Based Methods" (PDF). An Introduction to Statistical Learning: with Applications in R. New York: Springer. pp. 303–336. ISBN 978-1-4614-7137-0.