Decision Trees Edited
Decision Trees Edited
Root Node
Branch or Sub-Tree
Splitting
Decision Node
Pruning
◼ A Decision Tree is an important data structure known to solve many computational problems
◼ Such a classification is, in fact, made by posing questions starting from the root node to each terminal
node.
Name Body Skin Gives Birth Aquatic Aerial Has Legs Hibernates Class
Temperature Cover Creature Creature
Human Warm hair yes no no yes no Mammal
Python Cold scales no no no no yes Reptile
Salmon Cold scales no yes no no no Fish
Whale Warm hair yes yes no no no Mammal
Frog Cold none no semi no yes yes Amphibian
Komodo Cold scales no no no yes no Reptile
Bat Warm hair yes no yes yes yes Mammal
Pigeon Warm feathers no no yes yes no Bird
Cat Warm fur yes no no yes no Mammal
Leopard Cold scales yes yes no no no Fish
Turtle Cold scales no semi no yes no Reptile
Penguin Warm feathers no semi no yes no Bird
Porcupine Warm quills yes no no yes yes Mammal
Eel Cold scales no yes no no no Fish
Salamander Cold none no semi no yes yes Amphibian
Vertebrate Classification
Vertebrate Classification
● The series of questions and their answers can be organized in the form of a decision tree
● As a hierarchical structure consisting of nodes and edges
Vertebrate Classification
◼ While starting the training, the whole data-set is ◼ max_depth: The maximum depth of the tree is defined
The measure of the degree of probability of a particular variable being wrongly classified when it is randomly chosen is called the
Gini index or Gini impurity. The data is equally distributed based on the Gini index.
Mathematical Formula :
When you use the Gini index as the criterion for the algorithm to select the feature for the root node.,The feature with the least Gini
index is selected.
GINI INDEX OF DIVERSITY
Definition 9.7: Gini Index of Diversity
GINI INDEX OF DIVERSITY AND CART
INFORMATION GAIN (ID3)
Entropy is the main concept of this algorithm, which helps determine a feature or attribute that gives maximum information about
a class is called Information gain or ID3 algorithm. By using this method, we can reduce the level of entropy from the root node to
the leaf node.
Mathematical Formula :
‘p’, denotes the probability of E(S), which denotes the entropy. The feature or attribute with the highest ID3 gain is used as the root
for the splitting.
ID3: DECISION TREE INDUCTION ALGORITHMS
◼ Quinlan [1986] introduced the ID3, a popular short form of Iterative Dichotomizer 3
for decision trees from a set of training data.
◼ In ID3, each node corresponds to a splitting attribute and each arc is a possible value
of that attribute.
◼ At each node, the splitting attribute is selected to be the most informative among the
attributes not yet considered in the path starting from the root.
ALGORITHM ID3
2 1 1 1 3
2 1 1 2 2
2 1 2 1 3
2 1 2 2 1
2 2 1 1 3
2 2 1 2 2
2 2 2 1 3
2 2 2 2 3
3 1 1 1 3
3 1 1 2 3
3 1 2 1 3
3 1 2 2 1
3 2 1 1 3
3 2 1 2 2
3 2 2 1 3
3 2 2 2 3
INFORMATION GAINS FOR DIFFERENT ATTRIBUTES
DECISION TREE INDUCTION : ID3 WAY
DECISION TREES
ADVANTAGES DISADVANTAGES
2. The ASM is repeated until a leaf node, or a terminal node cannot be split into sub-nodes.
BUILDING DECISION TREE
◼ In principle, there are exponentially many decision tree that can be
constructed from a given database (also called training data).
◼ Some of the tree may not be optimum
◼ Some of them may give inaccurate result
4. For each Dk ϵ D
◼ Create a node and add an edge between D and Dk with label as the Ai’s attribute value in Dk
5. For each Dk ϵ D
◼ BuildTD(Dk) // Recursive call
6. Stop
NODE SPLITTING IN BUILDDT ALGORITHM
◼ BuildDT algorithm must provides a method for expressing an attribute test condition
and corresponding outcome for different attribute type
◼ Muti-way split: Outcome depends on the number of distinct values for the corresponding attribute
Attributes:
Gender = {Male(M), Female (F)} // Binary attribute
Height = {1.5, …, 2.5} // Continuous
attribute
◼ Overfitting is a concept in data science, which occurs when a statistical model fits exactly against its training data. When this
happens, the algorithm unfortunately cannot perform accurately against unseen data, defeating its purpose. Generalization of a
model to new data is ultimately what allows us to use machine learning algorithms every day to make predictions and classify
data.
Applications of decision tree
We can therefore say that decision trees have a very crucial role in predicting the stock market.
Marketing
Businesses can use decision trees to enhance the accuracy of their promotional
campaigns by observing the performance of their competitors’ products and
services. Decision trees can help in audience segmentation and support
businesses in producing better-targeted advertisements that have higher
conversion rates. Another use of decision tree is use of demographic data to
find prospective clients. They can help streamline a marketing budget and make
informed decisions on the target market that the business is focused on. In the
absence of decision trees, the business may spend its marketing market without
a specific demographic in mind, which will affect its overall revenues.
Retention of Customers:
Companies use decision trees for customer retention through analyzing their behaviors and
releasing new offers or products to suit those behaviors. By using decision tree models,
companies can figure out the satisfaction levels of their customers as well.
Detection of Frauds:
Companies can prevent fraud by using decision trees to identify fraudulent behavior
beforehand. It can save companies a lot of resources, including time and money.
Diagnosis of Diseases and Ailments:
Decision trees can help physicians and medical professionals in identifying patients that are at a
higher risk of developing serious ( or preventable) conditions such as diabetes or dementia. The
ability of decision trees to narrow down possibilities according to specific variables is quite
helpful in such cases.