Download Data mining practicals and more Study Guides, Projects, Research Data Mining in PDF only on Docsity!
Practical No. 6
Aim: Implement Decision tree with Weka
Objective: To demonstrate decision tree using J48 in Weka Theory:
A decision tree is a structure that includes a root node, branches, and leaf nodes. Each internal
node denotes a test on an attribute, each branch denotes the outcome of a test, and each leaf node
holds a class label. The topmost node in the tree is the root node.
The benefits of having a decision tree are as follows −
• It does not require any domain knowledge.
• It is easy to comprehend.
• The learning and classification steps of a decision tree are simple and fast.
Decision tree builds classification or regression models in the form of a tree structure. It breaks
down a dataset into smaller and smaller subsets while at the same time an associated decision
tree is incrementally developed. The final result is a tree with decision nodes and leaf nodes. A
decision node (e.g., Outlook) has two or more branches (e.g., Sunny, Overcast and Rainy). Leaf
node (e.g., Play) represents a classification or decision. The topmost decision node in a tree
which corresponds to the best predictor called root node. Decision trees can handle both
categorical and numerical data.
Algorithm
The core algorithm for building decision trees called ID3 by J. R. Quinlan
which employs a top-down, greedy search through the space of possible
branches with no backtracking. ID3 uses Entropy and Information Gain to
construct a decision tree. In ZeroR model there is no predictor, in OneR
model we try to find the single best predictor, naive Bayesian includes all
predictors using Bayes' rule and the independence assumptions between
predictors but decision tree includes all predictors with the dependence
assumptions between predictors.
- Create an .ARFF (Attribute Relation File Format) file and construct decision tree for the following data:
@relation height_classification @attribute roll_no numeric @attribute Gender{f,m} @attribute height numeric @attribute output {s,t,m} @data 1,f,1.6,s 2,m,2,t 3,f,1.9,m 4,f,1.88,m 5,f,1.7,s 6,m,1.85,m 7,f,1.6,s 8,m,1.7,s 9,m,,2.2,t 10,m,2.1,t 11,f,1.8,m 12,m,1.95,m 13,f,1.9,m 14,f,1.8,m 15,f,1.75,m
- Create an .ARFF (Attribute Relation File Format) file and construct decision tree for the following data:
@relation doop @attribute outlook{sunny,overcast,rainy} @attribute temperature numeric @attribute humidity numeric @attribute windy{t,f} @attribute play{no,yes} @data
sunny,85,85,?,no sunny,80,90,t,no overcast,83,86,f,yes rainy,70,96,f,yes rainy,68,80,f,yes rainy,65,70,t,no overcast,?,65,t,no sunny,72,95,f,no ?,69,70,f,? rainy,75,80,f,yes sunny,75,70,t,? overcast,72,90,t,yes overcast,81,75,f,yes rainy,71,91,t,no rainy,?,96,f,yes rainy,68,?,f,yes rainy,?,70,t,no overcast,64,65,?,yes
- For Iris Plants Database in iris.arff, construct a decision tree.
Conclusion: we have successfully Implemented Decision tree with Weka