0% found this document useful (0 votes)
633 views6 pages

Decision Tree Induction Explained

Uploaded by

sravyasri2806
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
633 views6 pages

Decision Tree Induction Explained

Uploaded by

sravyasri2806
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Decision tree induction algorithm:

A decision tree is a machine learning algorithm that creates a tree-like model of decisions and their
possible consequences. In classification, a decision tree is used to classify input data into one of
several possible classes. Here are the steps in how a decision tree works in classification in data
mining

A decision tree is a machine learning algorithm that creates a


tree-like model of decisions and their possible consequences. In
classification, a decision tree is used to classify input data into one
of several possible classes. Here are the steps in how a decision
tree works in classification in data mining:
here leaf node is assigned as class label. Here root node uses the
attributes body temperature to separate warm-blooded from cold-
blooded vertebrates.
Starting from root node , we apply the test condition to the record and
follow the

Data Preparation: The first step is to collect and prepare the


data. The data must be cleaned, pre-processed, and formatted in a
way that can be used by the decision tree algorithm.
Tree Construction: The decision tree algorithm starts by
selecting the best feature to split the data. The feature with
the highest information gain or the lowest Gini index is
selected as the root node. The data is then split into subsets based
on the values of this feature.

Recursive Partitioning: The algorithm then recursively repeats


this process for each subset, selecting the best feature to split
the data and creating new nodes for each feature. This
process is repeated until all the data has been classified into a set
of leaf nodes.
Splitting: It is a process of dividing a node into two or more sub-nodes.
Pruning: When we remove sub-nodes of a decision node, this
process is called pruning. The decision tree can be pruned to
prevent overfitting, which is when the model performs well on
the training data but poorly on the testing data.

Prediction: Once the decision tree is constructed, it can be used


to predict the target variable for new data by traversing the tree
from the root to the appropriate leaf node. At each node, the
feature value of the new data is compared to the value of the
node, and the algorithm follows the appropriate branch of the tree.
Evaluation: The final step is to evaluate the performance of the
decision tree on a testing dataset. This step is crucial to ensure
that the model can generalize well to new data and is not
overfitting to the training data.
They are also capable of handling both categorical and continuous
data and can handle missing data. However, decision trees can
overfit the training data, leading to poor performance on new data,
and they may not be suitable for complex data with many
features.
Advantages of decision tree :
 Decision trees are able to generate understandable rules.
 Decision trees perform classification without requiring much
computation.
Entropy : Entropy refers to a common way to measure impurity
in the decision tree. It measures the impurity in data set.

Information gain (gini) : It refers to the decline in entropy after


the dataset is split. It is also called as entropy reduction.
The skeleton decision tree induction algorithm also known as TreeGrowth is shown
in Algorithm 3.1 presents a pseudo code for decision tree induction algorithm. The input to
this algorithm consists of the training records E and the attribute set F. The algorithm works
by recursively selecting the best attribute to split the data (Step 7) and expanding the nodes
of the tree (Steps 11 and 12) until the stopping criterion is met (Step 1).
The details of this algorithm are explained below.
1. The createNode() : This Function extends the decision tree by creating a new node. A
node in the decision tree either has a test condition, denoted as [Link] cond, or a class
label, denoted as [Link].

2. The find_best_split() : function determines which attribute should be selected as the test
condition for splitting the training records. The choice of test condition depends on which
impurity measure is used to determine the goodness of a split. The popular measures include
entropy and the Gini index.

3. The Classify() : This Function determines the class label to be assigned to a leaf node. For
each leaf node t, let p(i|t) denote the fraction of training records from class i associated with
the node t. the leaf node is assigned to the class that has the majority number of training
records :
Algorithm 3.1 A skeleton decision tree induction algorithm.

TreeGrowth (E, F) # E= Training records and F= attribute set


1: if stopping cond(E,F) = true then # to stop or terminate the recursive condition if all records have
same class label or same attribute values
2: leaf = createNode(). # To extends the decision tree by creating a new node which is test

condition or a class label

3: leaf. Label = Classify (E). # determines the class label and assigned to a
leaf node 4: return leaf.
5: else
6: root = createNode().
7: root. Test cond = find best split(E, F). # recursively select best attribute to

9: for each v ∈ V do
split data. 8: let V = {v|v is a possible outcome of [Link] cond }.

10: Ev = {e | [Link] cond(e) = v and e ∈ E}.


11: child = TreeGrowth(Ev, F). # steps 11 and 12 to expand the nodes of tree until step
1 met 12: add child as descendent of root and label the edge (root → child) as v.
13: end for
14: end if
15: return root.

where the argmax operator returns the class i that maximizes p(i|t).

5. The stopping Cond() : Function is used to terminate the tree-growing process by testing
whether all the records have same class label or same attribute values. After building the
decision tree, a tree-pruning step can be performed to reduce the size of the decision tree.

Example for decision tree induction algorithm :


Training set, Test test and Classifier are given below:
CLASSIFIER OR
CLASSIFICATION
MODEL

Common questions

Powered by AI

Entropy in decision tree algorithms measures the impurity or disorder within a dataset. It quantifies the unpredictability of the information content. Lower entropy indicates higher purity. When splitting data, the algorithm aims to reduce entropy, thereby increasing the disorder within the resultant subsets, which is measured by information gain. Hence, a split that results in greater information gain, or reduced entropy, is considered better for classification tasks .

Decision trees offer several advantages: they generate understandable rules, perform classification without requiring much computation, and can handle both categorical and continuous data types. However, they might not be suitable for complex data sets with many features due to potential overfitting and reduced performance on new data .

Recursive partitioning in decision tree algorithms involves repeatedly splitting the dataset into subsets based on the values of selected attributes. Initially, the algorithm chooses the best feature according to an impurity measure. Then, for each resulting subset, the process is repeated: the best attribute is selected for splitting, and new nodes are created for the split. This continues until the data is classified into leaf nodes, where no further meaningful splitting can occur or a stopping condition is met .

The algorithm terminates the growth of a decision tree when a stopping condition is met. This could be when all records at a node have the same class label or attribute values, indicating no further meaningful splits can be made. The stopping condition helps prevent the tree from becoming overly complex and thus avoids potential overfitting .

The decision tree algorithm uses impurity measures like entropy and the Gini index to determine the best feature to split the data. It selects the feature with the highest information gain, which is the decline in entropy after the split, or the feature with the lowest Gini index. This process is repeated in a recursive manner for each subset created during the splitting .

The 'find_best_split()' function is critical in the decision tree induction algorithm as it determines the optimal attribute for splitting the data at each node. The function evaluates potential splits using impurity measures like entropy or the Gini index to ensure the splits increase the purity of the branches, facilitating better data classification down the tree .

The primary drawback of using unpruned decision trees is overfitting, where the tree becomes too tailored to the training data, capturing noise rather than the actual data pattern, which deteriorates performance on unseen data. Additionally, unpruned trees can become excessively complex and difficult to interpret, and their performance can be unstable with small variations in data .

Decision trees can handle categorical data straightforwardly by splitting the data based on the category values at each node. For continuous data, decision trees create binary splits based on threshold values that segment the data into two regions, thus converting continuous variables into a series of decision boundaries that facilitate classification in the tree model .

Pruning in a decision tree involves removing branches that have little utility in classifying data. The purpose of pruning is to simplify the model and reduce its size, which helps to combat overfitting. Overfitting occurs when the decision tree is too complex and captures noise in the training data, leading to poor performance on new, unseen data. By pruning irrelevant branches, the tree generalizes better to new data .

The 'createNode()' function is used to extend the decision tree by generating new nodes. A node can either embody a test condition, denoted as node.test_cond, or it is assigned a class label, indicated as node.label. Each node plays a pivotal role in segmenting the dataset into further sub-nodes or concluding with a classification label, thus expanding the structure and depth of the tree .

You might also like