SlideShare a Scribd company logo
CLASSIFICATION
Dr. Amanpreet Kaur​
Associate Professor,
Chitkara University,
Punjab
AGENDA
Introduction​
Primary goals
​Areas of growth
Timeline
​Summary​
CLASSIFICATION
• Classification predictive modeling involves assigning a
class label to input examples.
• Binary classification refers to predicting one of two classes
and multi-class classification involves predicting one of
more than two classes.
• Multi-label classification involves predicting one or more
classes for each example and imbalanced classification
refers to classification tasks where the distribution of
examples across the classes is not equal.
• Examples of classification problems include:
• Given an example, classify if it is spam or not.
• Given a handwritten character, classify it as one of the known
characters.
• Given recent user behavior, classify as churn or not.
3
•Text categorization (e.g., spam filtering)
•Fraud detection
•Optical character recognition
•Machine vision (e.g., face detection)
•Natural-language processing
• (e.g., spoken language understanding)
•Market segmentation
• (e.g.: predict if customer will respond to promotion)
•Bioinformatics
•(e.g., classify proteins according to their function)
4
EXAMPLE OF
CLASSIFICATION
DECISION TREE
• The decision tree algorithm builds the classification
model in the form of a tree structure.
• It utilizes the if-then rules which are equally exhaustive
and mutually exclusive in classification.
• The process goes on with breaking down the data into
smaller structures and eventually associating it with an
incremental decision tree.
• The final structure looks like a tree with nodes and
leaves. The rules are learned sequentially using the
training data one at a time.
• Each time a rule is learned, the tuples covering the
rules are removed. The process continues on the
training set until the termination point is met.
5
6
DECISION TREE
Root
Node
Interior
Node
Leaf
Node
• Terminologies Related to Decision Tree Algorithms
• Root Node: This node gets divided into different homogeneous
nodes. It represents entire sample.
• Splitting: It is the process of splitting or dividing a node into two
or more sub-nodes.
• Interior Nodes: They represent different tests on an attribute.
• Branches: They hold the outcomes of those tests.
• Leaf Nodes: When the nodes can’t be split further, they are
called leaf nodes.
• Parent and Child Nodes: The node from where sub-nodes are
created is called a parent node. And, the sub-nodes are called
the child nodes.
7
DECISION TREE
DECISIONTREE
CLASSIFIER ()
• DecisionTreeClassifier (): It is nothing but the decision tree
classifier function to build a decision tree model in Machine
Learning using Python. The DecisionTreeClassifier() function
looks like this:
• DecisionTreeClassifier (criterion = ‘gini’, random_state =
None, max_depth = None, min_samples_leaf =1)
• Here are a few important parameters:
• criterion: It is used to measure the quality of a split in the
decision tree classification. By default, it is ‘gini’; it also supports
‘entropy’.
• max_depth: This is used to add maximum depth to the
decision tree after the tree is expanded.
• min_samples_leaf: This parameter is used to add the
minimum number of samples required to be present at a leaf
node.
8
DECISION TREE
REGRESSOR ()
• DecisionTreeRegressio (): It is the decision tree regressor function used to
build a decision tree model in Machine Learning using Python. The
DecisionTreeRegressor () function looks like this:
• DecisionTreeRegressor (criterion = ‘mse’, random_state =None ,
max_depth=None, min_samples_leaf=1,)
• criterion: This function is used to measure the quality of a split in the decision
tree regression. By default, it is ‘mse’ (the mean squared error), and it also
supports ‘mae’ (the mean absolute error).
• max_depth: This is used to add maximum depth to the decision tree after the
tree is expanded.
• min_samples_leaf: This function is used to add the minimum number of
samples required to be present at a leaf node.
9
GAINS CHART
From left to right:
• Node 6: 16% of policies, 35% of claims.
• Node 4: add’l 16% of policies, 24% of claims.
• Node 2: add’l 8% of policies, 10% of claims.
• ..etc.
– The steeper the gains chart, the stronger the
model.
– Analogous to a lift curve.
– Desirable to use out-of-sample data.
10
SPLITTING RULES
• Select the variable value (X=t1) that produces the
greatest “separation” in the target variable.
• “Separation” defined in many ways.
– Regression Trees (continuous target): use sum of squared errors.
– Classification Trees (categorical target): choice of entropy, Gini measure,
“twoing” splitting rule.
11
REGRESSION TREES
• Tree-based modeling for continuous target
variable
• most intuitively appropriate method for loss
ratio analysis
• Find split that produces greatest separation in
∑[y – E(y)]2
• i.e.: find nodes with minimal within variance
• and therefore greatest between variance
• like credibility theory
12
CLASSIFICATION TREES
• Tree-based modeling for discrete target
variable
• In contrast with regression trees, various
measures of purity are used
• Common measures of purity:
• Gini, entropy, “twoing”
• Intuition: an ideal retention model would
produce nodes that contain either defectors
only or non-defectors only
13
REGRESSION VS. CLASSIFICATION
TREES
14
• Splitting Criteria:
– Gini, Entropy, Twoing
• Goodness of fit measure:
– misclassification rates
• Prior probabilities and misclassification costs
– available as model “tuning parameters”
• Splitting Criterion:
– sum of squared errors
• Goodness of fit:
– same measure!
– sum of squared errors
• No priors or misclassification costs…
– … just let it run
HOW CART SELECTS THE
OPTIMAL TREE
• Use cross-validation (CV) to select the optimal
decision tree.
• Built into the CART algorithm.
– Essential to the method; not an add-on
• Basic idea: “grow the tree” out as far as you can….
Then “prune back”.
• CV: tells you when to stop pruning.
15
GROWING AND
PRUNING
• One approach: stop growing the tree early.
• But how do you know when to stop?
• CART: just grow the tree all the way out; then prune back.
• Sequentially collapse nodes that result in the smallest
change in purity.
• “weakest link” pruning.
16
CART ADVANTAGES
• Nonparametric (no probabilistic assumptions)
• Automatically performs variable selection
• Uses any combination of continuous/discrete variables
– Very nice feature: ability to automatically bin massively
categorical variables into a few categories.
• zip code, business class, make/model…
• Discovers “interactions” among variables
– Good for “rules” search
– Hybrid GLM-CART models
17
CART DISADVANTAGES
• The model is a step function, not a continuous score
• So if a tree has 10 nodes, yhat can only take on 10 possible values.
• MARS improves this.
• Might take a large tree to get good lift
• But then hard to interpret
• Data gets chopped thinner at each split
• Instability of model structure
• Correlated variables  random data fluctuations could result in
entirely different trees.
• CART does a poor job of modeling linear structure
18
USES OF CART
• Building predictive models
– Alternative to GLMs, neural nets, etc
• Exploratory Data Analysis
– Breiman et al: a different view of the data.
– You can build a tree on nearly any data set with
minimal data preparation.
– Which variables are selected first?
– Interactions among variables
– Take note of cases where CART keeps re-splitting the
same variable (suggests linear relationship)
• Variable Selection
– CART can rank variables
– Alternative to stepwise regression 19
REFERENCES
E Books-
Peter Harrington “Machine Learning In Action”,
DreamTech Press
Ethem Alpaydın, “Introduction to Machine
Learning”, MIT Press
Video Links-
https://www.youtube.com/watch?v=atw7hUrg3_8
https://www.youtube.com/watch?v=FuJVLsZYkuE
20
THANK YOU
aman_preet_k@yahoo.co.in

More Related Content

DOCX
Classification Using Decision Trees and RulesChapter 5.docx
PDF
Foundations of Machine Learning - StampedeCon AI Summit 2017
PDF
Lecture 9 - Decision Trees and Ensemble Methods, a lecture in subject module ...
PPTX
Ai & Machine learning - 31140523010 - BDS302.pptx
PDF
Lecture 5 Decision tree.pdf
PPTX
23-512(Decision Tree) machine learning ppt
PDF
Mini datathon
PPTX
decision tree machine learning model for classification
Classification Using Decision Trees and RulesChapter 5.docx
Foundations of Machine Learning - StampedeCon AI Summit 2017
Lecture 9 - Decision Trees and Ensemble Methods, a lecture in subject module ...
Ai & Machine learning - 31140523010 - BDS302.pptx
Lecture 5 Decision tree.pdf
23-512(Decision Tree) machine learning ppt
Mini datathon
decision tree machine learning model for classification

Similar to Classification.pptx (20)

PPTX
Introduction to ML.NET
PDF
2023 Supervised Learning for Orange3 from scratch
 
PPTX
Primer on major data mining algorithms
PPTX
Intro to ml_2021
PPTX
7 Decision Trees and Entrophy in software .pptx
PPTX
DataMiningOverview_Galambos_2015_06_04.pptx
PPTX
Footprinting, Enumeration, Scanning, Sniffing, Social Engineering
PDF
Machine Learning Unit-5 Decesion Trees & Random Forest.pdf
PDF
Decision tree for data mining and computer
PPTX
Machine learning tree models for classification
PPTX
Mini datathon - Bengaluru
PPTX
Data Mining - The Big Picture!
PPTX
Decision Tree Classification Algorithm.pptx
PDF
Causal Random Forest
PPTX
Comparitive Analysis .pptx Footprinting, Enumeration, Scanning, Sniffing, Soc...
PPTX
Model Development And Evaluation in ML.pptx
PPTX
Macine learning algorithms - K means, KNN
PPTX
DECISION TREE AND PROBABILISTIC MODELS.pptx
PDF
General Tips for participating Kaggle Competitions
PDF
Decision tree
Introduction to ML.NET
2023 Supervised Learning for Orange3 from scratch
 
Primer on major data mining algorithms
Intro to ml_2021
7 Decision Trees and Entrophy in software .pptx
DataMiningOverview_Galambos_2015_06_04.pptx
Footprinting, Enumeration, Scanning, Sniffing, Social Engineering
Machine Learning Unit-5 Decesion Trees & Random Forest.pdf
Decision tree for data mining and computer
Machine learning tree models for classification
Mini datathon - Bengaluru
Data Mining - The Big Picture!
Decision Tree Classification Algorithm.pptx
Causal Random Forest
Comparitive Analysis .pptx Footprinting, Enumeration, Scanning, Sniffing, Soc...
Model Development And Evaluation in ML.pptx
Macine learning algorithms - K means, KNN
DECISION TREE AND PROBABILISTIC MODELS.pptx
General Tips for participating Kaggle Competitions
Decision tree
Ad

Recently uploaded (20)

PPTX
UNIT 4 Total Quality Management .pptx
PDF
Well-logging-methods_new................
PDF
PPT on Performance Review to get promotions
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Current and future trends in Computer Vision.pptx
PPT
Project quality management in manufacturing
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT
Mechanical Engineering MATERIALS Selection
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Artificial Intelligence
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
737-MAX_SRG.pdf student reference guides
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
UNIT 4 Total Quality Management .pptx
Well-logging-methods_new................
PPT on Performance Review to get promotions
additive manufacturing of ss316l using mig welding
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Current and future trends in Computer Vision.pptx
Project quality management in manufacturing
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
III.4.1.2_The_Space_Environment.p pdffdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Fundamentals of safety and accident prevention -final (1).pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mechanical Engineering MATERIALS Selection
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Artificial Intelligence
bas. eng. economics group 4 presentation 1.pptx
Safety Seminar civil to be ensured for safe working.
737-MAX_SRG.pdf student reference guides
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Ad

Classification.pptx

  • 1. CLASSIFICATION Dr. Amanpreet Kaur​ Associate Professor, Chitkara University, Punjab
  • 2. AGENDA Introduction​ Primary goals ​Areas of growth Timeline ​Summary​
  • 3. CLASSIFICATION • Classification predictive modeling involves assigning a class label to input examples. • Binary classification refers to predicting one of two classes and multi-class classification involves predicting one of more than two classes. • Multi-label classification involves predicting one or more classes for each example and imbalanced classification refers to classification tasks where the distribution of examples across the classes is not equal. • Examples of classification problems include: • Given an example, classify if it is spam or not. • Given a handwritten character, classify it as one of the known characters. • Given recent user behavior, classify as churn or not. 3
  • 4. •Text categorization (e.g., spam filtering) •Fraud detection •Optical character recognition •Machine vision (e.g., face detection) •Natural-language processing • (e.g., spoken language understanding) •Market segmentation • (e.g.: predict if customer will respond to promotion) •Bioinformatics •(e.g., classify proteins according to their function) 4 EXAMPLE OF CLASSIFICATION
  • 5. DECISION TREE • The decision tree algorithm builds the classification model in the form of a tree structure. • It utilizes the if-then rules which are equally exhaustive and mutually exclusive in classification. • The process goes on with breaking down the data into smaller structures and eventually associating it with an incremental decision tree. • The final structure looks like a tree with nodes and leaves. The rules are learned sequentially using the training data one at a time. • Each time a rule is learned, the tuples covering the rules are removed. The process continues on the training set until the termination point is met. 5
  • 7. • Terminologies Related to Decision Tree Algorithms • Root Node: This node gets divided into different homogeneous nodes. It represents entire sample. • Splitting: It is the process of splitting or dividing a node into two or more sub-nodes. • Interior Nodes: They represent different tests on an attribute. • Branches: They hold the outcomes of those tests. • Leaf Nodes: When the nodes can’t be split further, they are called leaf nodes. • Parent and Child Nodes: The node from where sub-nodes are created is called a parent node. And, the sub-nodes are called the child nodes. 7 DECISION TREE
  • 8. DECISIONTREE CLASSIFIER () • DecisionTreeClassifier (): It is nothing but the decision tree classifier function to build a decision tree model in Machine Learning using Python. The DecisionTreeClassifier() function looks like this: • DecisionTreeClassifier (criterion = ‘gini’, random_state = None, max_depth = None, min_samples_leaf =1) • Here are a few important parameters: • criterion: It is used to measure the quality of a split in the decision tree classification. By default, it is ‘gini’; it also supports ‘entropy’. • max_depth: This is used to add maximum depth to the decision tree after the tree is expanded. • min_samples_leaf: This parameter is used to add the minimum number of samples required to be present at a leaf node. 8
  • 9. DECISION TREE REGRESSOR () • DecisionTreeRegressio (): It is the decision tree regressor function used to build a decision tree model in Machine Learning using Python. The DecisionTreeRegressor () function looks like this: • DecisionTreeRegressor (criterion = ‘mse’, random_state =None , max_depth=None, min_samples_leaf=1,) • criterion: This function is used to measure the quality of a split in the decision tree regression. By default, it is ‘mse’ (the mean squared error), and it also supports ‘mae’ (the mean absolute error). • max_depth: This is used to add maximum depth to the decision tree after the tree is expanded. • min_samples_leaf: This function is used to add the minimum number of samples required to be present at a leaf node. 9
  • 10. GAINS CHART From left to right: • Node 6: 16% of policies, 35% of claims. • Node 4: add’l 16% of policies, 24% of claims. • Node 2: add’l 8% of policies, 10% of claims. • ..etc. – The steeper the gains chart, the stronger the model. – Analogous to a lift curve. – Desirable to use out-of-sample data. 10
  • 11. SPLITTING RULES • Select the variable value (X=t1) that produces the greatest “separation” in the target variable. • “Separation” defined in many ways. – Regression Trees (continuous target): use sum of squared errors. – Classification Trees (categorical target): choice of entropy, Gini measure, “twoing” splitting rule. 11
  • 12. REGRESSION TREES • Tree-based modeling for continuous target variable • most intuitively appropriate method for loss ratio analysis • Find split that produces greatest separation in ∑[y – E(y)]2 • i.e.: find nodes with minimal within variance • and therefore greatest between variance • like credibility theory 12
  • 13. CLASSIFICATION TREES • Tree-based modeling for discrete target variable • In contrast with regression trees, various measures of purity are used • Common measures of purity: • Gini, entropy, “twoing” • Intuition: an ideal retention model would produce nodes that contain either defectors only or non-defectors only 13
  • 14. REGRESSION VS. CLASSIFICATION TREES 14 • Splitting Criteria: – Gini, Entropy, Twoing • Goodness of fit measure: – misclassification rates • Prior probabilities and misclassification costs – available as model “tuning parameters” • Splitting Criterion: – sum of squared errors • Goodness of fit: – same measure! – sum of squared errors • No priors or misclassification costs… – … just let it run
  • 15. HOW CART SELECTS THE OPTIMAL TREE • Use cross-validation (CV) to select the optimal decision tree. • Built into the CART algorithm. – Essential to the method; not an add-on • Basic idea: “grow the tree” out as far as you can…. Then “prune back”. • CV: tells you when to stop pruning. 15
  • 16. GROWING AND PRUNING • One approach: stop growing the tree early. • But how do you know when to stop? • CART: just grow the tree all the way out; then prune back. • Sequentially collapse nodes that result in the smallest change in purity. • “weakest link” pruning. 16
  • 17. CART ADVANTAGES • Nonparametric (no probabilistic assumptions) • Automatically performs variable selection • Uses any combination of continuous/discrete variables – Very nice feature: ability to automatically bin massively categorical variables into a few categories. • zip code, business class, make/model… • Discovers “interactions” among variables – Good for “rules” search – Hybrid GLM-CART models 17
  • 18. CART DISADVANTAGES • The model is a step function, not a continuous score • So if a tree has 10 nodes, yhat can only take on 10 possible values. • MARS improves this. • Might take a large tree to get good lift • But then hard to interpret • Data gets chopped thinner at each split • Instability of model structure • Correlated variables  random data fluctuations could result in entirely different trees. • CART does a poor job of modeling linear structure 18
  • 19. USES OF CART • Building predictive models – Alternative to GLMs, neural nets, etc • Exploratory Data Analysis – Breiman et al: a different view of the data. – You can build a tree on nearly any data set with minimal data preparation. – Which variables are selected first? – Interactions among variables – Take note of cases where CART keeps re-splitting the same variable (suggests linear relationship) • Variable Selection – CART can rank variables – Alternative to stepwise regression 19
  • 20. REFERENCES E Books- Peter Harrington “Machine Learning In Action”, DreamTech Press Ethem Alpaydın, “Introduction to Machine Learning”, MIT Press Video Links- https://www.youtube.com/watch?v=atw7hUrg3_8 https://www.youtube.com/watch?v=FuJVLsZYkuE 20