SlideShare a Scribd company logo
Unit: 3 Classification
Outline Of The Chapter
• Basics
• Decision Tree Classifier
• Rule Based Classifier
• Nearest Neighbor Classifier
• Bayesian Classifier
• Artificial Neural Network Classifier
Issues : Over-fitting, Validation, Model Comparison
Compiled By: Kamal Acharya
Supervised Learning
• Supervised learning (classification)
– Supervision: The training data (observations, measurements, etc.) are
accompanied by labels indicating the class of the observations
– New data is classified based on the training set
Apply
Model
Induction
Deduction
Learn
Model
Model
Tid Attrib1 Attrib2 Attrib3 Class
1 Yes Large 125K No
2 No Medium 100K No
3 No Small 70K No
4 Yes Medium 120K No
5 No Large 95K Yes
6 No Medium 60K No
7 Yes Large 220K No
8 No Small 85K Yes
9 No Medium 75K No
10 No Small 90K Yes
10
Tid Attrib1 Attrib2 Attrib3 Class
11 No Small 55K ?
12 Yes Medium 80K ?
13 Yes Large 110K ?
14 No Small 95K ?
15 No Large 67K ?
10
Test Set
Learning
algorithm
Training Set
Compiled By: Kamal Acharya
• Classification:
– predicts categorical class labels
– classifies data (constructs a model) based on the training set and the values
(class labels) in a classifying attribute and uses it in classifying new data
• Regression:
– models continuous-valued functions, i.e., predicts unknown or missing
values
• Typical Applications
– credit approval
– target marketing
– medical diagnosis
– treatment effectiveness analysis
Classification vs. Prediction
Compiled By: Kamal Acharya
• Credit approval
– A bank wants to classify its customers based on whether they are
expected to pay back their approved loans
– The history of past customers is used to train the classifier
– The classifier provides rules, which identify potentially reliable future
customers
– Classification rule:
• If age = “31...40” and income = high then credit_rating = excellent
– Future customers
• Paul: age = 35, income = high  excellent credit rating
• John: age = 20, income = medium  fair credit rating
Why Classification? A motivating application
Compiled By: Kamal Acharya
Classification—A Two-Step Process
• Model construction: describing a set of predetermined classes
– Each tuple/sample is assumed to belong to a predefined class, as
determined by the class label attribute
– The set of tuples used for model construction: training set
– The model is represented as classification rules, decision trees, or
mathematical formulae
Compiled By: Kamal Acharya
Classification Process (1): Model Construction: E.g.
Training
Data
NAME RANK YEARS TENURED
Mike Assistant Prof 3 no
Mary Assistant Prof 7 yes
Bill Professor 2 yes
Jim Associate Prof 7 yes
Dave Assistant Prof 6 no
Anne Associate Prof 3 no
Classification
Algorithms
IF rank = ‘professor’
OR years > 6
THEN tenured = ‘yes’
Classifier
(Model)
Compiled By: Kamal Acharya
Classification—A Two-Step Process
• Model usage: for classifying future or unknown objects
– Estimate accuracy of the model
• The known label of test samples is compared with the
classified result from the model
• Accuracy rate is the percentage of test set samples that are
correctly classified by the model
• Test set is independent of training set, otherwise over-fitting
will occur
,
casestestofnumberTotal
tionsclassificacorrectofNumber
Accuracy
Compiled By: Kamal Acharya
Classification Process (2): Use the Model in Prediction
Classifier
Testing
Data
NAME RANK YEARS TENURED
Tom Assistant Prof 2 no
Mellisa Associate Prof 7 no
George Professor 5 yes
Joseph Assistant Prof 7 yes
Unseen Data
(Jeff, Professor, 4)
Tenured?
Compiled By: Kamal Acharya
Classification by Decision Tree Induction
• Decision tree
– A flow-chart-like tree structure
– Internal node denotes a test on an attribute
– Branch represents an outcome of the test
– Leaf nodes represent class labels or class distribution
Compiled By: Kamal Acharya
Classification by Decision Tree Induction
• Decision tree generation consists of two phases
– Tree construction
• At start, all the training examples are at the root
• Partition examples recursively based on selected attributes
– Tree pruning
• Identify and remove branches that reflect noise or outliers
• Use of decision tree: Classifying an unknown sample
– Test the attribute values of the sample against the decision tree
Compiled By: Kamal Acharya
Example of a Decision Tree
ID
Home
Owner
Marital
Status
Annual
Income
Defaulted
Borrower
1 Yes Single 125K No
2 No Married 100K No
3 No Single 70K No
4 Yes Married 120K No
5 No Divorced 95K Yes
6 No Married 60K No
7 Yes Divorced 220K No
8 No Single 85K Yes
9 No Married 75K No
10 No Single 90K Yes
10
Home
Owner
MarSt
Income
YESNO
NO
NO
Yes No
MarriedSingle, Divorced
< 80K > 80K
Splitting Attributes
Training Data Model: Decision Tree
Compiled By: Kamal Acharya
Apply Model to Test Data
Home
Owner
MarSt
Income
YESNO
NO
NO
Yes No
MarriedSingle, Divorced
< 80K > 80K
Home
Owner
Marital
Status
Annual
Income
Defaulted
Borrower
No Married 80K ?
10
Test Data
Start from the root of tree.
Compiled By: Kamal Acharya
Apply Model to Test Data
MarSt
Income
YESNO
NO
NO
Yes No
MarriedSingle, Divorced
< 80K > 80K
Home
Owner
Marital
Status
Annual
Income
Defaulted
Borrower
No Married 80K ?
10
Test Data
Home
Owner
Compiled By: Kamal Acharya
Apply Model to Test Data
MarSt
Income
YESNO
NO
NO
Yes No
MarriedSingle, Divorced
< 80K > 80K
Home
Owner
Marital
Status
Annual
Income
Defaulted
Borrower
No Married 80K ?
10
Test Data
Home
Owner
Compiled By: Kamal Acharya
Apply Model to Test Data
MarSt
Income
YESNO
NO
NO
Yes No
MarriedSingle, Divorced
< 80K > 80K
Home
Owner
Marital
Status
Annual
Income
Defaulted
Borrower
No Married 80K ?
10
Test Data
Home
Owner
Compiled By: Kamal Acharya
Apply Model to Test Data
MarSt
Income
YESNO
NO
NO
Yes No
MarriedSingle, Divorced
< 80K > 80K
Home
Owner
Marital
Status
Annual
Income
Defaulted
Borrower
No Married 80K ?
10
Test Data
Home
Owner
Compiled By: Kamal Acharya
Apply Model to Test Data
MarSt
Income
YESNO
NO
NO
Yes No
MarriedSingle, Divorced
< 80K > 80K
Home
Owner
Marital
Status
Annual
Income
Defaulted
Borrower
No Married 80K ?
10
Test Data
Assign Defaulted to
“No”
Home
Owner
Compiled By: Kamal Acharya
Decision Tree Classification Task
Apply
Model
Induction
Deduction
Learn
Model
Model
Tid Attrib1 Attrib2 Attrib3 Class
1 Yes Large 125K No
2 No Medium 100K No
3 No Small 70K No
4 Yes Medium 120K No
5 No Large 95K Yes
6 No Medium 60K No
7 Yes Large 220K No
8 No Small 85K Yes
9 No Medium 75K No
10 No Small 90K Yes
10
Tid Attrib1 Attrib2 Attrib3 Class
11 No Small 55K ?
12 Yes Medium 80K ?
13 Yes Large 110K ?
14 No Small 95K ?
15 No Large 67K ?
10
Test Set
Tree
Induction
algorithm
Training Set
Decision
Tree
Compiled By: Kamal Acharya
Algorithm for Decision Tree Induction
• Basic algorithm (a greedy algorithm)
– Tree is constructed in a top-down recursive divide-and-conquer manner
– At start, all the training examples are at the root
– Attributes are categorical (if continuous-valued, they are discretized in
advance)
– Samples are partitioned recursively based on selected attributes
– Test attributes are selected on the basis of a heuristic or statistical measure
(e.g., information gain)
• Conditions for stopping partitioning
– All samples for a given node belong to the same class
– There are no remaining attributes for further partitioning – majority voting is
employed for classifying the leaf
– There are no samples left
Compiled By: Kamal Acharya
Algorithm for Decision Tree Induction (pseudocode)
Algorithm GenDecTree(Sample S, Attlist A)
1. create a node N
2. If all samples are of the same class C then label N with C; terminate;
3. If A is empty then label N with the most common class C in S (majority
voting); terminate;
4. Select aA, with the highest information gain; Label N with a;
5. For each value v of a:
a. Grow a branch from N with condition a=v;
b. Let Sv be the subset of samples in S with a=v;
c. If Sv is empty then attach a leaf labeled with the most common class in S;
d. Else attach the node generated by GenDecTree(Sv, A-a)
Compiled By: Kamal Acharya
Attribute Selection Measure: Information Gain (ID3)
 Select the attribute with the highest information gain
 Let pi be the probability that an arbitrary tuple in D (data set)
belongs to class Ci, estimated by |Ci, D|/|D|
 Expected information (entropy) needed to classify a tuple in D:
 Information needed (after using A to split D into v partitions) to
classify D:
 Information gained by branching on attribute A
)(log)( 2
1
i
m
i
i ppDInfo 

)(
||
||
)(
1
j
v
j
j
A DI
D
D
DInfo  
(D)InfoInfo(D)Gain(A) A
Compiled By: Kamal Acharya
Input: Training Dataset
age income student credit_rating buys_computer
<=30 high no fair no
<=30 high no excellent no
31…40 high no fair yes
>40 medium no fair yes
>40 low yes fair yes
>40 low yes excellent no
31…40 low yes excellent yes
<=30 medium no fair no
<=30 low yes fair yes
>40 medium yes fair yes
<=30 medium yes excellent yes
31…40 medium no excellent yes
31…40 high yes fair yes
>40 medium no excellent no
Compiled By: Kamal Acharya
Output: A Decision Tree for “buys_computer”
age?
overcast
student? credit rating?
no yes fairexcellent
<=30 >40
no noyes yes
yes
30..40
Compiled By: Kamal Acharya
Attribute Selection: Information Gain
 Class P: buys_computer = “yes”
 Class N: buys_computer = “no”
age pi ni I(pi, ni)
<=30 2 3 0.971
31…40 4 0 0
>40 3 2 0.971
694.0)2,3(
14
5
)0,4(
14
4
)3,2(
14
5
)(


I
IIDInfoage
048.0)_(
151.0)(
029.0)(



ratingcreditGain
studentGain
incomeGain
246.0)()()(  DInfoDInfoageGain age
age income student credit_rating buys_computer
<=30 high no fair no
<=30 high no excellent no
31…40 high no fair yes
>40 medium no fair yes
>40 low yes fair yes
>40 low yes excellent no
31…40 low yes excellent yes
<=30 medium no fair no
<=30 low yes fair yes
>40 medium yes fair yes
<=30 medium yes excellent yes
31…40 medium no excellent yes
31…40 high yes fair yes
>40 medium no excellent no
940.0)
14
5
(log
14
5
)
14
9
(log
14
9
)5,9()( 22  IDInfo
Compiled By: Kamal Acharya
Splitting the samples using age
income student credit_rating buys_computer
high no fair no
high no excellent no
medium no fair no
low yes fair yes
medium yes excellent yes
income student credit_rating buys_computer
high no fair yes
low yes excellent yes
medium no excellent yes
high yes fair yes
income student credit_rating buys_computer
medium no fair yes
low yes fair yes
low yes excellent no
medium yes fair yes
medium no excellent no
age?
<=30
30...40
>40
labeled yes
• Because age has the highest information gain among the attributes, it is
selected as the splitting attribute
Compiled By: Kamal Acharya
Over-fitting and Tree Pruning
• Over-fitting: An induced tree may over-fit the training data
– Good accuracy on training data but poor on test data
– Symptoms: Too many branches, some may reflect anomalies due to noise or
outliers
– Results in Poor accuracy for unseen samples
• Two approaches to avoid over-fitting
– Pre-pruning: Halt tree construction early—do not split a node if this would
result in the goodness measure(Information gain) falling below a threshold
• Difficult to choose an appropriate threshold
– Post-pruning: Remove branches from a “fully grown” tree—get a sequence of
progressively pruned trees
• Use a set of data different from the training data to decide which is the
“best pruned tree”
Compiled By: Kamal Acharya
Decision Tree Based Classification
• Advantages:
– Inexpensive to construct
– Extremely fast at classifying unknown records
– Easy to interpret for small-sized trees
– Robust to noise (especially when methods to avoid over-fitting are
employed)
– Can easily handle redundant or irrelevant attributes (unless the
attributes are interacting)
Compiled By: Kamal Acharya
Decision Tree Based Classification
• Disadvantages:
– Space of possible decision trees is exponentially large. Greedy
approaches are often unable to find the best tree.
– Does not take into account interactions between attributes
– Each decision boundary involves only a single attribute
Compiled By: Kamal Acharya
Class work
• Study the table given below and construct a decision tree
based on the greedy algorithm using information gain.
Compiled By: Kamal Acharya
Compiled By: Kamal Acharya
We build the final tree
Contd..
Home work
• Study the table given below and construct a decision tree
based on the greedy algorithm using information gain.
Compiled By: Kamal Acharya
Day Outlook Temperature Humidity Wind Play Tennis
D1 SUNNY HOT HIGH WEAK NO
D2 SUNNY HOT HIGH STRONG NO
D3 OVERCAST HOT HIGH WEAK YES
D4 RAIN MILD HIGH WEAK YES
D5 RAIN COOL NORMAL WEAK YES
D6 RAIN COOL NORMAL STRONG NO
D7 OVERCAST COOL NORMAL STRONG YES
D8 SUNNY MILD HIGH WEAK NO
D9 SUNNY COOL NORMAL WEAK YES
D10 RAIN MILD NORMAL WEAK YES
D11 SUNNY MILD NORMAL STRONG YES
D12 OVERCAST MILD HIGH STRONG YES
D13 OVERCAST HOT NORMAL WEAK YES
D14 RAIN MILD HIGH STRONG NO
Rule Based Classifier
• In Rule based classifiers learned model is represented as a set of If-Then
rules.
• A rule-based classifier uses a set of IF-THEN rules for classification.
• An IF-THEN rule is an expression of the form
– IF condition THEN conclusion.
– An example is : IF(Give Birth = no)  (Can Fly = yes) THEN Birds
• The “IF” part (or left side) of a rule is known as the rule antecedent or
precondition.
• The “THEN” part (or right side) is the rule consequent. In the rule antecedent,
the condition consists of one or more attribute tests (e.g., (Give Birth = no) 
(Can Fly = yes)) That are logically ANDed. The rule’s consequent contains a
class prediction.
Compiled By: Kamal Acharya
Contd..
• Rule-based Classifier (Example)
Compiled By: Kamal Acharya
Name Blood Type Give Birth Can Fly Live in Water Class
human warm yes no no mammals
python cold no no no reptiles
salmon cold no no yes fishes
whale warm yes no yes mammals
frog cold no no sometimes amphibians
komodo cold no no no reptiles
bat warm yes yes no mammals
pigeon warm no yes no birds
cat warm yes no no mammals
leopard shark cold yes no yes fishes
turtle cold no no sometimes reptiles
penguin warm no no sometimes birds
porcupine warm yes no no mammals
eel cold no no yes fishes
salamander cold no no sometimes amphibians
gila monster cold no no no reptiles
platypus warm no no no mammals
owl warm no yes no birds
dolphin warm yes no yes mammals
eagle warm no yes no birds
R1: (Give Birth = no)  (Can Fly = yes)  Birds
R2: (Give Birth = no)  (Live in Water = yes)  Fishes
R3: (Give Birth = yes)  (Blood Type = warm)  Mammals
R4: (Give Birth = no)  (Can Fly = no)  Reptiles
R5: (Live in Water = sometimes)  Amphibians
How does Rule-based Classifier Work?
R1: (Give Birth = no)  (Can Fly = yes)  Birds
R2: (Give Birth = no)  (Live in Water = yes)  Fishes
R3: (Give Birth = yes)  (Blood Type = warm)  Mammals
R4: (Give Birth = no)  (Can Fly = no)  Reptiles
R5: (Live in Water = sometimes)  Amphibians
A lemur triggers rule R3, so it is classified as a mammal
A turtle triggers both R4 and R5
A dogfish shark triggers none of the rules
Name Blood Type Give Birth Can Fly Live in Water Class
lemur warm yes no no ?
turtle cold no no sometimes ?
dogfish shark cold yes no yes ?
Compiled By: Kamal Acharya
Compiled By: Kamal Acharya
age?
student? credit rating?
<=30 >40
no yes yes
yes
31..40
fairexcellentyesno
• Example: Rule extraction from our buys_computer decision-tree
IF age = young AND student = no THEN buys_computer = no
IF age = young AND student = yes THEN buys_computer = yes
IF age = mid-age THEN buys_computer = yes
IF age = old AND credit_rating = excellent THEN buys_computer = yes
IF age = young AND credit_rating = fair THEN buys_computer = no
Rule Extraction from a Decision Tree
 Rules are easier to understand than large trees
 One rule is created for each path from the root to a
leaf
 Each attribute-value pair along a path forms a
conjunction: the leaf holds the class prediction
Rule Coverage and Accuracy
• A Rule R can be assessed by
its coverage and accuracy
• Coverage of a rule:
– Fraction of records that satisfy
the antecedent of a rule
• Accuracy of a rule:
– Fraction of records that satisfy
the antecedent that also satisfy
the consequent of a rule
Tid Refund Marital
Status
Taxable
Income Class
1 Yes Single 125K No
2 No Married 100K No
3 No Single 70K No
4 Yes Married 120K No
5 No Divorced 95K Yes
6 No Married 60K No
7 Yes Divorced 220K No
8 No Single 85K Yes
9 No Married 75K No
10 No Single 90K Yes
10
(Status=Single)  No
Coverage = 40%, Accuracy = 50%
Compiled By: Kamal Acharya
Contd..
• Advantages of Rule-Based Classifiers:
– As highly expressive as decision trees
– Easy to interpret
– Easy to generate
– Can classify new instances rapidly
– Performance comparable to decision trees
Compiled By: Kamal Acharya
Compiled By: Kamal Acharya
Bayesian Classification: Why?
• A statistical classifier: performs probabilistic prediction, i.e., predicts
class membership probabilities
• Foundation: Based on Bayes’ Theorem.
• Performance: A simple Bayesian classifier, naïve Bayesian classifier,
has comparable performance with decision tree and selected neural
network classifiers
• Incremental: Each training example can incrementally
increase/decrease the probability that a hypothesis is correct.
• Standard: Even when Bayesian methods are computationally
intractable, they can provide a standard of optimal decision making
against which other methods can be measured
Compiled By: Kamal Acharya
Bayesian Theorem: Basics
• Let X be a data sample (“evidence”): class label is unknown
• Let H be a hypothesis that X belongs to class C
• Classification is to determine P(H|X), the probability that the hypothesis
holds given the observed data sample X
• P(H) (prior probability), the initial probability
– E.g., X will buy computer, regardless of age, income, …
• P(X): probability that sample data is observed
• P(X|H) (posteriori probability), the probability of observing the sample
X, given that the hypothesis holds
– E.g., Given that X will buy computer, the prob. that X is 31..40,
medium income
Compiled By: Kamal Acharya
Bayesian Theorem
• Given training data X, posteriori probability of a hypothesis H,
P(H|X), follows the Bayes theorem
• Predicts X belongs to Ci iff the probability P(Ci|X) is the highest
among all the P(Ck|X) for all the k classes
)(
)()|()|(
X
XX
P
HPHPHP 
Compiled By: Kamal Acharya
Towards Naïve Bayesian Classifier
• Let D be a training set of tuples and their associated class labels,
and each tuple is represented by an n-D attribute vector X = (x1,
x2, …, xn)
• Suppose there are m classes C1, C2, …, Cm. Classification is to
derive the maximum posteriori, i.e., the maximal P(Ci|X)
• This can be derived from Bayes’ theorem
• Since P(X) is constant for all classes, only needs to be
maximized
)(
)()|(
)|(
X
X
X
P
i
CP
i
CP
i
CP 
)()|()|(
i
CP
i
CP
i
CP XX 
Compiled By: Kamal Acharya
Derivation of Naïve Bayes Classifier
• A simplified assumption:
– attributes are conditionally independent (i.e., no dependence
relation between attributes):
– This greatly reduces the computation cost: Only counts the
class distribution
)|(...)|()|(
1
)|()|(
21
CixPCixPCixP
n
k
CixPCiP
nk


X
Compiled By: Kamal Acharya
Naïve Bayesian Classifier: Training Dataset
Class:
C1:buys_computer = ‘yes’
C2:buys_computer = ‘no’
Data sample
X = (age <=30,
Income = medium,
Student = yes
Credit_rating = Fair)
age income studentcredit_ratingbuys_compu
<=30 high no fair no
<=30 high no excellent no
31…40 high no fair yes
>40 medium no fair yes
>40 low yes fair yes
>40 low yes excellent no
31…40 low yes excellent yes
<=30 medium no fair no
<=30 low yes fair yes
>40 medium yes fair yes
<=30 medium yes excellent yes
31…40 medium no excellent yes
31…40 high yes fair yes
>40 medium no excellent no
Compiled By: Kamal Acharya
Naïve Bayesian Classifier: An Example
• P(Ci): P(buys_computer = “yes”) = 9/14 = 0.643
P(buys_computer = “no”) = 5/14= 0.357
• Compute P(X|Ci) for each class
P(age = “<=30” | buys_computer = “yes”) = 2/9 = 0.222
P(age = “<= 30” | buys_computer = “no”) = 3/5 = 0.6
P(income = “medium” | buys_computer = “yes”) = 4/9 = 0.444
P(income = “medium” | buys_computer = “no”) = 2/5 = 0.4
P(student = “yes” | buys_computer = “yes) = 6/9 = 0.667
P(student = “yes” | buys_computer = “no”) = 1/5 = 0.2
P(credit_rating = “fair” | buys_computer = “yes”) = 6/9 = 0.667
P(credit_rating = “fair” | buys_computer = “no”) = 2/5 = 0.4
• X = (age <= 30 , income = medium, student = yes, credit_rating = fair)
P(X|Ci) : P(X|buys_computer = “yes”) = 0.222 x 0.444 x 0.667 x 0.667 = 0.044
P(X|buys_computer = “no”) = 0.6 x 0.4 x 0.2 x 0.4 = 0.019
P(X|Ci)*P(Ci) : P(X|buys_computer = “yes”) * P(buys_computer = “yes”) = 0.028
P(X|buys_computer = “no”) * P(buys_computer = “no”) = 0.007
Therefore, X belongs to class (“buys_computer = yes”)
Compiled By: Kamal Acharya
Avoiding the 0-Probability Problem
• Naïve Bayesian prediction requires each conditional prob. be non-zero.
Otherwise, the predicted prob. will be zero
• Ex. Suppose a dataset with 1000 tuples, income=low (0), income= medium
(990), and income = high (10),
• Use Laplacian correction
– Adding 1 to each case
Prob(income = low) = 1/1003
Prob(income = medium) = 991/1003
Prob(income = high) = 11/1003
– The “corrected” prob. estimates are close to their “uncorrected” counterparts



n
k
CixkPCiXP
1
)|()|(
Compiled By: Kamal Acharya
Naïve Bayesian Classifier: Comments
• Advantages
– Easy to implement
– Good results obtained in most of the cases
• Disadvantages
– Assumption: class conditional independence, therefore loss of
accuracy
– Practically, dependencies exist among variables
• E.g., hospitals: patients: Profile: age, family history, etc.
Symptoms: fever, cough etc., Disease: lung cancer, diabetes, etc.
• Dependencies among these cannot be modeled by Naïve Bayesian
Classifier
Naive Bayesian Classifier Example
Outlook Temperature Humidity Windy Class
sunny hot high false N
sunny hot high true N
overcast hot high false P
rain mild high false P
rain cool normal false P
rain cool normal true N
overcast cool normal true P
sunny mild high false N
sunny cool normal false P
rain mild normal false P
sunny mild normal true P
overcast mild high true P
overcast hot normal false P
rain mild high true N
play tennis?
Compiled By: Kamal Acharya
Naive Bayesian Classifier Example
Outlook Temperature Humidity Windy Class
sunny hot high false N
sunny hot high true N
rain cool normal true N
sunny mild high false N
rain mild high true N
Outlook Temperature Humidity Windy Class
overcast hot high false P
rain mild high false P
rain cool normal false P
overcast cool normal true P
sunny cool normal false P
rain mild normal false P
sunny mild normal true P
overcast mild high true P
overcast hot normal false P
9
5
Compiled By: Kamal Acharya
Naive Bayesian Classifier Example
• Given the training set, we compute the probabilities:
• We also have the probabilities
– P = 9/14
– N = 5/14
O utlook P N H um idity P N
sunny 2/9 3/5 high 3/9 4/5
overcast 4/9 0 norm al 6/9 1/5
rain 3/9 2/5
Tem preature W indy
hot 2/9 2/5 true 3/9 3/5
m ild 4/9 2/5 false 6/9 2/5
cool 3/9 1/5
Compiled By: Kamal Acharya
Naive Bayesian Classifier Example
• To classify a new sample X:
– outlook = sunny
– temperature = cool
– humidity = high
– windy = false
• Prob(P|X) = Prob(P)*Prob(sunny|P)*Prob(cool|P)*
Prob(high|P)*Prob(false|P) = 9/14*2/9*3/9*3/9*6/9 = 0.01
• Prob(N|X) = Prob(N)*Prob(sunny|N)*Prob(cool|N)*
Prob(high|N)*Prob(false|N) = 5/14*3/5*1/5*4/5*2/5 = 0.013
• Therefore X takes class label N
Compiled By: Kamal Acharya
• Second example X = <rain, hot, high, false>
• P(X|p)·P(p) =
P(rain|p)·P(hot|p)·P(high|p)·P(false|p)·P(p) = 3/9·2/9·3/9·6/9·9/14 = 0.010582
• P(X|n)·P(n) =
P(rain|n)·P(hot|n)·P(high|n)·P(false|n)·P(n) = 2/5·2/5·4/5·2/5·5/14 = 0.018286
• Sample X is classified in class N (don’t play)
Naive Bayesian Classifier Example
Compiled By: Kamal Acharya
Compiled By: Kamal Acharya
Lazy vs. Eager Learning
• Lazy vs. eager learning
– Lazy learning (e.g., instance-based learning): Simply stores training data
(or only minor processing) and waits until it is given a test tuple
– Eager learning: Given a set of training set, constructs a classification
model before receiving new (e.g., test) data to classify
• Lazy: less time in training but more time in predicting
• Accuracy
– Lazy method effectively uses a richer hypothesis space since it uses many
local linear functions to form its implicit global approximation to the
target function
– Eager: must commit to a single hypothesis that covers the entire instance
space
Compiled By: Kamal Acharya
Lazy Learner: Instance-Based Methods
• Instance-based learning:
– Store training examples and delay the processing (“lazy
evaluation”) until a new instance must be classified
– Typical approach: k-nearest neighbor approach
– Instances represented as points in a Euclidean space.
Compiled By: Kamal Acharya
The k-Nearest Neighbor Algorithm
• All instances correspond to points in the n-D space
• The nearest neighbor are defined in terms of Euclidean distance, dist(X1,
X2)
• Target function could be discrete- or real- valued
.
_
+
_ xq
+
_ _
+
_
_
+
Compiled By: Kamal Acharya
Contd…
• For discrete-valued, k-NN returns the most common value among the k
training examples nearest to xq
• k-NN for real-valued prediction for a given unknown tuple
– Returns the mean values of the k nearest neighbors
• Distance-weighted nearest neighbor algorithm
– Weight the contribution of each of the k neighbors according to their
distance to the query xq
• Give greater weight to closer neighbors 2),(
1
i
xqxd
w
Compiled By: Kamal Acharya
Contd…
• Advantages:
– Robust to noisy data by averaging k-nearest neighbors
• Disadvantages:
– Curse of dimensionality:
• distance between neighbors could be dominated by irrelevant
attributes
• To overcome it elimination of the least relevant attributes
Compiled By: Kamal Acharya
Classification by Backpropagation
• Backpropagation: A neural network learning algorithm
• Started by psychologists and neurobiologists to develop and test
computational analogues of neurons
• A neural network: A set of connected input/output units where each
connection has a weight associated with it
• During the learning phase, the network learns by adjusting the
weights so as to be able to predict the correct class label of the input
tuples
• Also referred to as connectionist learning due to the connections
between units
Compiled By: Kamal Acharya
Neural Network as a Classifier
• Weakness
– Long training time
– Require a number of parameters typically best determined empirically, e.g., the
network topology or ``structure."
– Poor interpretability: Difficult to interpret the symbolic meaning behind the learned
weights and of ``hidden units" in the network
• Strength
– High tolerance to noisy data
– Ability to classify untrained patterns
– Well-suited for continuous-valued inputs and outputs
– Successful on a wide array of real-world data
– Algorithms are inherently parallel
– Techniques have recently been developed for the extraction of rules from trained
neural networks
Compiled By: Kamal Acharya
A Neuron (= a perceptron)
• The n-dimensional input vector x is mapped into variable y by means of the scalar
product and a nonlinear function mapping
-
f
weighted
sum
Input
vector x
output y
Activation
function
weight
vector w

w0
w1
wn
x0
x1
xn
)sign(y
ExampleFor
n
0i
jii bxw  
bj
Compiled By: Kamal Acharya
A Multi-Layer Feed-Forward Neural Network
Output layer
Input layer
Hidden layer
Output vector
Input vector: X
wij
Compiled By: Kamal Acharya
How A Multi-Layer Neural Network Works?
• The inputs to the network correspond to the attributes measured for each
training tuple
• Inputs are fed simultaneously into the units making up the input layer
• They are then weighted and fed simultaneously to a hidden layer
• The number of hidden layers is arbitrary, although usually only one
• The weighted outputs of the last hidden layer are input to units making up
the output layer, which emits the network's prediction
• The network is feed-forward in that none of the weights cycles back to an
input unit or to an output unit of a previous layer
• From a statistical point of view, networks perform nonlinear regression:
Given enough hidden units and enough training samples, they can closely
approximate any function
Compiled By: Kamal Acharya
Defining a Network Topology
• First decide the network topology: # of units in the input layer, # of
hidden layers (if > 1), # of units in each hidden layer, and # of units in
the output layer
• Normalizing the input values for each attribute measured in the
training tuples to [0.0—1.0]
• One input unit per domain value, each initialized to 0
• Output, if for classification and more than two classes, one output unit
per class is used
• Once a network has been trained and its accuracy is unacceptable,
repeat the training process with a different network topology or a
different set of initial weights
Compiled By: Kamal Acharya
Backpropagation
• Iteratively process a set of training tuples & compare the network's prediction
with the actual known target value
• For each training tuple, the weights are modified to minimize the mean
squared error between the network's prediction and the actual target value
• Modifications are made in the “backwards” direction: from the output layer,
through each hidden layer down to the first hidden layer, hence
“backpropagation”
• Steps
– Initialize weights (to small random #s) and biases in the network
– Propagate the inputs forward (by applying activation function)
– Backpropagate the error (by updating weights and biases)
– Terminating condition (when error is very small, etc.)
Issues regarding classification and prediction (1):
Data Preparation
• Data cleaning
– Preprocess data in order to reduce noise and handle missing values
• Relevance analysis (feature selection)
– Remove the irrelevant or redundant attributes
• Data transformation
– Generalize and/or normalize data
• numerical attribute income  categorical {low, medium, high}
• normalize all numerical attributes to [0,1)
Compiled By: Kamal Acharya
Issues regarding classification and prediction (2):
Evaluating Classification Methods
• accuracy
• Speed
– time to construct the model
– time to use the model
• Robustness
– handling noise and missing values
• Scalability
– efficiency in disk-resident databases
• Interpretability:
– understanding and insight provided by the model
• Goodness of rules (quality)
– decision tree size
– compactness of classification rules
Compiled By: Kamal Acharya
Compiled By: Kamal Acharya
Evaluation methods
• Holdout Method: The available data set D is divided into two
disjoint subsets,
– the training set Dtrain (for learning a model)
– the test set Dtest (for testing the model)
• Important: training set should not be used in testing and the
test set should not be used in learning.
– Unseen test set provides a unbiased estimate of accuracy.
• The test set is also called the holdout set. (the examples in the
original data set D are all labeled with classes.)
• This method is mainly used when the data set D is large.
Compiled By: Kamal Acharya
Evaluation methods (cont…)
• k-fold cross-validation: The available data is partitioned
into k equal-size disjoint subsets.
• Use each subset as the test set and combine the rest n-1
subsets as the training set to learn a classifier.
• The procedure is run k times, which give k accuracies.
• The final estimated accuracy of learning is the average of
the k accuracies.
• 10-fold and 5-fold cross-validations are commonly used.
• This method is used when the available data is not large.
Compiled By: Kamal Acharya
Evaluation methods (cont…)
• Leave-one-out cross-validation: This method is used when
the data set is very small.
• It is a special case of cross-validation
• Each fold of the cross validation has only a single test
example and all the rest of the data is used in training.
• If the original data has m examples, this is m-fold cross-
validation
Compiled By: Kamal Acharya
Evaluation methods (cont…)
• Validation set: the available data is divided into three subsets,
– a training set,
– a test set and
– a validation set
• A validation set is used frequently for estimating parameters in
learning algorithms.
• In such cases, the values that give the best accuracy on the
validation set are used as the final parameter values.
• Cross-validation can be used for parameter estimating as well.
Home Work
• What is supervised classification? In what situations can this technique be
useful?
• Briefly outline the major steps of decision tree classification.
• Why naïve Bayesian classification called naïve? Briefly outline the major idea
of naïve Bayesian classification.
• Compare the advantages and disadvantages of eager classification versus lazy
classification.
• Write an algorithm for k-nearest- neighbor classification given k, the nearest
number of neighbors, and n, the number of attributes describing each tuple.
Compiled By: Kamal Acharya
Thank You !
Compiled By: Kamal Acharya

More Related Content

PPTX
Classification in data mining
Sulman Ahmed
 
PPTX
Decision Tree Learning
Md. Ariful Hoque
 
PPTX
Decision tree
shivani saluja
 
PPT
2.4 rule based classification
Krish_ver2
 
PPTX
Decision tree
ShraddhaPandey45
 
PPT
Classification (ML).ppt
rajasamal1999
 
PPSX
Decision tree Using c4.5 Algorithm
Mohd. Noor Abdul Hamid
 
PPT
2.2 decision tree
Krish_ver2
 
Classification in data mining
Sulman Ahmed
 
Decision Tree Learning
Md. Ariful Hoque
 
Decision tree
shivani saluja
 
2.4 rule based classification
Krish_ver2
 
Decision tree
ShraddhaPandey45
 
Classification (ML).ppt
rajasamal1999
 
Decision tree Using c4.5 Algorithm
Mohd. Noor Abdul Hamid
 
2.2 decision tree
Krish_ver2
 

What's hot (20)

PDF
Bayes Belief Networks
Sai Kumar Kodam
 
PPT
2.3 bayesian classification
Krish_ver2
 
PPTX
Unsupervised learning
amalalhait
 
PPTX
Feature selection
dkpawar
 
PPTX
Data mining: Classification and prediction
DataminingTools Inc
 
PPTX
Naive bayes
Ashraf Uddin
 
PDF
Data preprocessing using Machine Learning
Gopal Sakarkar
 
PPTX
Unsupervised learning (clustering)
Pravinkumar Landge
 
PPTX
Decision trees
Jagjit Wilku
 
PPTX
lazy learners and other classication methods
rajshreemuthiah
 
PPT
01 Data Mining: Concepts and Techniques, 2nd ed.
Institute of Technology Telkom
 
PDF
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Marina Santini
 
PPTX
04 Classification in Data Mining
Valerii Klymchuk
 
PPTX
Clustering for Stream and Parallelism (DATA ANALYTICS)
DheerajPachauri
 
PPTX
Naive Bayes
Abdullah al Mamun
 
PPTX
Naïve Bayes Classifier Algorithm.pptx
Shubham Jaybhaye
 
PPTX
Unsupervised learning clustering
Arshad Farhad
 
PDF
The fundamentals of Machine Learning
Hichem Felouat
 
PPT
Data Mining: Concepts and Techniques — Chapter 2 —
Salah Amean
 
Bayes Belief Networks
Sai Kumar Kodam
 
2.3 bayesian classification
Krish_ver2
 
Unsupervised learning
amalalhait
 
Feature selection
dkpawar
 
Data mining: Classification and prediction
DataminingTools Inc
 
Naive bayes
Ashraf Uddin
 
Data preprocessing using Machine Learning
Gopal Sakarkar
 
Unsupervised learning (clustering)
Pravinkumar Landge
 
Decision trees
Jagjit Wilku
 
lazy learners and other classication methods
rajshreemuthiah
 
01 Data Mining: Concepts and Techniques, 2nd ed.
Institute of Technology Telkom
 
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Marina Santini
 
04 Classification in Data Mining
Valerii Klymchuk
 
Clustering for Stream and Parallelism (DATA ANALYTICS)
DheerajPachauri
 
Naive Bayes
Abdullah al Mamun
 
Naïve Bayes Classifier Algorithm.pptx
Shubham Jaybhaye
 
Unsupervised learning clustering
Arshad Farhad
 
The fundamentals of Machine Learning
Hichem Felouat
 
Data Mining: Concepts and Techniques — Chapter 2 —
Salah Amean
 
Ad

Similar to Classification techniques in data mining (20)

PDF
BIM Data Mining Unit3 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
PPT
Data Mining
IIIT ALLAHABAD
 
PDF
classification in data mining and data warehousing.pdf
321106410027
 
PPT
Unit 3classification
Kalpna Saharan
 
PPT
classification in data warehouse and mining
anjanasharma77573
 
PPTX
Lect9 Decision tree
hktripathy
 
PPT
Dm bs-lec7-classification - dti
ammarhaiderengr
 
PPTX
unit classification.pptx
ssuser908de6
 
PPTX
Chapter4-ML.pptx slide for concept of mechanic learning
Hina636704
 
PPT
Slide3.ppt
butest
 
PPTX
DecisionTree.pptx for btech cse student
MaushamkumarRay
 
PPT
Unit-4 classification
LokarchanaD
 
PPTX
NN Classififcation Neural Network NN.pptx
cmpt cmpt
 
PPT
Classification
Ankita Kadu
 
PPTX
Dataming-chapter-7-Classification-Basic.pptx
HimanshuSharma997566
 
PPT
08 classbasic
engrasi
 
PPT
08 classbasic
ritumysterious1
 
PPT
Data Mining Concepts and Techniques.ppt
Rvishnupriya2
 
PPT
Data Mining Concepts and Techniques.ppt
Rvishnupriya2
 
PDF
Lecture 5 Decision tree.pdf
ssuser4c50a9
 
BIM Data Mining Unit3 by Tekendra Nath Yogi
Tekendra Nath Yogi
 
Data Mining
IIIT ALLAHABAD
 
classification in data mining and data warehousing.pdf
321106410027
 
Unit 3classification
Kalpna Saharan
 
classification in data warehouse and mining
anjanasharma77573
 
Lect9 Decision tree
hktripathy
 
Dm bs-lec7-classification - dti
ammarhaiderengr
 
unit classification.pptx
ssuser908de6
 
Chapter4-ML.pptx slide for concept of mechanic learning
Hina636704
 
Slide3.ppt
butest
 
DecisionTree.pptx for btech cse student
MaushamkumarRay
 
Unit-4 classification
LokarchanaD
 
NN Classififcation Neural Network NN.pptx
cmpt cmpt
 
Classification
Ankita Kadu
 
Dataming-chapter-7-Classification-Basic.pptx
HimanshuSharma997566
 
08 classbasic
engrasi
 
08 classbasic
ritumysterious1
 
Data Mining Concepts and Techniques.ppt
Rvishnupriya2
 
Data Mining Concepts and Techniques.ppt
Rvishnupriya2
 
Lecture 5 Decision tree.pdf
ssuser4c50a9
 
Ad

More from Kamal Acharya (20)

PPTX
Programming the basic computer
Kamal Acharya
 
PPTX
Computer Arithmetic
Kamal Acharya
 
PPTX
Introduction to Computer Security
Kamal Acharya
 
PPTX
Session and Cookies
Kamal Acharya
 
PPTX
Functions in php
Kamal Acharya
 
PPTX
Web forms in php
Kamal Acharya
 
PPTX
Making decision and repeating in PHP
Kamal Acharya
 
PPTX
Working with arrays in php
Kamal Acharya
 
PPTX
Text and Numbers (Data Types)in PHP
Kamal Acharya
 
PPTX
Introduction to PHP
Kamal Acharya
 
PPTX
Capacity Planning of Data Warehousing
Kamal Acharya
 
PPTX
Data Warehousing
Kamal Acharya
 
PPTX
Search Engines
Kamal Acharya
 
PPTX
Web Mining
Kamal Acharya
 
PPTX
Information Privacy and Data Mining
Kamal Acharya
 
PPTX
Cluster Analysis
Kamal Acharya
 
PPTX
Association Analysis in Data Mining
Kamal Acharya
 
PPTX
Data Preprocessing
Kamal Acharya
 
PPTX
Introduction to Data Mining and Data Warehousing
Kamal Acharya
 
PPTX
Functions in Python
Kamal Acharya
 
Programming the basic computer
Kamal Acharya
 
Computer Arithmetic
Kamal Acharya
 
Introduction to Computer Security
Kamal Acharya
 
Session and Cookies
Kamal Acharya
 
Functions in php
Kamal Acharya
 
Web forms in php
Kamal Acharya
 
Making decision and repeating in PHP
Kamal Acharya
 
Working with arrays in php
Kamal Acharya
 
Text and Numbers (Data Types)in PHP
Kamal Acharya
 
Introduction to PHP
Kamal Acharya
 
Capacity Planning of Data Warehousing
Kamal Acharya
 
Data Warehousing
Kamal Acharya
 
Search Engines
Kamal Acharya
 
Web Mining
Kamal Acharya
 
Information Privacy and Data Mining
Kamal Acharya
 
Cluster Analysis
Kamal Acharya
 
Association Analysis in Data Mining
Kamal Acharya
 
Data Preprocessing
Kamal Acharya
 
Introduction to Data Mining and Data Warehousing
Kamal Acharya
 
Functions in Python
Kamal Acharya
 

Recently uploaded (20)

PPTX
Strengthening open access through collaboration: building connections with OP...
Jisc
 
PDF
5.Universal-Franchise-and-Indias-Electoral-System.pdfppt/pdf/8th class social...
Sandeep Swamy
 
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
mansk2
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PPTX
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
TumwineRobert
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 
Strengthening open access through collaboration: building connections with OP...
Jisc
 
5.Universal-Franchise-and-Indias-Electoral-System.pdfppt/pdf/8th class social...
Sandeep Swamy
 
Week 4 Term 3 Study Techniques revisited.pptx
mansk2
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
Cardiovascular Pharmacology for pharmacy students.pptx
TumwineRobert
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Software Engineering BSC DS UNIT 1 .pptx
Dr. Pallawi Bulakh
 

Classification techniques in data mining

  • 2. Outline Of The Chapter • Basics • Decision Tree Classifier • Rule Based Classifier • Nearest Neighbor Classifier • Bayesian Classifier • Artificial Neural Network Classifier Issues : Over-fitting, Validation, Model Comparison Compiled By: Kamal Acharya
  • 3. Supervised Learning • Supervised learning (classification) – Supervision: The training data (observations, measurements, etc.) are accompanied by labels indicating the class of the observations – New data is classified based on the training set Apply Model Induction Deduction Learn Model Model Tid Attrib1 Attrib2 Attrib3 Class 1 Yes Large 125K No 2 No Medium 100K No 3 No Small 70K No 4 Yes Medium 120K No 5 No Large 95K Yes 6 No Medium 60K No 7 Yes Large 220K No 8 No Small 85K Yes 9 No Medium 75K No 10 No Small 90K Yes 10 Tid Attrib1 Attrib2 Attrib3 Class 11 No Small 55K ? 12 Yes Medium 80K ? 13 Yes Large 110K ? 14 No Small 95K ? 15 No Large 67K ? 10 Test Set Learning algorithm Training Set Compiled By: Kamal Acharya
  • 4. • Classification: – predicts categorical class labels – classifies data (constructs a model) based on the training set and the values (class labels) in a classifying attribute and uses it in classifying new data • Regression: – models continuous-valued functions, i.e., predicts unknown or missing values • Typical Applications – credit approval – target marketing – medical diagnosis – treatment effectiveness analysis Classification vs. Prediction Compiled By: Kamal Acharya
  • 5. • Credit approval – A bank wants to classify its customers based on whether they are expected to pay back their approved loans – The history of past customers is used to train the classifier – The classifier provides rules, which identify potentially reliable future customers – Classification rule: • If age = “31...40” and income = high then credit_rating = excellent – Future customers • Paul: age = 35, income = high  excellent credit rating • John: age = 20, income = medium  fair credit rating Why Classification? A motivating application Compiled By: Kamal Acharya
  • 6. Classification—A Two-Step Process • Model construction: describing a set of predetermined classes – Each tuple/sample is assumed to belong to a predefined class, as determined by the class label attribute – The set of tuples used for model construction: training set – The model is represented as classification rules, decision trees, or mathematical formulae Compiled By: Kamal Acharya
  • 7. Classification Process (1): Model Construction: E.g. Training Data NAME RANK YEARS TENURED Mike Assistant Prof 3 no Mary Assistant Prof 7 yes Bill Professor 2 yes Jim Associate Prof 7 yes Dave Assistant Prof 6 no Anne Associate Prof 3 no Classification Algorithms IF rank = ‘professor’ OR years > 6 THEN tenured = ‘yes’ Classifier (Model) Compiled By: Kamal Acharya
  • 8. Classification—A Two-Step Process • Model usage: for classifying future or unknown objects – Estimate accuracy of the model • The known label of test samples is compared with the classified result from the model • Accuracy rate is the percentage of test set samples that are correctly classified by the model • Test set is independent of training set, otherwise over-fitting will occur , casestestofnumberTotal tionsclassificacorrectofNumber Accuracy Compiled By: Kamal Acharya
  • 9. Classification Process (2): Use the Model in Prediction Classifier Testing Data NAME RANK YEARS TENURED Tom Assistant Prof 2 no Mellisa Associate Prof 7 no George Professor 5 yes Joseph Assistant Prof 7 yes Unseen Data (Jeff, Professor, 4) Tenured? Compiled By: Kamal Acharya
  • 10. Classification by Decision Tree Induction • Decision tree – A flow-chart-like tree structure – Internal node denotes a test on an attribute – Branch represents an outcome of the test – Leaf nodes represent class labels or class distribution Compiled By: Kamal Acharya
  • 11. Classification by Decision Tree Induction • Decision tree generation consists of two phases – Tree construction • At start, all the training examples are at the root • Partition examples recursively based on selected attributes – Tree pruning • Identify and remove branches that reflect noise or outliers • Use of decision tree: Classifying an unknown sample – Test the attribute values of the sample against the decision tree Compiled By: Kamal Acharya
  • 12. Example of a Decision Tree ID Home Owner Marital Status Annual Income Defaulted Borrower 1 Yes Single 125K No 2 No Married 100K No 3 No Single 70K No 4 Yes Married 120K No 5 No Divorced 95K Yes 6 No Married 60K No 7 Yes Divorced 220K No 8 No Single 85K Yes 9 No Married 75K No 10 No Single 90K Yes 10 Home Owner MarSt Income YESNO NO NO Yes No MarriedSingle, Divorced < 80K > 80K Splitting Attributes Training Data Model: Decision Tree Compiled By: Kamal Acharya
  • 13. Apply Model to Test Data Home Owner MarSt Income YESNO NO NO Yes No MarriedSingle, Divorced < 80K > 80K Home Owner Marital Status Annual Income Defaulted Borrower No Married 80K ? 10 Test Data Start from the root of tree. Compiled By: Kamal Acharya
  • 14. Apply Model to Test Data MarSt Income YESNO NO NO Yes No MarriedSingle, Divorced < 80K > 80K Home Owner Marital Status Annual Income Defaulted Borrower No Married 80K ? 10 Test Data Home Owner Compiled By: Kamal Acharya
  • 15. Apply Model to Test Data MarSt Income YESNO NO NO Yes No MarriedSingle, Divorced < 80K > 80K Home Owner Marital Status Annual Income Defaulted Borrower No Married 80K ? 10 Test Data Home Owner Compiled By: Kamal Acharya
  • 16. Apply Model to Test Data MarSt Income YESNO NO NO Yes No MarriedSingle, Divorced < 80K > 80K Home Owner Marital Status Annual Income Defaulted Borrower No Married 80K ? 10 Test Data Home Owner Compiled By: Kamal Acharya
  • 17. Apply Model to Test Data MarSt Income YESNO NO NO Yes No MarriedSingle, Divorced < 80K > 80K Home Owner Marital Status Annual Income Defaulted Borrower No Married 80K ? 10 Test Data Home Owner Compiled By: Kamal Acharya
  • 18. Apply Model to Test Data MarSt Income YESNO NO NO Yes No MarriedSingle, Divorced < 80K > 80K Home Owner Marital Status Annual Income Defaulted Borrower No Married 80K ? 10 Test Data Assign Defaulted to “No” Home Owner Compiled By: Kamal Acharya
  • 19. Decision Tree Classification Task Apply Model Induction Deduction Learn Model Model Tid Attrib1 Attrib2 Attrib3 Class 1 Yes Large 125K No 2 No Medium 100K No 3 No Small 70K No 4 Yes Medium 120K No 5 No Large 95K Yes 6 No Medium 60K No 7 Yes Large 220K No 8 No Small 85K Yes 9 No Medium 75K No 10 No Small 90K Yes 10 Tid Attrib1 Attrib2 Attrib3 Class 11 No Small 55K ? 12 Yes Medium 80K ? 13 Yes Large 110K ? 14 No Small 95K ? 15 No Large 67K ? 10 Test Set Tree Induction algorithm Training Set Decision Tree Compiled By: Kamal Acharya
  • 20. Algorithm for Decision Tree Induction • Basic algorithm (a greedy algorithm) – Tree is constructed in a top-down recursive divide-and-conquer manner – At start, all the training examples are at the root – Attributes are categorical (if continuous-valued, they are discretized in advance) – Samples are partitioned recursively based on selected attributes – Test attributes are selected on the basis of a heuristic or statistical measure (e.g., information gain) • Conditions for stopping partitioning – All samples for a given node belong to the same class – There are no remaining attributes for further partitioning – majority voting is employed for classifying the leaf – There are no samples left Compiled By: Kamal Acharya
  • 21. Algorithm for Decision Tree Induction (pseudocode) Algorithm GenDecTree(Sample S, Attlist A) 1. create a node N 2. If all samples are of the same class C then label N with C; terminate; 3. If A is empty then label N with the most common class C in S (majority voting); terminate; 4. Select aA, with the highest information gain; Label N with a; 5. For each value v of a: a. Grow a branch from N with condition a=v; b. Let Sv be the subset of samples in S with a=v; c. If Sv is empty then attach a leaf labeled with the most common class in S; d. Else attach the node generated by GenDecTree(Sv, A-a) Compiled By: Kamal Acharya
  • 22. Attribute Selection Measure: Information Gain (ID3)  Select the attribute with the highest information gain  Let pi be the probability that an arbitrary tuple in D (data set) belongs to class Ci, estimated by |Ci, D|/|D|  Expected information (entropy) needed to classify a tuple in D:  Information needed (after using A to split D into v partitions) to classify D:  Information gained by branching on attribute A )(log)( 2 1 i m i i ppDInfo   )( || || )( 1 j v j j A DI D D DInfo   (D)InfoInfo(D)Gain(A) A Compiled By: Kamal Acharya
  • 23. Input: Training Dataset age income student credit_rating buys_computer <=30 high no fair no <=30 high no excellent no 31…40 high no fair yes >40 medium no fair yes >40 low yes fair yes >40 low yes excellent no 31…40 low yes excellent yes <=30 medium no fair no <=30 low yes fair yes >40 medium yes fair yes <=30 medium yes excellent yes 31…40 medium no excellent yes 31…40 high yes fair yes >40 medium no excellent no Compiled By: Kamal Acharya
  • 24. Output: A Decision Tree for “buys_computer” age? overcast student? credit rating? no yes fairexcellent <=30 >40 no noyes yes yes 30..40 Compiled By: Kamal Acharya
  • 25. Attribute Selection: Information Gain  Class P: buys_computer = “yes”  Class N: buys_computer = “no” age pi ni I(pi, ni) <=30 2 3 0.971 31…40 4 0 0 >40 3 2 0.971 694.0)2,3( 14 5 )0,4( 14 4 )3,2( 14 5 )(   I IIDInfoage 048.0)_( 151.0)( 029.0)(    ratingcreditGain studentGain incomeGain 246.0)()()(  DInfoDInfoageGain age age income student credit_rating buys_computer <=30 high no fair no <=30 high no excellent no 31…40 high no fair yes >40 medium no fair yes >40 low yes fair yes >40 low yes excellent no 31…40 low yes excellent yes <=30 medium no fair no <=30 low yes fair yes >40 medium yes fair yes <=30 medium yes excellent yes 31…40 medium no excellent yes 31…40 high yes fair yes >40 medium no excellent no 940.0) 14 5 (log 14 5 ) 14 9 (log 14 9 )5,9()( 22  IDInfo Compiled By: Kamal Acharya
  • 26. Splitting the samples using age income student credit_rating buys_computer high no fair no high no excellent no medium no fair no low yes fair yes medium yes excellent yes income student credit_rating buys_computer high no fair yes low yes excellent yes medium no excellent yes high yes fair yes income student credit_rating buys_computer medium no fair yes low yes fair yes low yes excellent no medium yes fair yes medium no excellent no age? <=30 30...40 >40 labeled yes • Because age has the highest information gain among the attributes, it is selected as the splitting attribute Compiled By: Kamal Acharya
  • 27. Over-fitting and Tree Pruning • Over-fitting: An induced tree may over-fit the training data – Good accuracy on training data but poor on test data – Symptoms: Too many branches, some may reflect anomalies due to noise or outliers – Results in Poor accuracy for unseen samples • Two approaches to avoid over-fitting – Pre-pruning: Halt tree construction early—do not split a node if this would result in the goodness measure(Information gain) falling below a threshold • Difficult to choose an appropriate threshold – Post-pruning: Remove branches from a “fully grown” tree—get a sequence of progressively pruned trees • Use a set of data different from the training data to decide which is the “best pruned tree” Compiled By: Kamal Acharya
  • 28. Decision Tree Based Classification • Advantages: – Inexpensive to construct – Extremely fast at classifying unknown records – Easy to interpret for small-sized trees – Robust to noise (especially when methods to avoid over-fitting are employed) – Can easily handle redundant or irrelevant attributes (unless the attributes are interacting) Compiled By: Kamal Acharya
  • 29. Decision Tree Based Classification • Disadvantages: – Space of possible decision trees is exponentially large. Greedy approaches are often unable to find the best tree. – Does not take into account interactions between attributes – Each decision boundary involves only a single attribute Compiled By: Kamal Acharya
  • 30. Class work • Study the table given below and construct a decision tree based on the greedy algorithm using information gain. Compiled By: Kamal Acharya
  • 31. Compiled By: Kamal Acharya We build the final tree Contd..
  • 32. Home work • Study the table given below and construct a decision tree based on the greedy algorithm using information gain. Compiled By: Kamal Acharya Day Outlook Temperature Humidity Wind Play Tennis D1 SUNNY HOT HIGH WEAK NO D2 SUNNY HOT HIGH STRONG NO D3 OVERCAST HOT HIGH WEAK YES D4 RAIN MILD HIGH WEAK YES D5 RAIN COOL NORMAL WEAK YES D6 RAIN COOL NORMAL STRONG NO D7 OVERCAST COOL NORMAL STRONG YES D8 SUNNY MILD HIGH WEAK NO D9 SUNNY COOL NORMAL WEAK YES D10 RAIN MILD NORMAL WEAK YES D11 SUNNY MILD NORMAL STRONG YES D12 OVERCAST MILD HIGH STRONG YES D13 OVERCAST HOT NORMAL WEAK YES D14 RAIN MILD HIGH STRONG NO
  • 33. Rule Based Classifier • In Rule based classifiers learned model is represented as a set of If-Then rules. • A rule-based classifier uses a set of IF-THEN rules for classification. • An IF-THEN rule is an expression of the form – IF condition THEN conclusion. – An example is : IF(Give Birth = no)  (Can Fly = yes) THEN Birds • The “IF” part (or left side) of a rule is known as the rule antecedent or precondition. • The “THEN” part (or right side) is the rule consequent. In the rule antecedent, the condition consists of one or more attribute tests (e.g., (Give Birth = no)  (Can Fly = yes)) That are logically ANDed. The rule’s consequent contains a class prediction. Compiled By: Kamal Acharya
  • 34. Contd.. • Rule-based Classifier (Example) Compiled By: Kamal Acharya Name Blood Type Give Birth Can Fly Live in Water Class human warm yes no no mammals python cold no no no reptiles salmon cold no no yes fishes whale warm yes no yes mammals frog cold no no sometimes amphibians komodo cold no no no reptiles bat warm yes yes no mammals pigeon warm no yes no birds cat warm yes no no mammals leopard shark cold yes no yes fishes turtle cold no no sometimes reptiles penguin warm no no sometimes birds porcupine warm yes no no mammals eel cold no no yes fishes salamander cold no no sometimes amphibians gila monster cold no no no reptiles platypus warm no no no mammals owl warm no yes no birds dolphin warm yes no yes mammals eagle warm no yes no birds R1: (Give Birth = no)  (Can Fly = yes)  Birds R2: (Give Birth = no)  (Live in Water = yes)  Fishes R3: (Give Birth = yes)  (Blood Type = warm)  Mammals R4: (Give Birth = no)  (Can Fly = no)  Reptiles R5: (Live in Water = sometimes)  Amphibians
  • 35. How does Rule-based Classifier Work? R1: (Give Birth = no)  (Can Fly = yes)  Birds R2: (Give Birth = no)  (Live in Water = yes)  Fishes R3: (Give Birth = yes)  (Blood Type = warm)  Mammals R4: (Give Birth = no)  (Can Fly = no)  Reptiles R5: (Live in Water = sometimes)  Amphibians A lemur triggers rule R3, so it is classified as a mammal A turtle triggers both R4 and R5 A dogfish shark triggers none of the rules Name Blood Type Give Birth Can Fly Live in Water Class lemur warm yes no no ? turtle cold no no sometimes ? dogfish shark cold yes no yes ? Compiled By: Kamal Acharya
  • 36. Compiled By: Kamal Acharya age? student? credit rating? <=30 >40 no yes yes yes 31..40 fairexcellentyesno • Example: Rule extraction from our buys_computer decision-tree IF age = young AND student = no THEN buys_computer = no IF age = young AND student = yes THEN buys_computer = yes IF age = mid-age THEN buys_computer = yes IF age = old AND credit_rating = excellent THEN buys_computer = yes IF age = young AND credit_rating = fair THEN buys_computer = no Rule Extraction from a Decision Tree  Rules are easier to understand than large trees  One rule is created for each path from the root to a leaf  Each attribute-value pair along a path forms a conjunction: the leaf holds the class prediction
  • 37. Rule Coverage and Accuracy • A Rule R can be assessed by its coverage and accuracy • Coverage of a rule: – Fraction of records that satisfy the antecedent of a rule • Accuracy of a rule: – Fraction of records that satisfy the antecedent that also satisfy the consequent of a rule Tid Refund Marital Status Taxable Income Class 1 Yes Single 125K No 2 No Married 100K No 3 No Single 70K No 4 Yes Married 120K No 5 No Divorced 95K Yes 6 No Married 60K No 7 Yes Divorced 220K No 8 No Single 85K Yes 9 No Married 75K No 10 No Single 90K Yes 10 (Status=Single)  No Coverage = 40%, Accuracy = 50% Compiled By: Kamal Acharya
  • 38. Contd.. • Advantages of Rule-Based Classifiers: – As highly expressive as decision trees – Easy to interpret – Easy to generate – Can classify new instances rapidly – Performance comparable to decision trees Compiled By: Kamal Acharya
  • 39. Compiled By: Kamal Acharya Bayesian Classification: Why? • A statistical classifier: performs probabilistic prediction, i.e., predicts class membership probabilities • Foundation: Based on Bayes’ Theorem. • Performance: A simple Bayesian classifier, naïve Bayesian classifier, has comparable performance with decision tree and selected neural network classifiers • Incremental: Each training example can incrementally increase/decrease the probability that a hypothesis is correct. • Standard: Even when Bayesian methods are computationally intractable, they can provide a standard of optimal decision making against which other methods can be measured
  • 40. Compiled By: Kamal Acharya Bayesian Theorem: Basics • Let X be a data sample (“evidence”): class label is unknown • Let H be a hypothesis that X belongs to class C • Classification is to determine P(H|X), the probability that the hypothesis holds given the observed data sample X • P(H) (prior probability), the initial probability – E.g., X will buy computer, regardless of age, income, … • P(X): probability that sample data is observed • P(X|H) (posteriori probability), the probability of observing the sample X, given that the hypothesis holds – E.g., Given that X will buy computer, the prob. that X is 31..40, medium income
  • 41. Compiled By: Kamal Acharya Bayesian Theorem • Given training data X, posteriori probability of a hypothesis H, P(H|X), follows the Bayes theorem • Predicts X belongs to Ci iff the probability P(Ci|X) is the highest among all the P(Ck|X) for all the k classes )( )()|()|( X XX P HPHPHP 
  • 42. Compiled By: Kamal Acharya Towards Naïve Bayesian Classifier • Let D be a training set of tuples and their associated class labels, and each tuple is represented by an n-D attribute vector X = (x1, x2, …, xn) • Suppose there are m classes C1, C2, …, Cm. Classification is to derive the maximum posteriori, i.e., the maximal P(Ci|X) • This can be derived from Bayes’ theorem • Since P(X) is constant for all classes, only needs to be maximized )( )()|( )|( X X X P i CP i CP i CP  )()|()|( i CP i CP i CP XX 
  • 43. Compiled By: Kamal Acharya Derivation of Naïve Bayes Classifier • A simplified assumption: – attributes are conditionally independent (i.e., no dependence relation between attributes): – This greatly reduces the computation cost: Only counts the class distribution )|(...)|()|( 1 )|()|( 21 CixPCixPCixP n k CixPCiP nk   X
  • 44. Compiled By: Kamal Acharya Naïve Bayesian Classifier: Training Dataset Class: C1:buys_computer = ‘yes’ C2:buys_computer = ‘no’ Data sample X = (age <=30, Income = medium, Student = yes Credit_rating = Fair) age income studentcredit_ratingbuys_compu <=30 high no fair no <=30 high no excellent no 31…40 high no fair yes >40 medium no fair yes >40 low yes fair yes >40 low yes excellent no 31…40 low yes excellent yes <=30 medium no fair no <=30 low yes fair yes >40 medium yes fair yes <=30 medium yes excellent yes 31…40 medium no excellent yes 31…40 high yes fair yes >40 medium no excellent no
  • 45. Compiled By: Kamal Acharya Naïve Bayesian Classifier: An Example • P(Ci): P(buys_computer = “yes”) = 9/14 = 0.643 P(buys_computer = “no”) = 5/14= 0.357 • Compute P(X|Ci) for each class P(age = “<=30” | buys_computer = “yes”) = 2/9 = 0.222 P(age = “<= 30” | buys_computer = “no”) = 3/5 = 0.6 P(income = “medium” | buys_computer = “yes”) = 4/9 = 0.444 P(income = “medium” | buys_computer = “no”) = 2/5 = 0.4 P(student = “yes” | buys_computer = “yes) = 6/9 = 0.667 P(student = “yes” | buys_computer = “no”) = 1/5 = 0.2 P(credit_rating = “fair” | buys_computer = “yes”) = 6/9 = 0.667 P(credit_rating = “fair” | buys_computer = “no”) = 2/5 = 0.4 • X = (age <= 30 , income = medium, student = yes, credit_rating = fair) P(X|Ci) : P(X|buys_computer = “yes”) = 0.222 x 0.444 x 0.667 x 0.667 = 0.044 P(X|buys_computer = “no”) = 0.6 x 0.4 x 0.2 x 0.4 = 0.019 P(X|Ci)*P(Ci) : P(X|buys_computer = “yes”) * P(buys_computer = “yes”) = 0.028 P(X|buys_computer = “no”) * P(buys_computer = “no”) = 0.007 Therefore, X belongs to class (“buys_computer = yes”)
  • 46. Compiled By: Kamal Acharya Avoiding the 0-Probability Problem • Naïve Bayesian prediction requires each conditional prob. be non-zero. Otherwise, the predicted prob. will be zero • Ex. Suppose a dataset with 1000 tuples, income=low (0), income= medium (990), and income = high (10), • Use Laplacian correction – Adding 1 to each case Prob(income = low) = 1/1003 Prob(income = medium) = 991/1003 Prob(income = high) = 11/1003 – The “corrected” prob. estimates are close to their “uncorrected” counterparts    n k CixkPCiXP 1 )|()|(
  • 47. Compiled By: Kamal Acharya Naïve Bayesian Classifier: Comments • Advantages – Easy to implement – Good results obtained in most of the cases • Disadvantages – Assumption: class conditional independence, therefore loss of accuracy – Practically, dependencies exist among variables • E.g., hospitals: patients: Profile: age, family history, etc. Symptoms: fever, cough etc., Disease: lung cancer, diabetes, etc. • Dependencies among these cannot be modeled by Naïve Bayesian Classifier
  • 48. Naive Bayesian Classifier Example Outlook Temperature Humidity Windy Class sunny hot high false N sunny hot high true N overcast hot high false P rain mild high false P rain cool normal false P rain cool normal true N overcast cool normal true P sunny mild high false N sunny cool normal false P rain mild normal false P sunny mild normal true P overcast mild high true P overcast hot normal false P rain mild high true N play tennis? Compiled By: Kamal Acharya
  • 49. Naive Bayesian Classifier Example Outlook Temperature Humidity Windy Class sunny hot high false N sunny hot high true N rain cool normal true N sunny mild high false N rain mild high true N Outlook Temperature Humidity Windy Class overcast hot high false P rain mild high false P rain cool normal false P overcast cool normal true P sunny cool normal false P rain mild normal false P sunny mild normal true P overcast mild high true P overcast hot normal false P 9 5 Compiled By: Kamal Acharya
  • 50. Naive Bayesian Classifier Example • Given the training set, we compute the probabilities: • We also have the probabilities – P = 9/14 – N = 5/14 O utlook P N H um idity P N sunny 2/9 3/5 high 3/9 4/5 overcast 4/9 0 norm al 6/9 1/5 rain 3/9 2/5 Tem preature W indy hot 2/9 2/5 true 3/9 3/5 m ild 4/9 2/5 false 6/9 2/5 cool 3/9 1/5 Compiled By: Kamal Acharya
  • 51. Naive Bayesian Classifier Example • To classify a new sample X: – outlook = sunny – temperature = cool – humidity = high – windy = false • Prob(P|X) = Prob(P)*Prob(sunny|P)*Prob(cool|P)* Prob(high|P)*Prob(false|P) = 9/14*2/9*3/9*3/9*6/9 = 0.01 • Prob(N|X) = Prob(N)*Prob(sunny|N)*Prob(cool|N)* Prob(high|N)*Prob(false|N) = 5/14*3/5*1/5*4/5*2/5 = 0.013 • Therefore X takes class label N Compiled By: Kamal Acharya
  • 52. • Second example X = <rain, hot, high, false> • P(X|p)·P(p) = P(rain|p)·P(hot|p)·P(high|p)·P(false|p)·P(p) = 3/9·2/9·3/9·6/9·9/14 = 0.010582 • P(X|n)·P(n) = P(rain|n)·P(hot|n)·P(high|n)·P(false|n)·P(n) = 2/5·2/5·4/5·2/5·5/14 = 0.018286 • Sample X is classified in class N (don’t play) Naive Bayesian Classifier Example Compiled By: Kamal Acharya
  • 53. Compiled By: Kamal Acharya Lazy vs. Eager Learning • Lazy vs. eager learning – Lazy learning (e.g., instance-based learning): Simply stores training data (or only minor processing) and waits until it is given a test tuple – Eager learning: Given a set of training set, constructs a classification model before receiving new (e.g., test) data to classify • Lazy: less time in training but more time in predicting • Accuracy – Lazy method effectively uses a richer hypothesis space since it uses many local linear functions to form its implicit global approximation to the target function – Eager: must commit to a single hypothesis that covers the entire instance space
  • 54. Compiled By: Kamal Acharya Lazy Learner: Instance-Based Methods • Instance-based learning: – Store training examples and delay the processing (“lazy evaluation”) until a new instance must be classified – Typical approach: k-nearest neighbor approach – Instances represented as points in a Euclidean space.
  • 55. Compiled By: Kamal Acharya The k-Nearest Neighbor Algorithm • All instances correspond to points in the n-D space • The nearest neighbor are defined in terms of Euclidean distance, dist(X1, X2) • Target function could be discrete- or real- valued . _ + _ xq + _ _ + _ _ +
  • 56. Compiled By: Kamal Acharya Contd… • For discrete-valued, k-NN returns the most common value among the k training examples nearest to xq • k-NN for real-valued prediction for a given unknown tuple – Returns the mean values of the k nearest neighbors • Distance-weighted nearest neighbor algorithm – Weight the contribution of each of the k neighbors according to their distance to the query xq • Give greater weight to closer neighbors 2),( 1 i xqxd w
  • 57. Compiled By: Kamal Acharya Contd… • Advantages: – Robust to noisy data by averaging k-nearest neighbors • Disadvantages: – Curse of dimensionality: • distance between neighbors could be dominated by irrelevant attributes • To overcome it elimination of the least relevant attributes
  • 58. Compiled By: Kamal Acharya Classification by Backpropagation • Backpropagation: A neural network learning algorithm • Started by psychologists and neurobiologists to develop and test computational analogues of neurons • A neural network: A set of connected input/output units where each connection has a weight associated with it • During the learning phase, the network learns by adjusting the weights so as to be able to predict the correct class label of the input tuples • Also referred to as connectionist learning due to the connections between units
  • 59. Compiled By: Kamal Acharya Neural Network as a Classifier • Weakness – Long training time – Require a number of parameters typically best determined empirically, e.g., the network topology or ``structure." – Poor interpretability: Difficult to interpret the symbolic meaning behind the learned weights and of ``hidden units" in the network • Strength – High tolerance to noisy data – Ability to classify untrained patterns – Well-suited for continuous-valued inputs and outputs – Successful on a wide array of real-world data – Algorithms are inherently parallel – Techniques have recently been developed for the extraction of rules from trained neural networks
  • 60. Compiled By: Kamal Acharya A Neuron (= a perceptron) • The n-dimensional input vector x is mapped into variable y by means of the scalar product and a nonlinear function mapping - f weighted sum Input vector x output y Activation function weight vector w  w0 w1 wn x0 x1 xn )sign(y ExampleFor n 0i jii bxw   bj
  • 61. Compiled By: Kamal Acharya A Multi-Layer Feed-Forward Neural Network Output layer Input layer Hidden layer Output vector Input vector: X wij
  • 62. Compiled By: Kamal Acharya How A Multi-Layer Neural Network Works? • The inputs to the network correspond to the attributes measured for each training tuple • Inputs are fed simultaneously into the units making up the input layer • They are then weighted and fed simultaneously to a hidden layer • The number of hidden layers is arbitrary, although usually only one • The weighted outputs of the last hidden layer are input to units making up the output layer, which emits the network's prediction • The network is feed-forward in that none of the weights cycles back to an input unit or to an output unit of a previous layer • From a statistical point of view, networks perform nonlinear regression: Given enough hidden units and enough training samples, they can closely approximate any function
  • 63. Compiled By: Kamal Acharya Defining a Network Topology • First decide the network topology: # of units in the input layer, # of hidden layers (if > 1), # of units in each hidden layer, and # of units in the output layer • Normalizing the input values for each attribute measured in the training tuples to [0.0—1.0] • One input unit per domain value, each initialized to 0 • Output, if for classification and more than two classes, one output unit per class is used • Once a network has been trained and its accuracy is unacceptable, repeat the training process with a different network topology or a different set of initial weights
  • 64. Compiled By: Kamal Acharya Backpropagation • Iteratively process a set of training tuples & compare the network's prediction with the actual known target value • For each training tuple, the weights are modified to minimize the mean squared error between the network's prediction and the actual target value • Modifications are made in the “backwards” direction: from the output layer, through each hidden layer down to the first hidden layer, hence “backpropagation” • Steps – Initialize weights (to small random #s) and biases in the network – Propagate the inputs forward (by applying activation function) – Backpropagate the error (by updating weights and biases) – Terminating condition (when error is very small, etc.)
  • 65. Issues regarding classification and prediction (1): Data Preparation • Data cleaning – Preprocess data in order to reduce noise and handle missing values • Relevance analysis (feature selection) – Remove the irrelevant or redundant attributes • Data transformation – Generalize and/or normalize data • numerical attribute income  categorical {low, medium, high} • normalize all numerical attributes to [0,1) Compiled By: Kamal Acharya
  • 66. Issues regarding classification and prediction (2): Evaluating Classification Methods • accuracy • Speed – time to construct the model – time to use the model • Robustness – handling noise and missing values • Scalability – efficiency in disk-resident databases • Interpretability: – understanding and insight provided by the model • Goodness of rules (quality) – decision tree size – compactness of classification rules Compiled By: Kamal Acharya
  • 67. Compiled By: Kamal Acharya Evaluation methods • Holdout Method: The available data set D is divided into two disjoint subsets, – the training set Dtrain (for learning a model) – the test set Dtest (for testing the model) • Important: training set should not be used in testing and the test set should not be used in learning. – Unseen test set provides a unbiased estimate of accuracy. • The test set is also called the holdout set. (the examples in the original data set D are all labeled with classes.) • This method is mainly used when the data set D is large.
  • 68. Compiled By: Kamal Acharya Evaluation methods (cont…) • k-fold cross-validation: The available data is partitioned into k equal-size disjoint subsets. • Use each subset as the test set and combine the rest n-1 subsets as the training set to learn a classifier. • The procedure is run k times, which give k accuracies. • The final estimated accuracy of learning is the average of the k accuracies. • 10-fold and 5-fold cross-validations are commonly used. • This method is used when the available data is not large.
  • 69. Compiled By: Kamal Acharya Evaluation methods (cont…) • Leave-one-out cross-validation: This method is used when the data set is very small. • It is a special case of cross-validation • Each fold of the cross validation has only a single test example and all the rest of the data is used in training. • If the original data has m examples, this is m-fold cross- validation
  • 70. Compiled By: Kamal Acharya Evaluation methods (cont…) • Validation set: the available data is divided into three subsets, – a training set, – a test set and – a validation set • A validation set is used frequently for estimating parameters in learning algorithms. • In such cases, the values that give the best accuracy on the validation set are used as the final parameter values. • Cross-validation can be used for parameter estimating as well.
  • 71. Home Work • What is supervised classification? In what situations can this technique be useful? • Briefly outline the major steps of decision tree classification. • Why naïve Bayesian classification called naïve? Briefly outline the major idea of naïve Bayesian classification. • Compare the advantages and disadvantages of eager classification versus lazy classification. • Write an algorithm for k-nearest- neighbor classification given k, the nearest number of neighbors, and n, the number of attributes describing each tuple. Compiled By: Kamal Acharya
  • 72. Thank You ! Compiled By: Kamal Acharya