Introduction To Data Mining
Introduction To Data Mining
P A N G . NI N G T A N
M i c h i g a nS t a t eU n i v e r s i t y
MICHAELSTEINBACH
U n i v e r s i toyf M i n n e s o t a
V I P I N K UM A R
U n i v e r s i toy f M i n n e s o t a
a n d A r m yH i g h P e r f o r m a n c e
ComputinR g e s e a r cC henter
+f.f_l crf.rfh. .W if f
aqtY6l$
t.T.R.C.
i'&'ufe61ttt1/.
Y \ t.\ $t,/,1'
'48!
n,5 \. 7\ V
Access the latest information about Addison-Wesley titles from our iWorld Wide Web site:
http ://www. aw-bc.com/computing
Many of the designations used by manufacturers and sellers to distiriguish their products
are claimed as trademarks. where those designations appear in this book, and Addison-
Wesley was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
The programs and applications presentedin this book have been incl,[rdedfor their
instructional value. They have been tested with care, but are not guatanteedfor any
particular purpose. The publisher does not offer any warranties or representations,nor does
it accept any liabilities with respect to the programs or applications.
For information on obtaining permission for use of material in this work, please submit a
written request to PearsonEducation, Inc., Rights and Contract Department, 75 Arlington
Street,Suite 300, Boston, MA02II6 or fax your requestto (617) g4g-j047.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval
system, or transmitted, in any form or by any means, electronic, mechanical, photocopying,
recording, or any other media embodiments now known or hereafter to become known,
without the prior written permission of the publisher. printed in the united Statesof
America.
lsBN0-321-42052-7
2 3 4 5 67 8 9 10-HAM-O807 06
our famili,es
Preface
Advances in data generation and collection are producing data sets of mas-
sive size in commerce and a variety of scientific disciplines. Data warehouses
store details of the salesand operations of businesses,Earth-orbiting satellites
beam high-resolution images and sensordata back to Earth, and genomicsex-
periments generate sequence,structural, and functional data for an increasing
number of organisms. The ease with which data can now be gathered and
stored has created a new attitude toward data analysis: Gather whatever data
you can whenever and wherever possible. It has become an article of faith
that the gathered data will have value, either for the purpose that initially
motivated its collection or for purposes not yet envisioned.
The field of data mining grew out of the limitations of current data anal-
ysis techniques in handling the challengesposedlby these new types of data
sets. Data mining does not replace other areas of data analysis, but rather
takes them as the foundation for much of its work. While some areas of data
mining, such as association analysis, are unique to the field, other areas, such
as clustering, classification, and anomaly detection, build upon a long history
of work on these topics in other fields. Indeed, the willingness of data mining
researchersto draw upon existing techniques has contributed to the strength
and breadth of the field, as well as to its rapid growth.
Another strength of the field has been its emphasis on collaboration with
researchers in other areas. The challenges of analyzing new types of data
cannot be met by simply applying data analysis techniques in isolation from
those who understand the data and the domain in which it resides. Often, skill
in building multidisciplinary teams has been as responsiblefor the successof
data mining projects as the creation of new and innovative algorithms. Just
as, historically, many developments in statistics were driven by the needs of
agriculture, industry, medicine, and business, rxrany of the developments in
data mining are being driven by the needs of those same fields.
This book began as a set of notes and lecture slides for a data mining
course that has been offered at the University of Minnesota since Spring 1998
to upper-division undergraduate and graduate Students. Presentation slides
viii Preface
and exercisesdeveloped in these offerings grew with time and served as a basis
for the book. A survey of clustering techniques in data mining, originally
written in preparation for research in the area, served as a starting point
for one of the chapters in the book. Over time, the clustering chapter was
joined by chapters on data, classification, association analysis, and anomaly
detection. The book in its current form has been class tested at the home
institutions of the authors-the University of Minnesota and Michigan State
University-as well as several other universities.
A number of data mining books appeared in the meantime, but were not
completely satisfactory for our students primarily graduate and undergrad-
uate students in computer science,but including students from industry and
a wide variety of other disciplines. Their mathematical and computer back-
grounds varied considerably, but they shared a common goal: to learn about
data mining as directly as possible in order to quickly apply it to problems
in their own domains. Thus, texts with extensive mathematical or statistical
prerequisiteswere unappealing to many of them, as were texts that required a
substantial database background. The book that evolved in responseto these
students needsfocusesas directly as possible on the key conceptsof data min-
ing by illustrating them with examples, simple descriptions of key algorithms,
and exercises.
To help the readers better understand the concepts that have been pre-
sented, we provide an extensive set of examples, figures, and exercises. Bib-
Iiographic notes are included at the end of each chapter for readers who are
interested in more advanced topics, historically important papers, and recent
trends. The book also contains a comprehensivesubject and author index.
Janardan, Rong Jin, George Karypis, Haesun Park, William F. Punch, Shashi
Shekhar, and Jaideep Srivastava. The collaborators on our many data mining
projects, who also have our gratitude, include Ramesh Agrawal, Steve Can-
non, Piet C. de Groen, FYan Hill, Yongdae Kim, Steve Klooster, Kerry Long,
Nihar Mahapatra, Chris Potter, Jonathan Shapiro, Kevin Silverstein, Nevin
Young, and Zhi-Li Zhang.
The departments of Computer Scienceand Engineering at the University of
Minnesota and Michigan State University provided computing resourcesand
a supportive environment for this project. ARDA, ARL, ARO, DOE, NASA,
and NSF provided research support for Pang-Ning Tan, Michael Steinbach,
and Vipin Kumar. In particular, Kamal Abdali, Dick Brackney, Jagdish Chan-
dra, Joe Coughlan, Michael Coyle, Stephen Davis, Flederica Darema, Richard
Hirsch, Chandrika Kamath, Raju Namburu, N. Radhakrishnan, James Sido-
ran, Bhavani Thuraisingham, Walt Tiernin, Maria Zemankova, and Xiaodong
Zhanghave been supportive of our research in data mining and high-performance
computing.
It was a pleasure working with the helpful staff at Pearson Education. In
particular, we would like to thank Michelle Brown, Matt Goldstein, Katherine
Harutunian, Marilyn Lloyd, Kathy Smith, and Joyce Wells. We would also
like to thank George Nichols, who helped with the art work and Paul Anag-
nostopoulos, who provided I4.T[X support. We are grateful to the following
Pearson reviewers: Chien-Chung Chan (University of Akron), Zhengxin Chen
(University of Nebraska at Omaha), Chris Clifton (Purdue University), Joy-
deep Ghosh (University of Texas, Austin), Nazli Goharian (Illinois Institute
of Technology), J. Michael Hardin (University of Alabama), James Hearne
(Western Washington University), Hillol Kargupta (University of Maryland,
Baltimore County and Agnik, LLC), Eamonn Keogh (University of California-
Riverside), Bing Liu (University of Illinois at Chicago), Mariofanna Milanova
(University of Arkansas at Little Rock), Srinivasan Parthasarathy (Ohio State
University), Zbigniew W. Ras (University of North Carolina at Charlotte),
Xintao Wu (University of North Carolina at Charlotte), and Mohammed J.
Zaki (RensselaerPolvtechnic Institute).
Gontents
Preface vll
Introduction 1
1.1 What Is Data Mining? 2
7.2 Motivating Challenges 4
1.3 The Origins of Data Mining 6
1.4 Data Mining Tasks 7
1.5 Scope and Organization of the Book 11
1.6 Bibliographic Notes 13
t.7 Exercises 16
Data 19
2.I Types of Data 22
2.1.I Attributes and Measurement 23
2.L.2 Types of Data Sets . 29
2.2 Data Quality 36
2.2.I Measurement and Data Collection Issues 37
2.2.2 IssuesRelated to Applications 43
2.3 Data Preprocessing 44
2.3.L Aggregation 45
2.3.2 Sampling 47
2.3.3 Dimensionality Reduction 50
2.3.4 Feature Subset Selection 52
2.3.5 Feature Creation 55
2.3.6 Discretization and Binarization 57
2.3:7 Variable Tlansformation . 63
2.4 Measuresof Similarity and Dissimilarity . . . 65
2.4.L Basics 66
2.4.2 Similarity and Dissimilarity between Simple Attributes . 67
2.4.3 Dissimilarities between Data Objects . 69
2.4.4 Similarities between Data Objects 72
xiv Contents
Exploring Data 97
3.i The Iris Data Set 98
3.2 Summary Statistics 98
3.2.L Frequenciesand the Mode 99
3.2.2 Percentiles 100
3.2.3 Measuresof Location: Mean and Median 101
3.2.4 Measuresof Spread: Range and Variance 102
3.2.5 Multivariate Summary Statistics 704
3.2.6 Other Ways to Summarize the Data 105
3.3 Visualization 105
3.3.1 Motivations for Visualization 105
3.3.2 General Concepts 106
3.3.3 Techniques 110
3.3.4 Visualizing Higher-Dimensional Data . 724
3.3.5 Do's and Don'ts 130
3.4 OLAP and Multidimensional Data Analysis 131
3.4.I Representing Iris Data as a Multidimensional Array 131
3.4.2 Multidimensional Data: The General Case . 133
3.4.3 Analyzing Multidimensional Data 135
3.4.4 Final Comments on Multidimensional Data Analysis 139
3 . 5 Bibliographic Notes 139
3 . 6 Exercises 747
Classification:
Basic Concepts, Decision Tlees, and Model Evaluation L45
4.1 Preliminaries 746
4.2 General Approach to Solving a Classification Problem 748
4.3 Decision Tlee Induction 150
4.3.1 How a Decision Tlee Works 150
4.3.2 How to Build a Decision TYee 151
4.3.3 Methods for Expressing Attribute Test Conditions 155
4.3.4 Measuresfor Selecting the Best Split . 158
4.3.5 Algorithm for Decision Tlee Induction 164
4.3.6 An Examole: Web Robot Detection 166
Contents xv
9.1.3 ClusterCharacteristics
. . 573
9.L.4 GeneralCharacteristicsof ClusteringAlgorithms 575
9.2 Prototype-BasedClustering 577
9.2.1 F\zzy Clustering 577
9.2.2 ClusteringUsing Mixture Models 583
9.2.3 Self-OrganizingMaps (SOM) 594
9.3 Density-BasedClustering 600
9.3.1 Grid-BasedClustering 601
9.3.2 SubspaceClustering 604
9.3.3 DENCLUE: A Kernel-BasedSchemefor Density-Based
Clustering 608
9.4 Graph-BasedClustering 612
9.4.1 Sparsification 613
9.4.2 Minimum SpanningTlee (MST) Clustering . . . 674
9.4.3 OPOSSUM:Optimal Partitioning of SparseSimilarities
UsingMETIS 616
9.4.4 Chameleon: Hierarchical Clustering with Dynamic
Modeling 616
9.4.5 Shared Nearest Neighbor Similarity 622
9.4.6 The Jarvis-Patrick Clustering Algorithm 625
9.4.7 SNN Density 627
9.4.8 SNN Density-Based Clustering 629
9.5 Scalable Clustering Algorithms 630
9.5.1 Scalability: General Issuesand Approaches 630
9.5.2 BIRCH 633
9.5.3 CURE 635
9.6 Which Clustering Algorithm? 639
9.7 Bibliographic Notes 643
9.8 Exercises 647
Introduction
Rapid advances in data collection and storage technology have enabled or-
ganizations to accumulate vast amounts of data. However, extracting useful
information has proven extremely challenging. Often, traditional data analy-
sis tools and techniques cannot be used because of the massive size of a data
set. Sometimes,the non-traditional nature of the data means that traditional
approachescannot be applied even if the data set is relatively small. In other
situations, the questions that need to be answeredcannot be addressedusing
existing data analysis techniques, and thus, new methods need to be devel-
oped.
Data mining is a technology that blends traditional data analysis methods
with sophisticated algorithms for processinglarge volumes of data. It has also
opened up exciting opportunities for exploring and analyzing new types of
data and for analyzing old types of data in new ways. In this introductory
chapter, we present an overview of data mining and outline the key topics
to be covered in this book. We start with a description of some well-known
applications that require new techniques for data analysis.
answer important business questions such as "Who are the most profitable
customers?" "What products can be cross-soldor up-sold?" and "What is the
revenue outlook of the company for next year?)) Some of these questions mo-
tivated the creation of association analvsis (Chapters 6 and 7), a new data
analysis technique.
Information
Figure1,1. Theprocess
of knowledge
discovery
indatabases
(KDD).
The input data can be stored in a variety of formats (flat files, spread-
sheets, or relational tables) and may reside in a centralized data repository
or be distributed across multiple sites. The purpose of preprocessing is
to transform the raw input data into an appropriate format for subsequent
analysis. The steps involved in data preprocessinginclude fusing data from
multiple sources, cleaning data to remove noise and duplicate observations,
and selecting records and features that are relevant to the data mining task
at hand. Because of the many ways data can be collected and stored, data
4 Chapter 1 Introduction
experiment and often represent opportunistic samplesof the data, rather than
random samples. Also, the data sets frequently involve non-traditional types
of data and data distributions.
1.2.Datamining
Figure ofmany
asa conlluence disciplines.
L.4 Data Mining Tasks 7
Figure 1.3 illustrates four of the core data mining tasks that are described
in the remainder of this book.
Figure
1.3.Fourofthecoredatamining
tasks.
8 Chapter 1 Introduction
Predictive modeling refers to the task of building a model for the target
variable as a function of the explanatory variables. There are two types of
predictive modeling tasks: classification, which is used for discrete target
variables, and regression, which is used for continuous target variables. For
example, predicting whether a Web user will make a purchase at an online
bookstore is a classification task becausethe target variable is binary-valued.
On the other hand, forecasting the future price of a stock is a regression task
becauseprice is a continuous-valued attribute. The goal of both tasks is to
learn a model that minimizes the error between the predicted and true values
of the target variable. Predictive modeling can be used to identify customers
that will respond to a marketing campaign, predict disturbances in the Earth's
ecosystem,or judge whether a patient has a particular diseasebased on the
results of medical tests.
Example 1.1 (Predicting the Type of a Flower). Consider the task of
predicting a species of flower based on the characteristics of the flower. In
particular, consider classifying an Iris flower as to whether it belongs to one
of the following three Iris species: Setosa, Versicolour, or Virginica. To per-
form this task, we need a data set containing the characteristics of various
flowers of these three species. A data set with this type of information is
the well-known Iris data set from the UCI Machine Learning Repository at
http: /hrurw.ics.uci.edu/-mlearn. In addition to the speciesof a flower,
this data set contains four other attributes: sepal width, sepal length, petal
length, and petal width. (The Iris data set and its attributes are described
further in Section 3.1.) Figure 1.4 shows a plot of petal width versus petal
length for the 150 flowers in the Iris data set. Petal width is broken into the
categories low, med'ium, and hi'gh,which correspond to the intervals [0' 0.75),
[0.75,1.75), [1.75,oo), respectively.Also, petal length is broken into categories
low, med,'ium,and hi,gh,which correspondto the intervals [0' 2.5), [2.5,5), [5'
oo), respectively. Based on these categories of petal width and length, the
following rules can be derived:
While these rules do not classify all the flowers, they do a good (but not
perfect) job of classifying most of the flowers. Note that flowers from the
Setosa speciesare well separated from the Versicolour and Virginica species
with respect to petal width and length, but the latter two species overlap
somewhat with respect to these attributes. I
L.4 Data Mining Tasks I
l----a--fo-------i
r Setosa la o r
. Versicolour ,ftfo oto ai
: o o o I
o Virginica I
' t0f0a o
0?oo r a
arf I
?1.75 !0_l! _.! o__o
E
() .t
aa rO
r 1.5 . .4. a?o
E o aaaa
= a aaaaaaa
(t' aaaa a
() aa
(Ll aaa aa
I
I
lltll
llt I
I lllltt I
It!
122.5345(
PetalLength(cm)
Figure1.4. Petalwidthversus
petallength
for150lrisflowers,
than observations that belong to other clusters. Clustering has been used to
group sets of related customers, find areas of the ocean that have a significant
impact on the Earth's climate, and compressdata.
Example 1.3 (Document Clustering). The collection of news articles
shown in Table 1.2 can be grouped based on their respective topics. Each
article is representedas a set of word-frequency pairs (r, where tu is a word
"),
and c is the number of times the word appears in the article. There are two
natural clusters in the data set. The first cluster consists of the first four ar-
ticles, which correspond to news about the economy,while the second cluster
contains the last four articles, which correspond to news about health care. A
good clustering algorithm should be able to identify these two clusters based
on the similarity between words that appear in the articles.
of newsarticles.
Table1.2.Collection
Article Words
I dollar: 1, industry: 4, country: 2, loan: 3, deal: 2, government: 2
2 machinery: 2, labor: 3, market: 4, industry: 2, work: 3, country: 1
.) job: 5, inflation: 3, rise: 2, jobless: 2, market: 3, country: 2, index: 3
A domestic: 3, forecast: 2, gain: 1, market: 2, sale: 3, price: 2
r
J patient: 4, symptom: 2, drug: 3, health: 2, clinic: 2, doctor: 2
o pharmaceutical:2, company: 3, drug: 2,vaccine:1, flu: 3
7 death: 2, cancer: 4, drug: 3, public: 4, health: 3, director: 2
8 medical: 2, cost: 3, increase: 2, patient: 2, health: 3, care: 1
1.5 Scope and Organization of the Book 11
fiers. The multiclass and imbalanced class problems are also discussed.These
topics can be covered independently.
Association analysis is explored in Chapters 6 and 7. Chapter 6 describes
the basics of association analysis: frequent itemsets, association rules, and
some of the algorithms used to generate them. Specific types of frequent
itemsets-maximal, closed,and hyperclique-that are important for data min-
ing are also discussed,and the chapter concludeswith a discussionof evalua-
tion measuresfor association analysis. Chapter 7 considers a variety of more
advancedtopics, including how association analysis can be applied to categor-
ical and continuous data or to data that has a concept hierarchy. (A concept
hierarchy is a hierarchical categorization of objects, e.g., store items, clothing,
shoes,sneakers.) This chapter also describeshow association analysis can be
extended to find sequential patterns (patterns involving order), patterns in
graphs, and negative relationships (if one item is present, then the other is
not).
Cluster analysis is discussedin Chapters 8 and 9. Chapter 8 first describes
the different types of clusters and then presentsthree specific clustering tech-
niques: K-means, agglomerative hierarchical clustering, and DBSCAN. This
is followed by a discussion of techniques for validating the results of a cluster-
ing algorithm. Additional clustering concepts and techniques are explored in
Chapter 9, including fiszzy and probabilistic clustering, Self-Organizing Maps
(SOM), graph-based clustering, and density-basedclustering. There is also a
discussion of scalability issues and factors to consider when selecting a clus-
tering algorithm.
The last chapter, Chapter 10, is on anomaly detection. After some basic
definitions, several different types of anomaly detection are considered: sta-
tistical, distance-based,density-based, and clustering-based. Appendices A
through E give a brief review of important topics that are used in portions of
the book: linear algebra, dimensionality reduction, statistics, regression,and
optimization.
The subject of data mining, while relatively young compared to statistics
or machine learning, is already too large to cover in a single book. Selected
references to topics that are only briefly covered, such as data quality' are
provided in the bibliographic notes of the appropriate chapter. Referencesto
topics not covered in this book, such as data mining for streams and privacy-
preserving data mining, are provided in the bibliographic notes of this chapter.
1_.6 Bibliographic Notes 13
Glymour et al. 116]consider the lessons that statistics may have for data
mining. Smyth et aL [38] describe how the evolution of data mining is being
driven by new types of data and applications, such as those involving streams,
graphs, and text. Emerging applications in data mining are consideredby Han
et al. [20] and Smyth [37] describessome researchchallengesin data mining.
A discussionof how developmentsin data mining researchcan be turned into
practical tools is given by Wu et al. [43]. Data mining standards are the
subject of a paper by Grossman et al. [17]. Bradley [3] discusseshow data
mining algorithms can be scaled to large data sets.
With the emergence of new data mining applications have come new chal-
lengesthat need to be addressed.For instance, concernsabout privacy breaches
as a result of data mining have escalated in recent years, particularly in ap-
plication domains such as Web commerce and health care. As a result, there
is growing interest in developing data mining algorithms that maintain user
privacy. Developing techniques for mining encrypted or randomized data is
known as privacy-preserving data mining. Some general referencesin this
area include papers by Agrawal and Srikant l1], Clifton et al. [7] and Kargupta
et al. [27]. Vassilios et al. [39] provide a survey.
Recent years have witnessed a growing number of applications that rapidly
generatecontinuous streams of data. Examples of stream data include network
traffic, multimedia streams, and stock prices. Severalissuesmust be considered
when mining data streams, such as the limited amount of memory available,
the need for online analysis, and the change of the data over time. Data
mining for stream data has become an important area in data mining. Some
selected publications are Domingos and Hulten [8] (classification), Giannella
et al. [15] (associationanalysis), Guha et al. [19] (clustering), Kifer et al. [28]
(changedetection), Papadimitriou et al. [32] (time series),and Law et al. [30]
(dimensionality reduction).
Bibliography
[1] R. Agrawal and R. Srikant. Privacy-preserving data mining. ln Proc. of 2000 ACM-
SIGMOD IntI. Conf. on Management of Data, pages 439-450, Dallas, Texas, 2000.
ACM Press.
12lM. J. A. Berry and G. Linofi. Data Mtni,ng Technr,ques: For Marketing, Sales, and'
Customer Relati,onship Management. Wiley Computer Publishing, 2nd edition, 2004.
[')] S. Bradley, J. Gehrke, R. Ramakrishnan, and R. Srikant. Scaling mining algorithms
lol
P.
to large databases. Communicati,ons of the ACM, 45(8):38 43,2002.
[4] S. Chakrabarti. Mini.ng the Web: Di.scoueri.ngKnouledge from Hypertert Data' Morgan
Kaufmann, San Flancisco, CA, 2003.
Bibliography 15
[5] M.-s. chen, J. Han, and P. s. Yu. Data Mining: An overview from a Database
Perspective. IEEE Transact'ions on Knowled,ge abd Data Engineering, g(6):g66-gg3,
1996.
[6] v. cherkassky and F. Mulier. Learn'ing from Data: concepts, Theory, and, Method,s.
Wiley Interscience, 1g98.
[7] c. clifton, M. Kantarcioglu, and J. vaidya. Defining privacy for data mining. In
National Sc'ience Foundat'ion workshop on Nert Generation Data Mining, pages 126-
133, Baltimore, MD, November 2002.
f8] P' Domingos and G. Hulten. Mining high-speed data streams. In Proc. of the 6th Intt.
conf. on Knowled,ge Discouery and Data M'in'ing, pages z1-80, Boston, Massachusetts,
2000. ACM Press.
J9] R. o' Duda, P. E. Hart, and D. G. stork. Pattern classification John wiley & sons,
Inc., New York, 2nd edition, 2001.
[10] M. H. Dunham. Data Mini,ng: Introd,uctory and, Ad,uancedropics. prentice Hall, 2002.
f11] U. M. Fayyad, G. G. Grinstein, and A. Wierse, editors. Information Visualization in
Data Mining and, Knowled,ge Discouery. Morgan Kaufmann Publishers, San Ftancisco,
CA, September 200I.
112] u. M. Fayyad, G. Piatetsky-Shapiro, and P. smyth. Fyom Data Mining to Knowledge
Discovery: An overview. rn Ad,aances in Knowledge Discouery and Data M'ining, pages
1-34. AAAI Press, 1996.
[13] u. M. Fayyad, G. Piatetsky-shapiro, P. Smyth, and R. uthurusamy, editors. Aduances
'in Knowled,ge Discouery and Data Mini.ng. press, 1g96.
AAAI/MIT
[14] J. H. Friedman. Data Mining and Statistics: What's the Connection? Unpublished.
www-stat.stanford.edu/-jhf/ftp/dm-stat.ps, 1992.
[15] c. Giannella, J. Han, J. Pei, X. Yan, and P. s. Yu. Mining Fyequent patterns in Data
streams at Multiple Time Granularities. In H. Kargupta, A. Joshi, K. sivakumar, and
Y. Yesha, editors, Nert Generation Data M,ining, pages ISI-2I2. AAAI/MIT,2003.
116] c. Glymour, D. Madigan, D. Pregibon, and P. smyth. statistical rhemes and Lessons
for Data Mining. Data Mining and Knowleilge D,iscouerg,1(1):11-28, 1992.
[17] R. L. Grossman, M. F. Hornick, and G. Meyer. Data mining standards initiatives.
c omtnunications of the A c M, 45(g) :59-6I, 2002.
[18] R. L. Grossman, c. Kamath, P. Kegelmeyer, v. Kumar, and R. Namburu, editors. Data
Mini;ng for Sci,entific and Engineering Applicati,ons. Kluwer Academic Publishers, 2001.
119] s. Guha, A. Meyerson, N. Mishra, R. Motwani, and L. o'callaghan. clustering Data
Streams: Theory and Practice. IEEE Tbansact'ions on Knowledge and, Data Engineering,
15(3) :515-528, May/June 2003.
[20] J. Han, R. B. Altman, V. Kumar, H. Mannila, and D. pregibon. Emerging scientific
applications in data mining. Communications of the ACM, 4S(8):54-b8,2002.
[21] J. Han and M. Kamber. Data Mining: concepts and, Techniques. Morgan Kaufmann
Publishers, San Francisco, 2001.
[22] D. J. Hand. Data Mining: Statistics and More? The American Statistician, 52(2):
112-118,1998.
[23] D. J. Hand, H. Mannila, and P. smyth. Principles of Data Mining. MIT press, 2001.
l24l T. Hastie, R. Tibshirani, and J. H. Fliedman. The Elements of Stati.stical Learning:
Data Mini,ng, Inference, Pred,iction. Springer, New York, 2001.
[25] M. Kantardzic. Data Mini,ng: concepts, Mod,el.s,Method,s, and Algorithms. wiley-IEEE
Press, Piscataway NJ, 2003.
16 Chapter I Introduction
L.7 Exercises
1. Discuss whether or not each of the following activities is a data mining task.
L.7 Exercises L7
2 . Suppose that you are employed as a data mining consultant for an Internet
search engine company. Describe how data mining can help the company by
giving specific examples of how techniques, such as clustering, classification,
association rule mining, and anomaly detection can be applied.
J. For each of the following data sets, explain whether or not data privacy is an
important issue.
The Type of Data Data sets differ in a number of ways. For example, the
attributes used to describedata objects can be of different types-quantitative
or qualitative-and data sets may have special characteristics;e.g., some data
sets contain time series or objects with explicit relationships to one another.
Not surprisingly, the type of data determines which tools and techniques can
be used to analyze the data. F\rrthermore, new research in data mining is
often driven by the need to accommodate new application areas and their new
types of data.
The Quality of the Data Data is often far from perfect. while most data
mining techniques can tolerate some level of imperfection in the data, a focus
on understanding and improving data quality typically improves the quality
of the resulting analysis. Data quality issuesthat often need to be addressed
include the presenceof noise and outliers; missing, inconsistent, or duplicate
data; and data that is biased or, in some other way, unrepresentative of the
phenomenon or population that the data is supposed to describe.
Preprocessing Steps to Make the Data More suitable for Data Min-
ing often, the raw data must be processedin order to make it suitable for
analysis. While one objective may be to improve data quality, other goals
focus on modifying the data so that it better fits a specifieddata mining tech-
nique or tool. For example, a continuous attribute, e.g., length, m&y need to
be transformed into an attribute with discrete categories,e.g., short, med,ium,
or long, in order to apply a particular technique. As another example, the
20 Chapter 2 Data
Hi,
I've attached the data file that I mentioned in my previous email.
Each line contains the information for a single patient and consists
of five fields. We want to predict the last field using the other fields.
I don't have time to provide any more information about the data
since I'm going out of town for a couple of days, but hopefully that
won't slow you down too much. And if you don't mind, could we
meet when I get back to discussyour preliminary results? I might
invite a few other members of mv team.
Despite some misgivings, you proceed to analyze the data. The first few
rows of the fiIe are as follows:
A brieflook at the data revealsnothing strange. You put your doubts aside
and start the analysis. There are only 1000 lines, a smaller data file than you
had hoped for, but two days later, you feel that you have made some progress.
You arrive for the meeting, and while waiting for others to arrive, you strike
2L
Statistician: So, you got the data for all the patients?
Data Miner: Yes. I haven't had much time for analysis, but I
do have a few interesting results.
Statistician: Amazing. There were so many data issueswith
this set of patients that I couldn't do much.
Data Miner: Oh? I didn't hear about any possible problems.
Statistician: Well, first there is field 5, the variable we want to
predict. It's common knowledge among people who analyze
this type of data that results are better if you work with the
log of the values, but I didn't discover this until later. Was it
mentioned to you?
Data Miner: No.
Statistician: But surely you heard about what happened to field
4? It's supposedto be measured on a scale from 1 to 10, with
0 indicating a missing value, but becauseof a data entry
error, all 10's were changed into 0's. Unfortunately, since
some of the patients have missing values for this field, it's
impossible to say whether a 0 in this field is a real 0 or a 10.
Quite a few of the records have that problem.
Data Miner: Interesting. Were there any other problems?
Statistician: Yes, fields 2 and 3 are basically the same, but I
assumethat you probably noticed that.
Data Miner: Yes, but these fields were only weak predictors of
field 5.
Statistician: Anyway, given all those problems, I'm surprised
you were able to accomplish anything.
Data Miner: Thue, but my results are really quite good. Field 1
is a very strong predictor of field 5. I'm surprised that this
wasn't noticed before.
Statistician: What? Field 1 is just an identification number.
Data Miner: Nonetheless,my results speak for themselves.
Statistician: Oh, no! I just remembered. We assignedID
numbers after we sorted the records based on field 5. There is
a strong connection, but it's meaningless.Sorry.
22 Chapter 2 Data
datasetcontaining
Table2,1.A sample information.
student
StudentID Year Grade Point Average (GPA)
Although record-based data sets are common, either in flat files or rela-
tional database systems, there are other important types of data sets and
systems for storing data. In Section 2.I.2,we will discusssome of the types of
data sets that are commonly encountered in data mining. However, we first
consider attributes.
2.L Types of Data 23
What Is an attribute?
sure it. In other words, the values used to represent an attribute may have
properties that are not properties of the attribute itself, and vice versa. This
is illustrated with two examples.
Example 2.3 (Employee Age and ID Number). Two attributes that
might be associatedwith an employee are ID and age (in years). Both of these
attributes can be represented as integers. However, while it is reasonableto
talk about the average age of an employee, it makes no sense to talk about
the average employee ID. Indeed, the only aspect of employees that we want
to capture with the ID attribute is that they are distinct. Consequently,the
only valid operation for employeeIDs is to test whether they are equal. There
is no hint of this limitation, however, when integers are used to represent the
employee ID attribute. For the age attribute, the properties of the integers
used to represent age are very much the properties of the attribute. Even so,
the correspondence is not complete since, for example, ages have a maximum'
while integers do not.
Example 2.4 (Length of Line Segments). Consider Figure 2.1, which
shows some objects-line segments and how the length attribute of these
objects can be mapped to numbers in two different ways. Each successive
line segment, going from the top to the bottom, is formed by appending the
topmost line segment to itself. Thus, the second line segment from the top is
formed by appending the topmost line segment to itself twice, the third line
segment from the top is formed by appending the topmost line segment to
itself three times, and so forth. In a very real (physical) sense, all the line
segmentsare multiples of the first. This fact is captured by the measurements
on the right-hand side of the figure, but not by those on the left hand-side.
More specifically, the measurement scale on the left-hand side captures only
the ordering of the length attribute, while the scale on the right-hand side
captures both the ordering and additivity properties. Thus, an attribute can be
measuredin a way that does not capture all the properties of the attribute. t
The type of an attribute should tell us what properties of the attribute are
reflected in the values used to measure it. Knowing the type of an attribute
is important because it tells us which properties of the measured values are
consistent with the underlying properties of the attribute, and therefore, it
allows us to avoid foolish actions, such as computing the average employee ID.
Note that it is common to refer to the type of an attribute as the type of a
measurement scale.
2.1 Types of Data 25
----> 1
----> 2
--> 3
--> 5
of lengthsto numbers
A mapping
propertiesof
rensth. nffii?;'fi"::ilin""till8in*o
Figure2.1.Themeasurement
ofthelength
of linesegments
ontwodifferent
scales
of measurement.
1. Distinctness : and *
3. Addition * and -
4. Multiplication x and /
this does not mean that the operations appropriate for one attribute type are
appropriate for the attribute types above it.
Nominal and ordinal attributes are collectively referred to as categorical
or qualitative attributes. As the name suggests,qualitative attributes, such
as employeeID, lack most of the properties of numbers. Even if they are rep-
resented by numbers, i.e., integers, they should be treated more like symbols.
The remaining two types of attributes, interval and ratio, are collectively re-
ferred to as quantitative or numeric attributes. Quantitative attributes are
represented by numbers and have most of the properties of numbers. Note
that quantitative attributes can be integer-valued or continuous.
The types of attributes can also be described in terms of transformations
that do not changethe meaning of an attribute. Indeed, S. Smith Stevens,the
psychologist who originally defined the types of attributes shown in Table 2.2,
defined them in terms of these permissible transformations. For example,
2.L Types of Data 27
Table2,3.Transformations
thatdefineattribute
levels,
Attribute
Typ" Tlansformation Comment
Nominal Any one-to-one mapping, €.g., & It all employee IIJ numbers are
permutation of values reassigned, it will not make any
differcnce
()rdinal An order-preserving change of An attribute encompassingthe
values. i.e.. notion of good, better, best can
new _ualue : f (old_ualue), be represented equally well by
where / is a monotonic function. the values {1,2,3} or by
{ 0 . 5 ,1 , 1 0 } .
Interval new -ualue : a * old-talue I b, The Fahrenheit and Celsius
o. and b constants. temperature scales differ in the
Iocation of their zero value and
the size of a degree (unit).
Ratio new -ualue : a * ol,d-ua|ue Length can be measured in
meters or feet.
Asymmetric Attributes
Before providing details of specific kinds of data sets, we discuss three char-
acteristics that apply to many data sets and have a significant impact on the
data mining techniquesthat are used: dimensionality, sparsity, and resolution.
Sparsity For some data sets, such as those with asymmetric features, most
attributes of an object have values of 0; in many casesTfewer than 1% of
the entries are non-zero. In practical terms, sparsity is an advantage because
usually only the non-zero values need to be stored and manipulated. This
results in significant savings with respect to computation time and storage.
FurthermoreT some data mining algorithms work well only for sparse data.
Record Data
Much data mining work assumesthat the data set is a collection of records
(data objects), each of which consists of a fixed set of data fields (attributes).
See Figure 2.2(a). For the most basic form of record data, there is no explicit
relationship among records or data fields, and every record (object) has the
same set of attributes. Record data is usually stored either in flat files or in
relational databases. Relational databasesare certainly more than a collection
of records, but data mining often does not use any of the additional information
available in a relational database. Rather, the database serves as a convenient
place to find records. Different types of record data are described below and
are illustrated in Figure 2.2.
The Data Matrix If the data objects in a collection of data all have the
same fixed set of numeric attributes, then the data objects can be thought of as
points (vectors) in a multidimensional space,where each dimension represents
a distinct attribute describing the object. A set of such data objects can be
interpreted as an n'Lby n matrix, where there are rn rows, one for each object,
2.L Types of Data 31
Document1 0 0 2 o 0 0 2
Document2 0 7 0 0 0 0 0
Document3 0 I 0 0 2 2 0 o 0
Figure2.2, Different
variations
of record
data.
and n columns, one for each attribute. (A representationthat has data objects
as columns and attributes as rows is also fine.) This matrix is called a data
matrix or a pattern matrix. A data matrix is a variation of record data,
but becauseit consists of numeric attributes, standard matrix operation can
be applied to transform and manipulate the data. Therefore, the data matrix
is the standard data format for most statistical data. Figure 2.2(c) shows a
sample data matrix.
Graph-Based Data
Data with Objects That Are Graphs If objects have structure, that
is, the objects contain subobjects that have relationships, then such objects
are frequently represented as graphs. For example, the structure of chemical
compounds can be representedby a graph, where the nodes are atoms and the
links between nodes are chemical bonds. Figure 2.3(b) shows a ball-and-stick
diagram of the chemical compound benzene,which contains atoms of carbon
(black) and hydrogen (gray). A graph representation makes it possible to
determine which substructures occur frequently in a set of compounds and to
ascertain whether the presenceof any of these substructures is associatedwith
the presenceor absenceof certain chemical properties, such as melting point
or heat of formation. Substructure mining, which is a branch of data mining
that analyzes such data, is consideredin Section 7.5.
2.1 Types of Data 33
UsefulLinks:
. Bbuoq@hv -
Knowledge Discovery and
. mer Useful Web sib
Data Mining Bibliography
(GeB up&td frequenily, so dsironenl)
o ACM SIGmD
o onuqqets
o fteDahh€
Ordered Data
For some types of data, the attributes have relationships that involve order
in time or space. Different types of ordered data are described next and are
shown in Figure 2.4.
25
20
E
15
E
10
1983 19& 1985 1986 1987 1984 1989 1990 1991 lS2 1993 1994
y€r
Figure2.4. Different
variations
ofordered
data.
C2, and C3; and five different items A, B, C, D, and E. In the top table,
each row corresponds to the items purchased at a particular time by each
customer. For instance, at time f3, customer C2 purchased items A and D. In
the bottom table, the same information is displayed, but each row corresponds
to a particular customer. Each row contains information on each transaction
involving the customer, where a transaction is consideredto be a set of items
and the time at which those items were purchased. For example, customer C3
bought items A and C at time t2.
2.1 Types of Data 35
Time Series Data Time series data is a special type of sequential data
in which each record is a time series, i.e., a series of measurementstaken
over time. For example, a financial data set might contain objects that are
time seriesof the daily prices of various stocks. As another example, consider
Figure 2.4(c), which shows a time series of the averagemonthly temperature
for Minneapolis during the years 1982 to 1994. When working with temporal
data, it is important to consider temporal autocorrelation; i.e., if two
measurements are close in time, then the values of those measurements are
often very similar.
Spatial Data Some objects have spatial attributes, such as positions or ar-
eas, as well as other types of attributes. An example of spatial data is weather
data (precipitation, temperature, pressure) that is collected for a variety of
geographical locations. An important aspect of spatial data is spatial auto-
correlation; i.e., objects that are physically close tend to be similar in other
ways as well. Thus, two points on the Earth that are close to each other
usually have similar values for temperature and rainfall.
Important examples of spatial data are the science and engineering data
sets that are the result of measurements or model output taken at regularly
or irregularly distributed points on a two- or three-dimensional grid or mesh.
For instance, Earth science data sets record the temperature or pressure mea-
sured at points (grid cells) on latitude-longitude spherical grids of various
resolutions,e.8., 1o by 1o. (See Figure 2.4(d).) As another example, in the
simulation of the flow of a gas, the speed and direction of flow can be recorded
for each grid point in the simulation.
36 Chapter 2 Data
Most data mining algorithms are designed for record data or its variations,
such as transaction data and data matrices. Record-oriented techniques can
be applied to non-record data by extracting features from data objects and
using these features to create a record corresponding to each object. Consider
the chemical structure data that was described earlier. Given a set of common
substructures, each compound can be represented as a record with binary
attributes that indicate whether a compound contains a specific substructure.
Such a representation is actually a transaction data set, where the transactions
are the compounds and the items are the substructures.
In some cases, it is easy to represent the data in a record format, but
this type of representation does not capture all the information in the data.
Consider spatio-temporal data consisting of a time series from each point on
a spatial grid. This data is often stored in a data matrix, where each row
representsa location and each column represents a particular point in time.
However, such a representation does not explicitly capture the time relation-
ships that are present among attributes and the spatial relationships that
exist among objects. This does not mean that such a representation is inap-
propriate, but rather that these relationships must be taken into consideration
during the analysis. For example, it would not be a good idea to use a data
mining technique that assumesthe attributes are statistically independent of
one another.
It is unrealistic to expect that data will be perfect. There may be problems due
to human error, limitations of measuring devices,or flaws in the data collection
process. Values or even entire data objects may be missing. In other cases,
there may be spurious or duplicate objects; i.e., multiple data objects that all
correspond to a single "real" object. For example, there might be two different
records for a person who has recently lived at two different addresses. Even if
all the data is present and "looks fine," there may be inconsistencies-a person
has a height of 2 meters, but weighs only 2 kilograms.
In the next few sections,we focus on aspectsofdata quality that are related
to data measurement and collection. We begin with a definition of measure-
ment and data collection errors and then consider a variety of problems that
involve measurement error: noise, artifacts, bias, precision, and accuracy. We
conclude by discussing data quality issuesthat may involve both measurement
and data collection problems: outliers, missing and inconsistent values, and
duplicate data.
The term measurement error refers to any problem resulting from the mea-
surement process. A common problem is that the value recorded differs from
the true value to some extent. For continuous attributes, the numerical dif-
ference of the measured and true value is called the error. The term data
collection error refers to errors such as omitting data objects or attribute
values, or inappropriately including a data object. For example, a study of
animals of a certain species might include animals of a related speciesthat are
similar in appearanceto the speciesof interest. Both measurementerrors and
data collection errors can be either systematic or random.
We will only consider general types of errors. Within particular domains,
there are certain types of data errors that are commonplace, and there ofben
exist well-developed techniques for detecting and/or correcting these errors.
For example, keyboard errors are common when data is entered manually, and
as a result, many data entry programs have techniques for detecting and, with
human intervention, correcting such errors.
2.5.Noise
Figure ina timeseries
context.
. i*.
i
^ +,
+
T+
T
iat
(a) Three groups of points. (b) With noise points (+) added.
more noise were added to the time series,its shape would be lost. Figure 2.6
shows a set of data points before and after some noise points (indicated by
'+'s) have been added. Notice that some of the noise points are intermixed
with the non-noise points.
The term noise is often used in connection with data that has a spatial or
temporal component. In such cases,techniques from signal or image process-
ing can frequently be used to reduce noise and thus, help to discover patterns
(signals) that might be "lost in the noise." Nonetheless,the elimination of
noise is frequently difficult, and much work in data mining focuses on devis-
ing robust algorithms that produce acceptable results even when noise is
present.
2.2 Data Quality 39
review the details of working with significant digits, as most readers will have
encountered them in previous courses, and they are covered in considerable
depth in science,engineering, and statistics textbooks.
Issuessuch as significant digits, precision, bias, and accuracy are sometimes
overlooked, but they are important for data mining as well as statistics and
science. Many times, data sets do not come with information on the precision
of the data, and furthermore, the programs used for analysis return results
without any such information. Nonetheless,without some understanding of
the accuracy of the data and the results, an analyst runs the risk of committing
serious data analysis blunders.
Outliers
Outliers are either (1) data objects that, in some sense,have characteristics
that are different from most of the other data objects in the data set, or
(2) values of an attribute that are unusual with respect to the typical values
for that attribute. Alternatively, we can speak of anomalous objects or
values. There is considerableleeway in the definition of an outlier, and many
different definitions have been proposed by the statistics and data mining
communities. Furthermore, it is important to distinguish between the notions
of noise and outliers. Outliers can be legitimate data objects or values. Thus,
unlike noise, outliers may sometimes be of interest. In fraud and network
intrusion detection, for example, the goal is to find unusual objects or events
from among a large number of normal ones. Chapter 10 discussesanomaly
detection in more detail.
Missing Values
Ignore the Missing Value during Analysis Many data mining approaches
can be modified to ignore missing values. For example, suppose that objects
are being clustered and the similarity between pairs of data objects needs to
be calculated. If one or both objects of a pair have missing values for some
attributes, then the similarity can be calculated by using only the attributes
that do not have missing values. It is true that the similarity will only be
approximate, but unless the total number of attributes is small or the num-
ber of missing values is high, this degree of inaccuracy may not matter much.
Likewise, many classification schemes can be modified to work with missing
values.
Inconsistent Values
Duplicate Data
A data set may include data objects that are duplicates, or almost duplicates,
of one another. Many people receive duplicate mailings becausethey appear
in a database multiple times under slightly different names. To detect and
eliminate such duplicates, two main issuesmust be addressed. First, if there
are two objects that actually represent a single object, then the values of
corresponding attributes may differ, and these inconsistent values must be
2.2 Data Quality 43
b
I
60 65 70 75 80 85 90 95
Year
Figure2.7, Conelation
of SSTdatabetween positive
pairsof years.Whiteareasindicate correlation.
Blackareasindicate
negative
correlation.
issuesat the measurementand data collection level, there are many issuesthat
are specific to particular applications and fields. Again, we consider only a few
of the general issues.
Relevance The available data must contain the information necessary for
the application. Consider the task of building a model that predicts the acci-
dent rate for drivers. If information about the age and gender of the driver is
omitted, then it is likely that the model will have limited accuracy unless this
information is indirectly available through other attributes.
Making sure that the objects in a data set are relevant is also challenging.
A common problem is sampling bias, which occurs when a sample does not
contain different types of objects in proportion to their actual occurrence in
the population. For example, survey data describesonly those who respond to
the survey. (Other aspects of sampling are discussedfurther in Section 2.3.2.)
Becausethe results of a data analysis can reflect only the data that is present,
sampling bias will typically result in an erroneous analysis.
Knowledge about the Data Ideally, data sets are accompanied by doc-
umentation that describes different aspects of the data; the quality of this
documentation can either aid or hinder the subsequentanalysis. For example,
if the documentation identifies several attributes as being strongly related,
these attributes are likely to provide highly redundant information, and we
may decide to keep just one. (Consider sales tax and purchase price.) If the
documentation is poor, however, and fails to tell us, for example, that the
missing values for a particular field are indicated with a -9999, then our analy-
sis of the data may be faulty. Other important characteristicsare the precision
of the data, the type of features (nominal, ordinal, interval, ratio), the scale
of measurement (e.g., meters or feet for length), and the origin of the data.
o Aggregation
o Sampling
o Dimensionality reduction
o Feature subset selection
o Feature creation
o Discretization and binarization
o Variable transformation
Roughly speaking, these items fall into two categories: selecting data ob-
jects and attributes for the analysis or creating/changing the attributes. In
both casesthe goal is to improve the data mining analysis with respect to
time, cost, and quality. Details are provided in the following sections.
A quick note on terminology: In the following, we sometimes use synonyms
for attribute, such as feature or variable, in order to follow common usage.
2.3.L Aggregation
Sometimes "lessis more" and this is the casewith aggregation, the combining
of two or more objects into a single object. Consider a data set consisting of
transactions (data objects) recording the daily sales of products in various
store locations (Minneapolis, Chicago, Paris, ...) for different days over the
courseof a year. SeeTable 2.4. One way to aggregatetransactions for this data
set is to replace all the transactions of a single store with a single storewide
transaction. This reducesthe hundreds or thousands of transactions that occur
daily at a specific store to a single daily transaction, and the number of data
objects is reduced to the number of stores.
An obvious issue is how an aggregatetransaction is created; i.e., how the
values of each attribute are combined acrossall the records correspondingto a
particular location to create the aggregatetransaction that representsthe sales
of a single store or date. Quantitative attributes, such as price, are typically
aggregated by taking a sum or an average. A qualitative attribute, such as
item, can either be omitted or summarized as the set of all the items that were
sold at that location.
The data in Table 2.4 can also be viewed as a multidimensional array,
where each attribute is a dimension. FYom this viewpoint, aggregation is the
46 Chapter 2 Data
Table2.4.
Datasetcontaining
information
about purchases.
customer
Ttansaction ID Item I Store Location Date
: :
L01r23 Watch Chicago 0e106/04
r0rl23 Battery Chicago 0e/06104
t0rr24 Shoes Minneapolis 0s106104
;
.5
6
z
z
Figure2.8. Histograms
of standard
deviation andyearlyprecipitation
formonthly in Australia
forthe
oeriod1982to 1993.
2.3.2 Sampling
Sampling Approaches
There are many sampling techniques, but only a few of the most basic ones
and their variations will be covered here. The simplest type of sampling is
simple random sampling. For this type of sampling, there is an equal prob-
ability of selecting any particular item. There are two variations on random
sampling (and other sampling techniques as well): (1) sampling without re-
placement-as each item is selected, it is removed from the set of all objects
that together constitute the population, and (2) sampling with replace-
ment-objects are not removed from the population as they are selected for
the sample. In sampling with replacement,the sameobject can be picked more
than once. The samples produced by the two methods are not much different
when samples are relatively small compared to the data set size, but sampling
with replacement is simpler to analyze since the probability of selecting any
object remains constant during the sampling process.
When the population consists of different types of objects, with widely
different numbers of objects, simple random sampling can fail to adequately
represent those types of objects that are less frequent. This can cause prob-
lems when the analysis requires proper representation of all object types. For
example, when building classification models for rare classes,it is critical that
the rare classesbe adequately representedin the sample. Hence, a sampling
scheme that can accommodate differing frequencies for the items of interest is
needed. Stratified sampling, which starts with prespecified groups of ob-
jects, is such an approach. In the simplest version, equal numbers of objects
are drawn from each group even though the groups are ofdifferent sizes. In an-
other variation, the number of objects drawn from each group is proportional
to the size of that group.
Example 2.8 (Sampling and Loss of Information). Once a sampling
technique has been selected, it is still necessaryto choose the sample size.
Larger sample sizes increase the probability that a sample will be representa-
tive, but they also eliminate much of the advantage of sampling. Conversely,
with smaller sample sizes,patterns may be missedor erroneouspatterns can be
detected. Figure 2.9(a) shows a data set that contains 8000 two-dimensional
points, while Figures 2.9(b) and 2.9(c) show samplesfrom this data set of size
2000 and 500, respectively. Although most of the structure of this data set is
present in the sample of 2000 points, much of the structure is missing in the
sample of 500 points. r
2.3 Data Preprocessing 49
ii
Figure2.9. Example
ofthelossofstructure
withsampling,
oo
oo
(d
oo e
n
o o
o o Sample Size
Figure2.10.Finding points
representative from10groups.
Progressive Sampling
Data sets can have a large number of features. Consider a set of documents,
where each document is represented by a vector whose components are the
frequencies with which each word occurs in the document. In such cases,
2.3 Data Preprocessing 51
Another way to reduce the dimensionality is to use only a subset of the fea-
tures. While it might seemthat such an approach would lose information, this
is not the case if redundant and irrelevant features are present. Redundant
features duplicate much or all of the information contained in one or more
other attributes. For example, the purchaseprice of a product and the amount
of salestax paid contain much of the same information. Irrelevant features
Oontain almost no useful information for the data mining task at hand. For
instance, students' ID numbers are irrelevant to the task of predicting stu-
dents' grade point averages. Redundant and irrelevant features can reduce
classification accuracy and the quality of the clusters that are found.
While some irrelevant and redundant attributes can be eliminated imme-
diately by using common senseoI domain knowledge,selectingthe best subset
of features frequently requires a systematic approach. The ideal approach to
feature selection is to try all possible subsets of features as input to the data
mining aigorithm of interest, and then take the subset that produces the best
results. This method has the advantage of reflecting the objective and bias of
the data mining algorithm that will eventually be used. Unfortunately, since
the number of subsetsinvolving n attributes is 2n, such an approach is imprac-
tical in most situations and alternative strategies are needed. There are three
standard approachesto feature selection: embedded, filter, and wrapper.
2.3 Data Preprocessing 53
Wrapper approaches These methods use the target data mining algorithm
as a black box to find the best subset of attributes, in a way similar to that
of the ideal algorithm described above, but typically without enumerating all
possible subsets.
of a feature
Figure2,11.Flowchart subset process.
selection
Feature Weighting
Feature Extraction
The creation of a new set of features from the original raw data is known as
feature extraction. Consider a set of photographs, where each photograph
is to be classified according to whether or not it contains a human face. The
raw data is a set of pixels, and as such, is not suitable for many types of
classification algorithms. However, if the data is processed to provide higher-
level features, such as the presenceor absenceof certain types of edges and
areasthat are highly correlated with the presenceof human faces,then a much
broader set of classification techniques can be applied to this problem.
Unfortunately, in the sense in which it is most commonly used, feature
extraction is highly domain-specific. For a particular field, such as image
processing, various features and the techniques to extract them have been
developed over a period of time, and often these techniques have limited ap-
plicability to other fields. Consequently,whenever data mining is applied to a
relatively new area, a key task is the development of new features and feature
extraction methods.
56 Chapter 2 Data
(a) Two time series. (b) Noisy time series. (c) Power spectrum
of theFourier
Figure2.12.Application transform
to identify
theunderlying in timeseries
frequencies
data.
A totally different view of the data can reveal important and interesting fea-
tures. Consider, for example, time series data, which often contains periodic
patterns. If there is only a single periodic pattern and not much noise' then
the pattern is easily detected. If, on the other hand, there are a number of
periodic patterns and a significant amount of noise is present, then these pat-
terns are hard to detect. Such patterns can, nonetheless,often be detected
by applying a Fourier transform to the time seriesin order to change to a
representation in which frequency information is explicit. In the example that
follows, it will not be necessary to know the details of the Fourier transform.
It is enough to know that, for each time series,the Fourier transform produces
a new data object whose attributes are related to frequencies.
Example 2.10 (Fourier Analysis). The time series presented in Figure
2.I2(b) is the sum of three other time series,two of which are shown in Figure
2.12(a) and have frequenciesof 7 and 17 cycles per second, respectively. The
third time series is random noise. Figure 2.12(c) shows the power spectrum
that can be computed after applying a Fourier transform to the original time
series. (Informally, the power spectrum is proportional to the square of each
frequency attribute.) In spite ofthe noise, there are two peaks that correspond
to the periods of the two original, non-noisy time series. Again, the main point
is that better features can reveal important aspects of the data. I
2.3 Data Preprocessing 57
Feature Construction
ofa categorical
Table2.5.Conversion tothreebinaryattributes.
attribute
Catesorical Value Integer Value fi1 Ta
awful 0 0 0 0
poor I 0 0 1
OK 2 0 1 0
good 3 0 1 1
great 4 1 0 0
ofa categorical
Table2.6. Conversion attribute binaryattributes.
tofiveasymmetric
Categorical Value Integer Value :x7 u5 tr4
awtuL 0 1 U 0 0 0
poor I 0 1 0 0 0
OK 2 0 0 1 0 0
good 3 0 0 0 1 0
great 4 0 0 0 0 1
Binarization
k
er:l piilogzpij,
i:l
t :1.
tr.
.ti
i..
.ri
I i..
t r;.
!, .3
s- 3' l. 'l
.;.
! ?r
2.1
10 15 10 15 20
i :-i
i| * ' . . .
I .i.
i .'T
i: i.',i.
:g
| ., '
I ...
!:.
i i,:,
10 15 20
Figure2.13. Different
discretization
techniques.
Categorical attributes can sometimes have too many values. If the categorical
attribute is an ordinal attribute, then techniques similar to those for con-
tinuous attributes can be used to reduce the number of categories. If the
categorical attribute is nominal, however, then other approachesare needed.
Consider a university that has a large number of departments. Consequently,
a department name attribute might have dozens of different values. In this
situation, we could use our knowledge of the relationships among different
departments to combine departments into larger groups, such as eng'ineering,
soc'ialsciences,or biological sc'iences.If domain knowledge does not serve as
a useful guide or such an approach results in poor classification performance,
then it is necessaryto use a more empirical approach, such as grouping values
2.3 Data Preprocessing 63
-----xg -----
::"""*S.;t-
:"-,$
Figure2.14.Discretizing
r andy attributes
forfourgroups
(classes)
of points.
Simple Functions
Normalization or Standardization
2.4.L Basics
Definitions
TYansformations
Table2.7. Similarity
anddissimilarity
forsimple
attributes
Attribute Dissimilarity Similaritv
T'ype
)_ 0 1fr:A I \fr:y
Nominal 11, - s:
I if rly 0 ifnly
d:lr-all("-t)
Ordinal (valuesmapped to integers 0 to n-1 s:I-d
where n is the number of values)
Interval or Ratio d:lr-al s:-d, ' s : ; i ,L t a s:e-o,
^ - 1 d-min-d
-
Distances
We first present some examples, and then offer a more formal description of
distancesin terms of the properties common to all distances. The Euclidean
distance, d, between two points, x and y, in one-, two-, three-, or higher-
dimensional space, is given by the following familiar formula:
n
\-r - a k\)t ' ,
d(*, y) : ) \tn (2.1)
K=l
(, ,\
d(x, y) :
(Lor-orr)''"
where r is a parameter. The following are the three most common examples
of Minkowski distances.
d(*, Y) : (2.3)
J* (U'wr-rrt')"'
The r parameter should not be confused with the number of dimensions (at-
tributes) n. The Euclidean, Manhattan, and supremum distances are defined
for all values of n: I,2,3,..., and specify different ways of combining the
differencesin each dimension (attribute) into an overall distance.
Tables 2.10 and 2.11, respectively, give the proximity matrices for the L1
and Loo distances using data from Table 2.8. Notice that all these distance
matrices are symmetric; i.e., the ijth entry is the same as the jith entry. In
Table 2.9, for instance, the fourth row of the first column and the fourth
column of the first row both contain the value 5.1.
Distances, such as the Euclidean distance, have some well-known proper-
ties. If d(*, y) is the distance between two points, x and y, then the following
properties hold.
1. Positivity
123456
X
Figure
2.15.Four points.
two-dimensional
Table2.10.L1distance
matrix
forTable
2.8. Table
2,11.L- distance
matrix
forTable
2.8.
L1 p1 p2 p3 p4 L- pl p2 p3 p4
pl 0.0 4.0 4.0 6.0 p1 0.0 2.0 3.0 5.0
p2 4.0 0.0 2.0 4.0 p2 2.0 0.0 1 . 0 3.0
p3 4.0 2.0 0.0 2.0 p3 3.0 1.0 0.0 2.0
p4 6.0 4.0 2.0 0.0 p4 5.0 3.0 2.0 0 . 0
2. Symmetry
d(*,Y) : d(Y,x) for all x and Y.
3. T[iangle Inequality
d(x,z) < d(*, y) + d(y, z) for all points x, y,, and z.
Measures that satisfy all three properties are known as metrics. Some
people only use the term distance for dissimilarity measuresthat satisfy these
properties, but that practice is often violated. The three properties described
here are useful, as well as mathematically pleasing. AIso, if the triangle in-
equality holds, then this property can be used to increasethe efficiencyof tech-
niques (including clustering) that depend on distancespossessingthis property.
(SeeExercise 25.) Nonetheless,many dissimilarities do not satisfy one or more
of the metric properties. We give two examples of such measures.
72 Chapter 2 Data
For similarities, the triangle inequality (or the analogous property) typically
does not hold, but symmetry and positivity typically do. To be explicit, if
s(x, y) is the similarity between points x and y, then the typical properties of
similarities are the following:
x : (1,0,0,0,0,0,0,0,0,0)
y : ( 0 , 0 , 0 , 0 , 0 ,10,,0 , 01, )
J:-T-,+----;-:--4-:g
JOI TJ IOTJ I I ZTITU
Cosine Similarity
nored and various processing techniques are used to account for different forms
of the same word, differing document lengths, and different word frequencies.
Even though documents have thousands or tens of thousands of attributes
(terms), each document is sparsesince it has relatively few non-zero attributes.
(The normalizations used for documents do not create a non-zero entry where
there was azero entry; i.e., they preservesparsity.) Thus, as with transaction
data, similarity should not depend on the number of shared 0 values since
any two documents are likely to "not contain" many of the same words, and
therefore, if 0-0 matches are counted, most documents will be highly similar to
most other documents. Therefore, a similarity measure for documents needs
to ignores 0-0 matches like the Jaccard measure, but also must be able to
handle non-binary vectors. The cosine similarity, defined next, is one of the
most common measure of document similarity. If x and y are two document
vectors, then
:
cos(x,y) (, 7\
ffi,
where. indicatesthe vectordot product,x .y : D[:trplp, andllxll is the
lengthof vectorx, ll*ll : 1fD|:rr2r: 1/x4.
Example 2.18 (Cosine Similarity of Two Document Vectors). This
example calculates the cosine similarity for the following two data objects,
which might represent document vectors:
* : ( 3 ,2 , 0 , 5 , 0 , 0 , 0
2, 0,0)
y : ( 1 , 0 , 0 , 0 , 0 , 0 ,10, ,0 , 2 )
x . y : 3 i .1 * 2 x 0 * 0 * 0 * 5 x 0 * 0 x 0 f 0 * 0 * 0 * 0 * 2 * l * 0 x 0 * 0 x 2 : 5
l l x l:l roxo *oxo *2x2*oxo *oxo:6.48
l l y l:l :2.24
cos(x,y) : 0.31
I
Figule
2.16.Geometric
illustration measure.
ofthecosine
where x' : x/llxll and y/ : V lllyll. Dividing x and y by their lengths normal-
izesthem to have a length of 1. This means that cosinesimilarity does not take
the magnitude ofthe two data objects into account when computing similarity.
(Euclidean distance might be a better choice when magnitude is important.)
For vectors with a length of 1, the cosine measurecan be calculated by taking
a simple dot product. Consequently,when many cosine similarities between
objects are being computed, normalizing the objects to have unit length can
reduce the time required.
x.y
EJ(x,y): (2.e)
ll"ll'+llvll'-*.v
Correlation
The correlation between two data objects that have binary or continuous vari-
ables is a measure of the linear relationship between the attributes of the
objects. (The calculation of correlation between attributes, which is more
common, can be defined similarly.) More precisely, Pearson's correlation
2 .4 Measures of Similaritv and Dissimilaritv 77
covariance(x,y) StA
corr(x, y) : (2.10)
standard-deviation(x) xstandard-deviation(y) tr ta'
where we are using the following standard statistical notation and definitions:
1n
: s,s: :+ I("u
covariance(x,y) -z)(yx -9) (2.11)
n- r-. E:L
standard-deviation(x) : su :
fil@n-n)'
standard-deviation(y) : su:
;\l@*-vt'
1fl
i : I)-r*isthemeanofx
n4
k:1
1fl
g : 1fy*isthemeanofy
h:1
x: ( - 3 , 6 , 0 , 3 ,- 6 )
y: ( 1 ,- 2 , 0 , - 7 , 2 )
x: (3,6,0,3,6)
y : (1,2,0,L,2)
I
78 Chapter 2 Data
0.80 1.00
Figure plots
2.17.Scatter illustrating from-1 to1.
correlations
*: (-3, -2,-1, 0, I, 2, 3)
Y:(9, 4,1,0,1,4,9)
I
taking the dot product. Notice that this is not the same as the standardization
used in other contexts, where we make the transformations, r'* : (rp - ,) lt"
and y'r : (A* - T) I sa.
r and y be real numbers and /(t) be the real valued function, d(t) : t2. In
that case, the gradient reduces to the derivative and the dot product reduces
to multiplication. Specifically,Equation 2.L2 becomesEquation 2.13.
-1 01234
x
Figure
2.18.lllustration
ofBregman
divergence.
where E-1 is the inverse of the covariancematrix of the data. Note that the
covariance matrix E is the matrix whose ijth entry is the covariance of the ith
and jth attributes as defined by Equation 2.II.
Example 2.23. In Figure 2.19, there are 1000 points, whose r and g at-
tributes have a correlation of 0.6. The distance between the two large points
at the opposite ends of the long axis of the ellipse is 14.7 in terms of Euclidean
distance, but only 6 with respect to Mahalanobis distance. In practice, com-
puting the Mahalanobis distance is expensive,but can be worthwhile for data
whose attributes are correlated. If the attributes are relatively uncorrelated,
but have different ranges, then standardizing the variables is sufficient.
I
Figure2.19.Setoftwo-dimensionalpoints.
TheMahalanobis
distance thetwopointsrepre-
between
sentedbylargedotsis6;theirEuclidean
distance
is 14.7.
Unfortunately, this approach does not work well if some of the attributes
are asymmetric attributes. For example, if all the attributes are asymmetric
binary attributes, then the similarity measuresuggestedpreviously reducesto
the simple matching coefficient, a measure that is not appropriate for asym-
metric binary attributes. The easiest way to fix this problem is to omit asym-
metric attributes from the similarity calculation when their values are 0 for
both of the objects whose similarity is being computed. A similar approach
also works well for handling missing values.
In summary, Algorithm 2.7 is effective for computing an overall similar-
ity between two objects, x and y, with different types of attributes. This
procedure can be easily modified to work with dissimilarities.
Using Weights
In much of the previous discussion, all attributes were treated equally when
computing proximity. This is not desirable when some attributes are more im-
portant to the definition of proximity than others. To addressthese situations,
2.4 Measuresof Similaritv and Dissimilaritv 83
3: Compute the overall similarity between the two objects using the following for-
mula:
:$ffi
similarity(x,") (2.15)
/ n \1/'
d(x, y) : ( D,'ol"r - akl'I (2.r7)
\t:r /
objects have only a few of the characteristics described by the attributes, and
thus, are highly similar in terms of the characteristics they do not have. The
cosine,Jaccard, and extended Jaccard measuresare appropriate for such data.
There are other characteristics of data vectors that may need to be consid-
ered. Suppose, for example, that we are interested in comparing time series.
If the magnitude of the time seriesis important (for example, each time series
represent total sales of the same organization for a different year), then we
could use Euclidean distance. If the time series represent different quantities
(for example, blood pressureand oxygen consumption), then we usually want
to determine if the time series have the same shape, not the same magnitude.
Correlation, which uses a built-in normalization that accounts for differences
in magnitude and level, would be more appropriate.
In some cases,transformation or normalization of the data is important
for obtaining a proper similarity measure since such transformations are not
always present in proximity measures. For instance, time series may have
trends or periodic patterns that significantly impact similarity. Also, a proper
computation of similarity may require that time lags be taken into account.
Finally, two time seriesmay only be similar over specific periods of time. For
example, there is a strong relationship between temperature and the use of
natural gas, but only during the heating season.
Practical consideration can also be important. Sometimes, a one or more
proximity measuresare already in use in a particular field, and thus, others
will have answered the question of which proximity measures should be used.
Other times, the software package or clustering algorithm being used may
drastically limit the choices. If efficiency is a concern, then we may want to
choosea proximity measure that has a property, such as the triangle inequality,
that can be used to reduce the number of proximity calculations. (SeeExercise
25.)
However, if common practice or practical restrictions do not dictate a
choice,then the proper choiceof a proximity measurecan be a time-consuming
task that requires careful consideration of both domain knowledge and the
purpose for which the measure is being used. A number of different similarity
measures may need to be evaluated to see which ones produce results that
make the most sense.
particular, one of the initial motivations for defining types of attributes was
to be precise about which statistical operations were valid for what sorts of
data. We have presented the view of measurement theory that was initially
described in a classic paper by S. S. Stevens 179]. (Tables 2.2 and 2.3 are
derived from those presentedby Stevens [80].) While this is the most common
view and is reasonably easy to understand and apply, there is, of course,
much more to measurementtheory. An authoritative discussioncan be found
in a three-volume series on the foundations of measurement theory [63, 69,
81]. AIso of interest is a wide-ranging article by Hand [55], which discusses
measurement theory and statistics, and is accompanied by comments from
other researchers in the field. Finally, there are many books and articles that
describe measurement issuesfor particular areas of scienceand engineering.
Data quality is a broad subject that spans every discipline that uses data.
Discussionsof precision, bias, accuracy, and significant figures can be found
in many introductory science,engineering,and statistics textbooks. The view
of data quality as "fitness for use" is explained in more detail in the book by
Redman [76]. Those interested in data quality may also be interested in MIT's
Total Data Quality Management program [70, 84]. However, the knowledge
neededto deal with specific data quality issuesin a particular domain is often
best obtained by investigating the data quality practices of researchersin that
field.
Aggregation is a less well-defined subject than many other preprocessing
tasks. However, aggregationis one of the main techniquesused by the database
area of Online Analytical Processing(OLAP), which is discussedin Chapter 3.
There has also been relevant work in the area of symbolic data analysis (Bock
and Diday [a7]). One of the goals in this area is to summarize traditional record
data in terms of symbolic data objects whose attributes are more complex than
traditional attributes. Specifically, these attributes can have values that are
setsof values (categories),intervals, or sets of valueswith weights (histograms).
Another goal of symbolic data analysis is to be able to perform clustering,
classification,and other kinds of data analysis on data that consistsof symbolic
data objects.
Sampling is a subject that has been well studied in statistics and related
fields. Many introductory statistics books, such as the one by Lindgren [65],
have some discussionon sampling, and there are entire books devoted to the
subject, such as the classic text by Cochran [49]. A survey of sampling for
data mining is provided by Gu and Liu [54], while a survey of sampling for
databases is provided by Olken and Rotem [ZZ]. There are a number of other
data mining and database-related sampling referencesthat may be of interest,
86 Chapter 2 Data
including papers by Palmer and Faloutsos [74], Provost et al. [75], Toivonen
[82],and Zakiet al. [85].
In statistics, the traditional techniques that have been used for dimension-
ality reduction are multidimensional scaling (MDS) (Borg and Groenen [48],
Kruskal and Uslaner [6a]) and principal component analysis (PCA) (Jolliffe
[58]), which is similar to singular value decomposition (SVD) (Demmel [50]).
Dimensionality reduction is discussedin more detail in Appendix B.
Discretization is a topic that has been extensively investigated in data
mining. Some classification algorithms only work with categorical data, and
association analysis requires binary data, and thus, there is a significant moti-
vation to investigate how to best binarize or discretize continuous attributes.
For association analysis, we refer the reader to work by Srikant and Agrawal
[78], while some useful referencesfor discretization in the area of classification
include work by Dougherty et al. [51], Elomaa and Rousu [SZ], Fayyad and
Irani [53], and Hussain et al. [56].
Feature selectionis another topic well investigated in data mining. A broad
coverageof this topic is provided in a survey by Molina et al. [71] and two
books by Liu and Motada [66, 67]. Other useful paperc include those by Blum
and Langley 1461,Kohavi and John [62], and Liu et al. [68].
It is difficult to provide referencesfor the subject of feature transformations
becausepractices vary from one discipline to another. Many statistics books
have a discussionof transformations, but typically the discussionis restricted
to a particular purpose, such as ensuring the normality of a variable or making
sure that variables have equal variance. We offer two references: Osborne [73]
and Ttrkey [83].
While we have covered some of the most commonly used distance and
similarity measures,there are hundreds of such measuresand more are being
created all the time. As with so many other topics in this chapter, many of
these measuresare specificto particular fields; e.g., in the area of time seriessee
papers by Kalpakis et al. [59] and Keogh and Pazzani [61]. Clustering books
provide the best general discussions.In particular, seethe books by Anderberg
[45], Jain and Dubes [57], Kaufman and Rousseeuw[00], and Sneath and Sokal
1771.
Bibliography
[45] M. R. Anderberg. Cluster Analysis for Appli,cati,ons. Academic Press, New York, De-
cember 1973.
[461A. BIum and P. Langley. Selection of Relevant Features and Examples in Machine
Learning. Artificial Intellig ence, 97 (l=2) :245-27 l, 1997.
Bibliography 87
l47l H. H. Bock and E. Diday. Analysis of Sgmbolic Data: Exploratory Methods for Ertract-
ing Statistical Information from Complen Data (Studi,es in Classifi,cation, Data Analys'is,
and, Know ledge Org an'izat'ionl. Springer-Verlag Telos, January 2000.
[48] I. Borg and P. Groenen. Modern Multidimensional Scaling Theory and, Applications.
Springer-Verlag, February 1997.
[49] W. G. Cochran. Sampling Techniques. John Wiley & Sons, 3rd edition, JuJy 1977.
[50] J. W. Demmel. Applied, Numerical Linear Algebra. Society for Industrial & Applied
Mathematics, September 1997.
[51] J. Dougherty, R. Kohavi, and M. Sahami. Supervised and Unsupervised Discretization
of Continuous Features. In Proc. of the 12th Intl. Conf. on Machine Learni,ng, pages
L94-202, t995.
[52] T. Elomaa and J. Rousu. General and Efficient Multisplitting of Numerical Attributes.
M achine Learni,ng,36(3):201 244, 1999.
[53] U. M. Fayyad and K. B. Irani. Multi-interval discretization of continuousvalued at-
tributes for classification learning. In Proc. 13th Int. Joint Conf. on Arti;fi,cial Intelli,-
gence, pages lO22-L027. Morgan Kaufman, 1993.
154] F. H. Gaohua Gu and H. Liu. Sampling and Its Application in Data Mining: A Survey.
Technical Report TRA6/00, National University of Singapore, Singapore, 2000.
f55] D. J. Hand. Statistics and the Theory of Measurement. Jountal of the Rogal Statistical
Societg: Series A (Statistics in Societg),159(3):445-492, 1996.
[56] F. Hussain, H. Liu, C. L. Tan, and M. Dash. TRC6/99: Discretization: an enabling
technique. Technical report, National University of Singapore, Singapore, 1999.
[57j A. K. Jain and R. C. Dubes. Algorithrns for Clustering Data. Prentice Hall
Advanced Reference Series. Prentice Hall, March 1988. Book available online at
http: //www.cse.msu.edu/-jain/Clustering-Jain-Dubes.pdf.
[58] I. T. Jolliffe. Principal Cornponent Analys'is. Springer Verlag, 2nd edition, October
2002.
[59] K. Kalpakis, D. Gada, and V. Puttagunta. Distance Measures for Effective Clustering
of ARIMA Time-Series. In Proc. of the 2001 IEEE Intl. Conf. on Data Mini'ng, pages
273-280. IEEE Computer Society, 2001.
[60] L. Kaufman and P. J. Rousseeuw. Findi,ng Groups in Data: An Introduction to Cluster
Analysi.s. Wiley Series in Probability and Statistics. John Wiley and Sons, New York,
November 1990.
[61] E. J. Keogh and M. J. Pazzani. Scaling up dynamic time warping for datamining
applications. In KDD, pages 285-289, 2000.
[62] R. Kohavi and G. H. John. Wrappers for Feature Subset Selection. Artificial Intell'igence,
97 {I-2) :273-324, 1997.
f63] D. Krantz, R. D. Luce, P. Suppes, and A. Tversky. Foundations of Measurements:
Volume 1: Additiue and polgnomial representations. Academic Press, New York, 1971.
[64] J. B. Kruskal and E. M. Uslaner. Multiilimensional Scal'ing. Sage Publications, August
1978.
[65] B. W. Lindgren. Statistical Theory CRC Press, January 1993.
f66] H. Liu and H. Motoda, editors. Feature Ertract'ion, Constr-uction and Select'ion: A Data
Mini,ng Perspectiue. Kluwer International Series in Engineering and Computer Science,
453. Kluwer Academic Publishers, July 1998.
[67] H. Liu and H. Motoda. Feature Selection for Knowleilge Discouery and Data Mi'n-
ing. Kluwer International Series in Engineering and Computer Science, 454. Kluwer
Academic Publishers. Julv 1998.
88 Chapter 2 Data
168] H. Liu, H. Motoda, and L. Yu. Feature Extraction, Selection, and Construction. In
N. Ye, editor, The Handbook of Data Mi,ning, pages22 41. Lawrence Erlbaum Asso-
ciates, Inc., Mahwah, NJ, 2003.
[69] R. D. Luce, D. Krantz, P. Suppes, and A. Tversky. Foundat'ions of Measurements:
Volume 3: Representation, Ariomatizati,on, and Inuariance. Academic Press, New York,
1990.
[70] MIT Total Data Quality Management Program. web.mit.edu/tdqm/www/index.shtml,
2003.
171] L. C. Molina, L. Belanche, and A. Nebot. Feature Selection Algorithms: A Survey and
Experimental Evaluation. ln Proc. of the 2002 IEEE Intl. Conf. on Data M'ining,2OO2.
1721 F. Olken and D. Rotem. Random Sampling from Databases-A Survey. Stati,stics I
Comput'ing, 5(l) :25-42, March 1995.
[73] J. Osborne. Notes on the Use of Data TYansformations. Practical Assessment, Research
€i Eualuation, 28(6), 2002.
l74l C R. Palmer and C. Faloutsos. Density biased sampling: An improved method for data
mining and clusterin g. AC M SI G M O D Record, 29(2) :82-92, 2000.
[75] F. J. Provost, D. Jensen, and T. Oates. Efficient Progressive Sampling. In Proc. of the
5th IntI. Conf. on Knowled,ge Discouery and, Data Mining, pages 23-32, 1999.
[76] T. C. Redman. Data Qualitg: The Field Gui.d,e.Digital Press, January 2001.
l77l P H. A. Sneath and R. R. Sokal. Numerical Taronomy. FYeeman,San Francisco, 1971.
[78] R. Srikant and R. Agrawal. Mining Quantitative Association Rules in Large Relational
Tables. In Proc. of 1996 ACM-SIGMOD Intl. Conf. on Management of Data, pages
1-12, Montreal, Quebec, Canada, August 1996.
[79] S. S. Stevens. On the Theory of Scales of Measurement. Science, 103(2684):677-680,
June 1946.
[80] S. S. Stevens. Measurement. In G. M. Maranell, editor, Scali,ng: A Sourceboolefor
Behauioral Scientists, pages 22-4L Aldine Publishing Co., Chicago, 1974.
f81] P. Suppes, D. Krantz, R. D. Luce, and A. Tversky. Found,at'ionsof Measurements:
Volume 2: Geometrical, Threshold, and Probab'ilistic Representations. Academic Press,
New York, 1989.
f82] H. Toivonen. Sampling Large Databases for Association Rules. In VLDB96, pages
L34-I45. Morgan Kaufman, September 1996.
[83] J. W. Tukey. On the Comparative Anatomy of TYansformations. Annals of Mathematical
Stat'istics, 28(3):602-632, September 1957.
f84] R. Y. Wang, M. Ziad, Y. W. Lee, and Y. R. Wang. Data Quali,ty. The Kluwer In-
ternational Series on Advances in Database Systems, Volume 23. Kluwer Academic
Publishers, January 2001.
[85] M. J. Zaki, S. Parthasarathy, W. Li, and M. Ogihara. Evaluation of Sampling for Data
Mining of Association Rules. Technical Report TR617, Renssela,erPolytechnic Institute,
1996.
2.6 Exercises
1. In the initial example of Chapter 2, the statistician says, ((Yes,fields 2 and 3
are basically the same." Can you tell from the three lines of sample data that
are shown why she says that?
2.6 Exercises 89
0) Military rank.
(k) Distance from the center of campus.
(l) Density of a substance in grams per cubic centimeter.
(-) Coat check number. (When you attend an event, you can often give your
coat to someone who, in turn, gives you a number that you can use to
claim your coat when you leave.)
3. You are approached by the marketing director of a local company, who believes
that he has devised a foolproof way to measure customer satisfaction' He
explains his scheme as follows: "It's so simple that I can't believe that no one
has thought of it before. I just keep track of the number of customer complaints
for each product. I read in a data mining book that counts are ratio attributes,
and so, my measure of product satisfaction must be a ratio attribute. But
when I rated the products based on my new customer satisfaction measure and
showed them to my boss, he told me that I had overlooked the obvious, and
that my measure was worthless. I think that he was just mad because our best-
selling product had the worst satisfaction since it had the most complaints.
Could you help me set him straight?"
(a) Who is right, the marketing director or his boss? If you answered, his
boss, what would you do to fix the meaaure of satisfaction?
(b) What can you say about the attribute type of the original product satis-
faction attribute?
90 Chapter 2 Data
I
A few months later, you are again approached by the same marketing director
as in Exercise 3. This time, he has devised a better approach to measure the
extent to which a customer prefers one product over other, similar products. He
explains, "When we develop new products, we typically create several variations
and evaluate which one customers prefer. Our standard procedure is to give
our test subjects all ofthe product variations at one time and then ask them to
rank the product variations in order of preference. However, our test subjects
are very indecisive, especially when there are more than two products. As a
result, testing takes forever. I suggested that we perform the comparisons in
pairs and then use these comparisons to get the rankings. Thus, if we have
three product variations, we have the customers compare variations I and 2,
then 2 and 3, and finally 3 and 1. Our testing time with my new procedure
is a third of what it was for the old procedure, but the employees conducting
the tests complain that they cannot come up with a consistent ranking from
the results. And my boss wants the latest product evaluations, yesterday. I
should also mention that he was the person who came up with the old product
evaluation approach. Can you help me?"
(a) Is the marketing director in trouble? Will his approach work for gener-
ating an ordinal ranking of the product variations in terms of customer
preference? Explain.
(b) Is there a way to fix the marketing director's approach? More generally,
what can you say about trying to create an ordinal measurement scale
based on pairwise comparisons?
(c) For the original product evaluation scheme, the overall rankings of each
product variation are found by computing its average over all test subjects.
Comment on whether you think that this is a reasonable approach. What
other approaches might you take?
(a) How would you convert this data into a form suitable for association
analysis?
(b) In particular, what type of attributes would you have and how many of
them are there?
9 . Many sciences rely on observation instead of (or in addition to) designed ex-
periments. Compare the data quality issues involved in observational science
with those of experimental science and data mining.
10.Discuss the difference between the precision of a measurement and the terms
single and double precision, as they are used in computer science, typically to
represent floating-point numbers that require 32 and 64 bits, respectively.
1 1 . Give at least two advantages to working with data stored in text files instead
of in a binary format.
12. Distinguish between noise and outliers. Be sure to consider the following ques-
tions.
13. Consider the problem of finding the K nearest neighbors of a data object. A
programmer designs Algorithm 2.2 for this task.
(u) Describe the potential problems with this algorithm if there are duplicate
objects in the data set. Assume the distance function will only return a
distance of 0 for objects that are the same.
(b) How would you fix this problem?
14. The following attributes are measured for members of a herd of Asian ele-
phants: wei,ght, hei,ght, tusk length, trunk length, and ear area. Based on these
measurements, what sort of similarity mea"surefrom Section 2.4 would you use
to compare or group these elephants? Justify your answer and explain any
special circumstances.
92 Chapter 2 Data
1 5 . You are given a set of rn objects that is divided into K groups, where the ith
group is of size mi. If. the goal is to obtain a sample of size fl I ffi, what is
the difference between the following two sampling schemes? (Assume sampling
with replacement.)
16. Consider a document-term matrix, where tfii isthe frequency of the rith word
(term) in the jth document and m is the number of documents. Consider the
variable transformation that is defined by
tf'ti:tfti*nsffi, (2.18)
where dfi is the number of documents in which the i.th term appears, which
is known as the document frequency of the term. This transformation is
known as the inverse document frequency transformation.
(a) What is the effect of this transformation if a term occurs in one document?
In every document?
(b) What might be the purpose of this transformation?
18. This exercise compares and contrasts some similarity and distance measures.
(a) For binary data, the Ll distance corresponds to the Hamming distance;
that is, the number of bits that are different between two binary vectors.
The Jaccard similarity is a measure of the similarity between two bina,ry
vectors. Compute the Hamming distance and the Jaccard similarity be-
tween the following two binary vectors.
x: 0101010001
y : 0100011000
(c) Suppose that you are comparing how similar two organisms of different
species are in terms of the number of genes they share. Describe which
measure, Hamming or Jaccard, you think would be more appropriate for
comparing the genetic makeup of two organisms. Explain. (Assume that
each animal is represented as a binary vector, where each attribute is 1 if
a particular gene is present in the organism and 0 otherwise.)
(d) If you wanted to compare the genetic makeup of two organisms of the same
species, e.g., two human beings, would you use the Hamming distance,
the Jaccard coefficient, or a different measure of similarity or distance?
Explain. (Note that two human beings share > 99.9% of the same genes.)
1 9 . For the following vectors, x and y, calculate the indicated similarity or distance
measures.
1.4 1.4
1.2 1.2
o o
o 1 1
q
o
o 0.8 o 0.8
c
G 0.6 (5 0.6
o o
o.4 o 0.4
l,rJ I.JJ
o.2 o.2
CosineSimilarity Correlation
Figure
2.20.Graphs
forExercise
20.
satisfies the metric axioms given on page 70. ,4. and B are sets and A - B is
the set difference.
22. Discuss how you might map correlation values from the interval l-1,1] to the
interval [0,1]. Note that the type of transformation that you use might depend
on the application that you have in mind. Thus, consider two applications:
clustering time series and predicting the behavior of one time series given an-
other.
23. Given a similarity measure with values in the interval [0,1] describe two ways to
transform this similarity value into a dissimilarity value in the interval l0,oo].
,A Proximity is typically defined between a pair of objects.
(a) Define two ways in which you might define the proximity among a group
of objects.
(b) How might you define the distance between two sets of points in Euclidean
space?
(c) How might you define the proximity between two sets of data objects?
(Make no assumption about the data objects, except that a proximity
measure is defined between any pair of objects.)
25. You are given a set of points ,9 in Euclidean space, as well as the distance of
each point in ,S to a point x. (It does not matter if x e S.)
2.6, Exercises 95
(a) If the goal is to find all points within a specified distance e of point y,
y * x, explain how you could use the triangle inequality and the already
calculated distances to x to potentially reduce the number of distance
calculations necessary?Hint: The triangle inequality, d(x,z) < d(x,y)*
d(y,*), can be rewritten as d(x,y) 2 d(x, z) - d(y,z).
(b) In general, how would the distance between x and y affect the number of
distance calculations?
(c) Suppose that you can find a small subset of points ,5', from the original
data set, such that every point in the data set is within a specified distance
e of at least one of the points in ^91and that you also have the pairwise
distance matrix for 51 Describe a technique that uses this information to
compute, with a minimum of distance calculations, the set of all points
within a distance of B of a specified point from the data set.
26. Show that 1 minus the Jaccard similarity is a distance measure between two data
objects, x and y, that satisfies the metric axioms given on page 70. Specifically,
d(*,y) : 1- J(x,y).
27. Show that the distance measure defined as the angle between two data vectors,
x and y, satisfies the metric axioms given on page 70. Specifically, d(*, y) :
arccos(cos(x,y)).
,9, Explain why computing the proximity between two attributes is often simpler
than computing the similarity between two objects.
ExploringData
The previous chapter addressed high-level data issues that are important in
the knowledge discovery process. This chapter provides an introduction to
data exploration, which is a preliminary investigation of the data in order
to better understand its specific characteristics. Data exploration can aid in
selecting the appropriate preprocessing and data analysis techniques. It can
even address some of the questions typically answered by data mining. For
example, patterns can sometimes be found by visually inspecting the data.
Also, some of the techniques used in data exploration, such as visualization,
can be used to understand and interpret data mining results.
This chapter covers three major topics: summary statistics, visualization,
and On-Line Analytical Processing (OLAP). Summary statistics, such as the
mean and standard deviation of a set of values, and visualization techniques,
such as histograms and scatter plots, are standard methods that are widely
employed for data exploration. OLAP, which is a more recent development,
consists of a set of techniques for exploring multidimensional arrays of values.
OlAP-related analysis functions focus on various ways to create summary
data tables from a multidimensional data array. These techniques include
aggregating data either across various dimensions or across various attribute
values. For instance, if we are given sales information reported according
to product, location, and date, OLAP techniques can be used to create a
summary that describes the sales activity at a particular location by month
and product category.
The topics covered in this chapter have considerable overlap with the area
known as Exploratory Data Analysis (EDA), which was created in the
1970s by the prominent statistician, John Tirkey. This chapter, like EDA,
places a heavy emphasis on visualization. Unlike EDA, this chapter does not
include topics such as cluster analysis or anomaly detection. There are two
98 Chapter 3 Exploring Data
reasonsfor this. First, data mining views descriptive data analysis techniques
as an end in themselves,whereasstatistics, from which EDA originated, tends
to view hypothesis-basedtesting as the final goal. Second, cluster analysis
and anomaly detection are large areas and require full chapters for an in-
depth discussion. Hence, cluster analysis is coveredin Chapters 8 and 9, while
anomaly detection is discussedin Chapter 10.
The sepals of a flower are the outer structures that protect the more fragile
parts of the flower, such as the petals. In many flowers, the sepals are green,
and only the petals are colorful. For Irises, however, the sepals are also colorful.
As illustrated by the picture of a Virginica Iris in Figure 3.1, the sepals of an
Iris are larger than the petals and are drooping, while the petals are upright.
Figure3.1. Picture
of lrisVirginica.
RobertH. Mohlenbrock@ USDA-NRCS PLANTS Database/
USDANRCS.1995.Northeast wetland guide
flora:Fieldoffice to plant
species.
Northeast
National
Technical
Center,
Chester,PA.Background removed.
Given a set of unordered categorical values, there is not much that can be done
to further characterize the values except to compute the frequency with which
each value occurs for a particular set of data. Given a categorical attribute r,
which can take values {rt,. . . ,1ri,. .. u7r}and a set of rn objects, the frequency
of a value u; is defined as
The mode of a categorical attribute is the value that has the highest frequency.
100 Chapter 3 Exploring Data
Table sizeforstudents
3.1.Class ina hypothetical
college.
Class Size FYequency
freshman t40 0.33
sophomore 160 0.27
junior 130 0.22
senior 170 0.18
Categorical attributes often, but not always, have a small number of values,
and consequently, the mode and frequencies of these values can be interesting
and useful. Notice, though, that for the Iris data set and the class attribute,
the three types of flower all have the same frequency, and therefore, the notion
of a mode is not interesting.
For continuous data, the mode, as currently defined, is often not useful
becausea single value may not occur more than once. Nonetheless,in some
cases,the mode may indicate important information about the nature of the
values or the presenceof missing values. For example, the heights of 20 people
measuredto the nearest millimeter will typically not repeat, but if the heights
are measured to the nearest tenth of a meter, then some people may have the
same height. Also, if a unique value is used to indicate a missing value, then
this value will often show up as the mode.
3.2.2 Percentiles
Table3.2. Percentiles
forsepal
length,
sepal petallength,
width, andpetalwidth.(Allvalues
arein
centimeters.)
Percentile Sepal Length Sepal Width Petal Length Petal Width
0 4.3 2.0 1.0 0.1
10 4.8 2.5 t.4 0.2
20 5.0 2.7 r.o 0.2
30 5.2 2.8 t.7 0.4
40 D.r) 3.0 3.9 7.2
50 5.8 3.0 4.4 1.3
60 6.1 3.1 4.6 -t.l)
70 6.3 3.2 5.0 1.8
80 6.6 3.4 o.4 1.9
90 6.9 3.6 c.6 2.2
100 7.9 4.4 6.9 2.5
For continuous data, two of the most widely used summary statistics are the
mean and median, which are measures of the locati,on of a set of values.
Considera set of nl objects and an attribute r. Let {r1,...,r^) be the
attribute values of r for these zn objects. As a concrete example, these values
might be the heights of rn children. Let {rg1,...,:xOd} representthe values
of z after they have been sorted in non-decreasingorder. Thus, ro): min(z)
and r1*1: max(r). Then, the mean and median are defined as follows:
* ^e^ a- /n- (\ r ) : I := I
m \-..
*L*' (3.2)
m,
_ ^r:^- / \ :
meoran(r/ f *,r*rl i f r n i s o d d , i . e . ,r n : 2 r * |
(3.3)
1 !.'i*,' * r 1 " + r 1 ) i f r n i s e v e n ,i ' e ' , m : 2 r
\ 2\*(r)
To summarize, the median is the middle value if there are an odd number
of values, and the average of the two middle values if the number of values
is even. Thus, for seven values, the median is 1141,while for ten values, the
median is |(r15; + rfol).
LO2 Chapter 3 Exploring Data
Example 3.4. The means, medians, and trimmed means (p : 20%) of the
four quantitative attributes of the Iris data are given in Table 3.3. The three
measuresof location have similar values except for the attribute petal length.
andmedians
Table3.3. Means forsepallength, andpetalwidth.(Allvalues
sepalwidth,petallength,
areincentimeters.)
Measure Sepal Length Sepal Width Petal Length Petal Width
mean 5.84 3.05 3.76 I 20
median 5.80 3.00 4.35 1.30
trimmed mean (20To) 5. (9 3.02 3.72 r.72
Another set of commonly used summary statistics for continuous data are
those that measure the dispersion or spread of a set of values. Such measures
indicate if the attribute values are widely spread out or if they are relatively
concentrated around a single point such as the mean.
The simplest measure of spread is the range, which, given an attribute r
with a set of rn values {rr, . . . , r*}, is defined as
Table3.4.Range,
standard (std),
deviation absolute
average (AAD),
difference median
absolute
difier-
ence(MAD),andinterquartile
range (lQR)forsepal
length,
sepal petallength,
width, andpetal
width.
(Allvalues
areincentimeters.)
Measure Sepal Length Sepal Width Petal Length Petal Width
range 3.6 ,A 5.9 ,A
1m
variance(z)- s7: --- \-(2, - z)2 (3.5)
m,-lz-/''
The mean can be distorted by outliers, and since the variance is computed
using the mean, it is also sensitive to outliers. Indeed, the variance is particu-
larly sensitive to outliers since it uses the squared difference between the mean
and other values. As a result, more robust estimates of the spread of a set
of values are often used. Following are the definitions of three such measures:
the absolute average deviation (AAD), the median absolute deviation
(MAD), and the interquartile range(IQR). Table 3.4 shows these measures
for the Iris data set.
1ffi
AAD(z):'tl*i-nl (3.6)
m-
(3.e)
1
r \n-
covariance(ri, r j) ., - ri)\rki - ri), (3.11)
v 2 - \ z - t l\rnt.
K:1
where rpi arrd,rkj arethe values of the ith andj'h attributes for the kth object.
Notice that covariance(r6,rt) : variance(r1). Thus, the covariancematrix has
the variances of the attributes along the diagonal.
The covariance of two attributes is a measure of the degree to which two
attributes vary together and depends on the magnitudes of the variables. A
value near 0 indicates that two attributes do not have a (linear) relationship,
but it is not possible to judge the degree of relationship between two variables
by looking only at the value of the covariance. Because the correlation of two
attributes immediately gives an indication of how strongly two attributes are
(linearly) related, correlation is preferred to covariance for data exploration.
(AIso see the discussionof correlation in Section 2.4.5.) The ijth entry of the
correlation matrix R, is the correlation between I'he ith and jth attributes
of the data. If rt arrd.rj are the i,th and jth attributes, then
,j) : **Xy-f,
ri.j : corcelntion(r6, (3.12)
3.3 Visualization 105
where s2 and sy are the variances of r; and rjj respectively. The diagonal
entries of R are correlation(u,rt): 1, while the other entries are between
-1 and 1. It is also useful to consider correlation matrices that contain
the
pairwise correlations of objects instead of attributes.
3.3 Visualization
Data visualization is the display of information in a graphic or tabular format.
Successfulvisualization requires that the data (information) be converted into
a visual format so that the characteristics of the data and the relationships
among data items or attributes can be analyzed or reported. The goal of
visualization is the interpretation of the visualized information by a person
and the formation of a mental model of the information.
In everyday life, visual techniques such as graphs and tables are often the
preferred approach used to explain the weather, the economy, and the results
of political elections. Likewise, while algorithmic or mathematical approaches
are often emphasized in most technical disciplines-data mining included-
visual techniques can play a key role in data analysis. In fact, sometimes the
use of visualization techniques in data mining is referred to as visual data
mining.
15
10
Temp
Longitude
(SST)forJuly,1982.
Temperature
Figure3,2. SeaSurface
is easy to see that the ocean temperature is highest at the equator and lowest
at the poles.
Another general motivation for visualization is to make use of the domain
knowledge that is "locked up in people's heads." While the use of domain
knowledgeis an important task in data mining, it is often difficult or impossible
to fully utilize such knowledgein statistical or algorithmic tools. In some cases,
an analysis can be performed using non-visual tools, and then the results
presentedvisually for evaluation by the domain expert. In other cases,having
a domain specialist examine visualizations of the data may be the best way
of finding patterns of interest since, by using domain knowledge, a person can
often quickly eliminate many uninteresting patterns and direct the focus to
the patterns that are important.
relative positions of the objects. Likewise, if there are two or three continuous
attributes that are taken as the coordinates ofthe data points, then the result-
ing plot often gives considerable insight into the relationships of the attributes
and the data points becausedata points that are visually close to each other
have similar values for their attributes.
In general, it is difficult to ensure that a mapping of objects and attributes
will result in the relationships being mapped to easily observed relationships
among graphical elements. Indeed, this is one of the most challenging aspects
of visualization. In any given set of data, there are many implicit relationships,
and hence, a key challenge of visualization is to choose a technique that makes
the relationships of interest easily observable.
Arrangement
(rows)
Table3.5, A tableof nineobjects with (rows)
Table3.6.Atableofnineobjects withsix
sixbinary (columns).
attributes binaryattributes permuted
(columns) sothatthe
oftherowsandcolumns
relationships areclear.
r23456 613254
1 010110 4 11100
2 101001 2 11100 0
J 010110 6 11100 0
4 101001 8 11100 0
5 010110 r
00011 1
o 101001 3 00011 I
,7
010110 9 00011 1
8 101001 1 00011 1
q
010110 7 00011 I
3.3 Visualization 109
Selection
3.3.3 Techniques
Visualization techniques are often specialized to the type of data being ana-
lyzed. Indeed, new visualization techniques and approaches, as well as special-
ized variations ofexisting approaches,are being continuously created, typically
in responseto new kinds of data and visualization tasks.
Despite this specialization and the ad hoc nature of visualization, there are
some generic ways to classify visualization techniques. One such classification
is based on the number of attributes involved (1,2,3, or many) or whether the
data has some special characteristic, such as a hierarchical or graph structure.
Visualization methods can also be classifiedaccording to the type of attributes
involved. Yet another classification is based on the type of application: scien-
tific, statistical, or information visualization. The following discussionwill use
three categories: visualization of a small number of attributes, visualization of
data with spatial andf or temporal attributes, and visualization of data with
many attributes.
Most of the visualization techniques discussed here can be found in a wide
variety of mathematical and statistical packages, some of which are freely
available. There are also a number of data sets that are freely available on the
World Wide Web. Readers are encouraged to try these visualization techniques
as they proceed through the following sections.
3.3 Visualization 111
Stem and Leaf Plots Stem and leaf plots can be used to provide insight
into the distribution of one-dimensional integer or continuous data. (We will
assumeinteger data initially, and then explain how stem and leaf plots can be
applied to continuous data.) For the simplest type of stem and leaf plot, we
split the values into groups, where each group contains those values that are
the same except for the last digit. Each group becomesa stem, while the last
digits of a group are the leaves. Hence, if the values are two-digit integers,
e.g., 35, 36, 42, and 51, then the stems will be the high-order digits, e.g., 3,
4, and 5, while the leaves are the low-order digits, e.g., 1, 2, 5, and 6. By
plotting the stems vertically and leaves horizontally, we can provide a visual
representation of the distribution of the data.
Example 3.7. The set of integers shown in Figure 3.4 is the sepal length in
centimeters (multiplied by 10 to make the values integers) taken from the Iris
data set. For convenience,the values have also been sorted.
The stem and leaf plot for this data is shown in Figure 3.5. Each number in
Figure 3.4 is first put into one of the vertical groups-4, 5, 6, or 7-according
to its ten's digit. Its last digit is then placed to the right of the colon. Often,
especially if the amount of data is larger, it is desirable to split the stems.
For example, instead of placing all values whose ten's digit is 4 in the same
"bucket," the stem 4 is repeated twice; all values 40-44 are put in the bucket
corresponding to the first stem and all values 45-49 are put in the bucket
corresponding to the second stem. This approach is shown in the stem and
leaf plot of Figure 3.6. Other variations are also possible. I
Histograms Stem and leaf plots are a type of histogram, a plot that dis-
plays the distribution of values for attributes by dividing the possible values
into bins and showing the number of objects that fall into each bin. For cate-
gorical data, each value is a bin. If this results in too many values, then values
are combined in some way. For continuous attributes, the range of values is di-
vided into bins-typically, but not necessarily, of equal width-and the values
in each bin are counted.
LL2 Chapter 3 Exploring Data
43 44 44 44 45 46 46 46 46 47 47 48 48 48 48 48 49 49 49 49 49 49 50
50 50 50 50 50 50 50 50 50 51 51 51 51 51 51 51 51 51 52 52 52 52 53
54 54 54 54 54 54 55 55 55 55 55 55 55 56 56 56 56 56 56 57 57 57 57
57 57 57 57 58 58 58 58 58 58 58 59 59 59 60 60 60 60 60 60 61 61 61
61 61 61 62 62 62 62 63 63 63 63 63 63 63 63 63 64 64 64 64 64 64 64
65 65 65 65 65 66 66 67 67 67 67 67 67 67 67 68 68 68 69 69 69 69 70
7t 72 72 72 73 74 76 77 77 77 77 79
Figure datafromthelrisdataset.
length
3.4.Sepal
34444566667788888999999
0000000000Lt t l1tfl L222234444445555555666 66677 7 7 77 7 78888888999
A 000000 11 1 1 t1222233333333344444445555566777 77777 8889999
0t22234677779
Figure andleafplotforthesepal
3.5.Stem length
fromthelrisdataset.
3444
4: 566667788888999999
tr. 000000000011 1 111 1 1 122223444++4
tr. 555555566666677 777 7778888888999
A 000000 1 1 11 t t22223333333334444444
A 5 5 5 556 677 777 7 77 8889999
7. 0122234
677779
Figure3.6. Stemandleafplotforthesepallength
fromthelrisdatasetwhenbuckets
conesponding
todigitsaresplit.
Once the counts are available for each bin, a bar plot is constructed such
that each bin is representedby one bar and the area of each bar is proportional
to the number of values (objects) that fall into the corresponding range. If all
intervals are of equal width, then all bars are the same width and the height
of a bar is proportional to the number of values in the corresponding bin.
Exarnple 3.8. Figure 3.7 shows histograms (with 10 bins) for sepal length,
sepal width, petal length, and petal width. Since the shape of a histogram
can depend on the number of bins, histograms for the same data, but with 20
bins, are shown in Figure 3.8. I
(a) Sepal length. (b) Sepal width. (c) Petal length (d) Petal width.
Figure
3.7.Histograms (10bins).
offourlrisattributes
) 05 I 15 2
Petwnh
(a) Sepal length. (b) Sepal width. (c) Petal length. (d) Petal width.
change in scale of the g axis, and the shape of the histogram does not change.
Another common variation, especially for unordered categorical data, is the
Pareto histogram, which is the same as a normal histogram except that the
categories are sorted by count so that the count is decreasing from left to right.
Figure3.9.Two-dimensional of petallength
histogram andwidthinthelrisdataset.
Box Plots Box plots are another method for showing the distribution of the
values of a single numerical attribute. Figure 3.10 shows a labeled box plot for
sepal length. The lower and upper ends of the box indicate the 25th and 75th
percentiles,respectively,while the line inside the box indicates the value of the
50th percentile. The top and bottom lines of the tails indicate the 10'h and
90th percentiles. Outliers are shown by "+" marks. Box plots are relatively
compact, and thus, many of them can be shown on the same plot. Simplified
versions of the box plot, which take less space,can also be used.
Example 3.1-0. The box plots for the first four attributes of the Iris data
set are shown in Figure 3.11. Box plots can also be used to compare how
attributes vary between different classesof objects, as shown in Figure 3.12.
T
Pie Chart A pie chart is similar to a histogram, but is typically used with
categorical attributes that have a relatively small number of values. Instead of
showing the relative frequency of different values with the area or height of a
bar, as in a histogram, a pie chart usesthe relative area of a circle to indicate
relative frequency. Although pie charts are common in popular articles, they
3.3 Visualization 115
<- Outlier
<- 90thpercentile
g
o
o
<- 75rhpercentile E
o
<-- sOthpercentile o
<_ 25rhpercentile d
<- 1Othpercentile
Figure3.10. Description
of 3,11.Boxplotforlrisattributes.
Figure
boxplotforsepal
length,
=
LJ
l-
widh M L€ngth &lwidh Spalkngih Sepalwdlh told Length Peblwidh S6pal bngth S€palwdh bd bngth &l Wfr
3.12.Boxplots
Figure bylrisspecies.
ofattributes
are used less frequently in technical publications because the size of relative
areas can be hard to judge. Histograms are preferred for technical work.
Example 3.11. Figure 3.13 displays a pie chart that shows the distribution
of Iris speciesin the Iris data set. In this case, all three flower types have the
same freouencv. r
Versicolour
ofthetypesof lrisflowers.
Figure3.13.Distribution
the probability that a point is lessthan that value. For each observedvalue, an
empirical cumulative distribution function (ECDF) shows the fraction
of points that are less than this value. Since the number of points is finite, the
empirical cumulative distribution function is a step function.
Example 3.12. Figure 3.14 shows the ECDFs of the Iris attributes. The
percentiles of an attribute provide similar information. Figure 3.15 shows the
percentile plots of the four continuous attributes of the Iris data set from
Table 3.2. The reader should compare these figures with the histograms given
in Figures 3.7 and 3.8. r
Scatter Plots Most people are familiar with scatter plots to some extent,
and they were used in Section 2.4.5 to illustrate linear correlation. Each data
object is plotted as a point in the plane using the values of the two attributes
as r and y coordinates. It is assumed that the attributes are either integer- or
real-valued.
Example 3.13. Figure 3.16 shows a scatter plot for each pair of attributes
of the Iris data set. The different species of Iris are indicated by different
markers. The arrangement of the scatter plots of pairs of attributes in this
type of tabular format, which is known as a scatter plot matrix, provides
an organized way to examine a number of scatter plots simultaneously. I
3.3 Visualization LL7
Figure
3.14.Empirical
CDFsoffourlrisattributes.
0204608010
Figure plots
3.15.Percentile forsepal
length,
sepal petal
width, andpetal
length, width.
118 Chapter 3 Exploring Data
c\l
o
=
(d
q)
o-
X
XXX XX
X XXX Xg X
XffiX XXW
XX X XXg
o
-c v)
ct
c') (o
E
s9 at)
(U
o
o -c
o-
ol .9
(t
o
o_
x
(D
x x
x x (6
XX
x
X
X s <)
p x oo x <t>
X -c
X) f x o
x
x xg '= x
g XX
x (5
x
x
x x -E
X X o-
o <rt
o
Grt
o
+ ol =
@
ctt
o o u-
o goo ce9
t\ -C
o)
c
q)
@_
(d
o-
o
gr@
There are two main uses for scatter plots. First, they graphically show
the relationship between two attributes. In Section 2.4.5, we saw how scatter
plots could be used to judge the degreeof linear correlation. (SeeFigure 2.17.)
Scatter plots can also be used to detect non-linear relationships, either directly
or by using a scatter plot of the transformed attributes.
Second,when classlabels are available, they can be used to investigate the
degree to which two attributes separate the classes. If is possible to draw a
line (or a more complicated curve) that divides the plane defined by the two
attributes into separate regions that contain mostly objects of one class, then
it is possible to construct an accurate classifier based on the specified pair of
attributes. If not, then more attributes or more sophisticated methods are
neededto build a classifier. In Figure 3.16, many of the pairs of attributes (for
example, petal width and petal length) provide a moderate separation of the
Iris species.
Example 3.14. There are two separate approachesfor displaying three at-
tributes of a data set with a scatter plot. First, each object can be displayed
according to the values of three, instead of two attributes. F igure 3.17 shows a
three-dimensionalscatter plot for three attributes in the Iris data set. Second,
one of the attributes can be associatedwith some characteristic of the marker,
such as its size, color, or shape. Figure 3.18 shows a plot of three attributes
of the Iris data set, where one of the attributes, sepal width, is mapped to the
size of the marker. r
c 1.5
c
o
J1
o
o
@ 0.5
*:;'H*:
"**-i,S#".*f
0
plotolsepal
3.17.Three-dimensional
Figure scatter width,
sepal andpetalwidth.
length,
4
Petal Length
plotofpetallength
Figure3.18,Scatter petalwidth,
versus withthesizeofthemarker
indicating
sepal
width.
3.3 Visualization LzL
plotof SSTforDecember
Figure3.19,Contour 1998.
made at various points in time. In addition, data may have only a temporal
component, such as time seriesdata that gives the daily prices of stocks.
Surface Plots Like contour plots, surface plots use two attributes for'the
r and 3l coordinates. The third attribute is used to indicate the height above
I22 Chapter 3 Exploring Data
of a setof 12points.
Figure3,20.Density
the plane defined by the first two attributes. While such graphs can be useful,
they require that a value of the third attribute be defined for all combinations
of values for the first two attributes, at least over some range. AIso, if the
surface is too irregular, then it can be difficult to see all the information,
unless the plot is viewed interactively. Thus, surface plots are often used to
describe mathematical functions or physical surfaces that vary in a relatively
smooth manner.
Example 3.16. Figure 3.20 shows a surface plot of the density around a set
of 12 points. This example is further discussedin Section 9.3.3. r
Vector Field Plots In some data, a characteristic may have both a mag-
nitude and a direction associatedwith it. For example, consider the flow of a
substanceor the change of density with location. In these situations, it can be
useful to have a plot that displays both direction and magnitude. This type
of plot is known as a vector plot.
Example 3.17. Figure 3.2I shows a contour plot of the density of the two
smaller density peaks from Figure 3.20(b), annotated with the density gradient
vectors.
\\\lllltrr\\\lll.t
ttlllrttlll\
plotofthegradient
Figure3.21,Vector (change) forthebottom
indensity peaksof Figure
twodensity
3.20.
of plots that we have described so far. However, separate "slices" of the data
can be displayed by showing a set of plots, one for each month. By examining
the change in a particular area from one month to another, it is possible to
notice changesthat occur, including those that may be due to seasonalfactors.
Example 3.18. The underlying data set for this example consists of the av-
erage monthly sea level pressure (SLP) from 1982 to 1999 on a 2.5o by 2.5'
Iatitude-longitude grid. The twelve monthly plots of pressurefor one year are
shown in Figure 3.22. In this example, we are interested in slices for a par-
ticular month in the year 1982. More generally, we can consider slices bf the
data along any arbitrary dimension.
January February
April May
July August
plotsof sealevelpressure
Figure3,22.Monthly overthe12months
of 1982.
This section considersvisualization techniques that can display more than the
handful of dimensionsthat can be observedwith the techniquesjust discussed.
However, even these techniques are somewhat limited in that they only show
some aspects of the data.
Example 3.19. Figure 3.23 shows the standardized data matrix for the Iris
data set. The first 50 rows represent Iris flowers ofthe species Setosa, the next
50 Versicolour, and the last 50 Virginica. The Setosa flowers have petal width
and length well below the average, while the Versicolour flowers have petal
width and length around average. The Virginica flowers have petal width and
length above average. l
It can also be useful to look for structure in the plot of a proximity matrix
for a set of data objects. Again, it is useful to sort the rows and columns of
the similarity matrix (when class labels are known) so that all the objects of a
class are together. This allows a visual evaluation of the cohesivenessof each
class and its separation from other classes.
Example 3.20. Figure 3.24 shows the correlation matrix for the Iris data
set. Again, the rows and columns are organized so that all the flowers of a
particular species are together. The flowers in each group are most similar
L26 Chapter 3 Exploring Data
to each other, but Versicolour and Virginica are more similar to one another
than to Setosa. r
If class labels are not known, various techniques (matrix reordering and
seriation) can be used to rearrange the rows and columns of the similarity
matrix so that groups of highly similar objects and attributes are together
and can be visually identified. Effectively, this is a simple kind of clustering.
See Section 8.5.3 for a discussion of how a proximity matrix can be used to
investigate the cluster structure of data.
I
o
o
E
c
o
o
o
5
I
o
o
E
c
c)
o
o
f
(!
:-;4"r6$h
fp+;fr;o[, oro
(a) Star graph of Iris 150. (b) Chernoff face of Iris 150.
Figure3.27.Starcoordinates
graphandChernoff
faceofthe150thflowerofthelrisdataset.
il\
4J A 04 I\
AJ
2 34 5
,4\
=vz /4\
€--F
,,f\
<vv <t>
v/ \,/
51 52 53 54 55
,,,,\
Y-T-7
\l/
+\t/ ,,'1t\
\ |
\Z
//
,-T\
\ l,/
\'/
-/t\
s\t/
J0l 102 '103 104 105
Figute
3.28.Plotof15lrisflowers
using
starcoordinates.
/Cit /-F\
vv
'I
2345
l^\ Z\
/oro\ Iore\ /oro\ rD /oro\
\_-/ \:-/ \_-/ \:./
51 52 53 54 55
/\
/eto) f\:/,1 /oro\ /oro) /oro)
\, tl \, \7
\7 '104
101 102 103 105
Despite the visual appeal of these sorts of diagrams, they do not scalewell,
and thus, they are of limited use for many data mining problems. Nonetheless,
they may still be of use as a means to quickly compare small sets of objects
that have been selectedby other techniques.
ACCENT Principles The follov,ring are the ACCEN? principles for ef-
fective graphical display put forth by D. A. Burn (as adapted by Michael
Friendlv):
Clarity Ability to visually distinguish all the elements of a graph. Are the
most important elements or relations visually most prominent?
Necessity The need for the graph, and the graphical elements. Is the graph
a more useful way to represent the data than alternatives (table, text)?
Are all the graph elements necessary to convey the relations?
Graphical excellence is that which gives to the viewer the greatest num-
ber of ideas in the shortest time with the least ink in the smallest space.
Most data sets can be representedas a table, where each row is an object and
each column is an attribute. In many cases,it is also possible to view the data
as a multidimensional array. We illustrate this approach by representing the
Iris data set as a multidimensional array.
Table 3.7 was created by discretizing the petal length and petal width
attributes to have values of low, med'ium, and hi,gh and then counting the
number of flowers from the Iris data set that have particular combinations
of petal width, petal length, and species type. (For petal width, the cat-
egories low, med'ium, and hi,gh correspond to the intervals [0, 0.75), [0.75,
1.75), [7.75, oo), respectively. For petal length, the categories low, med'ium,
and hi,gh correspond to the intervals 10, 2.5), 12.5,5), [5, m), respectively.)
I32 Chapter 3 Exploring Data
offlowers
Table3.7. Number a particular
having of petalwidth,petallength,
combination andspecies
rype.
Petal Length Petal Width SpeciesT Count
Iov,r low Setosa 40
low medium Setosa 2
medium low Setosa 2
medium medium Versicolour +L)
Petal
widrh
Virginica
Versicolour
Setosa
high
medium
low
Petal -c E =
.9 .= o
width -c E
o
E
Figure3.30.A multidimensional
datarepresentation
forthelrisdataset.
3.4 OLAP and Multidimensional Data Analysis 133
Table3.8.Crosstabulationofflowers
accord- offlowers
Table3.9,Cross-tabulation accord-
ingto petallengthandwidthforflowers
ofthe ingto petallengthandwidthforflowers
ofthe
Setosa species. Versicolour
species.
width width
Iow medium high
+l
low 000
b0 medium 0433
et
j high 022
Table3.10. Cross-tabulation
of flowersac-
cording
to petal
lengthandwidthforflowers
of
theVirginica
species.
width
Table
3.11,Sales ofproducts
revenue (indollars)
forvarious
locations
andtimes.
Product ID Location Date Revenue
:: ii
1 Minneapolis Oct. 18,2004 $250
1 Chicago Oct. 18,2004 $79
v{"'
ProductlD
Figure
3.31.Multidimensional
datarepresentation
forsales
data.
3.4 OLAP and MultidimensionalData Analvsis L37
Table thatresult
3.12.Totals fromsumming timeandproduct.
fora fixed
overalllocations
date
JanI.2O04 Jan2,2004
tr
3.12withmarginaltotals.
3.13.Table
Table
date
Jan 1. 2004 Jan2,2004 Dec 31. 2004 | total
27 $3.800.020
tr
27,362 ,r27
are three sets of totals that result from summing over only one dimension and
each set of totals can be displayed as a two-dimensional table.
If we sum over two dimensions (perhaps starting with one of the arrays
of totals obtained by summing over one dimension), then we will obtain a
multidimensional array of totals with rz - 2 dimensions. There will be (!)
g
distinct anays of such totals. For the sales examples, there will be () :
arays of totals that result from summing over location and product, Iocation
and time, or product and time. In general, summing over ,k dimensions yields
([) arrays of totals, each with dimension n - k.
A multidimensional representation of the data, together with all possible
totals (aggregates),is known as a data cube. Despite the name, the size of
each dimension-the number of attribute values-does not need to be equal.
AIso, a data cube may have either more or fewer than three dimensions. More
importantly, a data cube is a generalization of what is known in statistical
terminology as a cross-tabulation. If marginal totals were added, Tables
3.8, 3.9, or 3.10 would be typical examples of cross tabulations.
138 Chapter 3 Exploring Data
[99], SPSS [102], R [96], and S-PLUS [98]), and mathematics software (MAT-
LAB [94] and Mathematica [93]). Most of the graphics in this chapter were
generated using MATLAB. The statistics package R is freely available as an
open source software packagefrom the R project.
The literature on visualization is extensive, covering many fields and many
decades. One of the classicsof the field is the book by Tufte [103]. The book
by Spence [tOt], which strongly influenced the visualization portion of this
chapter, is a useful referencefor information visualization-both principles and
techniques. This book also provides a thorough discussion of many dynamic
visualization techniques that were not covered in this chapter. Two other
books on visualization that may also be of interest are those by Card et al.
[87] and Fayyad et al. [S9].
Finally, there is a great deal of information available about data visualiza-
tion on the World Wide Web. Since Web sites come and go frequently, the best
strategy is a search using "information visualization," "data visualization," or
"statistical graphics." However, we do want to single out for attention "The
Gallery of Data Visualization," by Friendly [90]. The ACCENT Principles for
effective graphical display as stated in this chapter can be found there, or as
originally presented in the article by Burn [86].
There are a variety of graphical techniques that can be used to explore
whether the distribution of the data is Gaussian or some other specified dis-
tribution. Also, there are plots that display whether the observed values are
statistically significant in some sense. We have not covered any of these tech-
niques here and refer the reader to the previously mentioned statistical and
mathematical packages.
Multidimensional analysis has been around in a variety of forms for some
time. One of the original papers was a white paper by Codd [88], the father
of relational databases. The data cube was introduced by Gray et al. [91],
who described various operations for creating and manipulating data cubes
within a relational database framework. A comparison of statistical databases
and OLAP is given by Shoshani [100]. Specific information on OLAP can
be found in documentation from database vendors and many popular books.
Many database textbooks also have general discussionsof OLAP, often in the
context of data warehousing. For example, see the text by Ramakrishnan and
Gehrke [97].
Bibliography
[86] D. A. Burn. Designing Effective Statistical Graphs. In C. R. Rao, editor, Hand,bookof
Stati,stics 9. Elsevier/North-Holland, Amsterdam, The Netherlands, September 1993.
3.6 Exercises L4L
,in Informat'ion
[87] S. K. Card, J. D. MacKinlay, and B. Shneiderman, editors. Read,ings
Visualization: Using Vision to Thznlc. Morgan Kaufmann Publishers, San Francisco,
CA, January 1999.
[88] E. F. Codd, S. B. Codd, and C. T. Smalley. Providing OLAP (On-line Analytical
Processing) to User- Analysts: An IT Mandate. White Paper, E.F. Codd and Associates,
1993.
f89] U. M. Fayyad, G. G. Grinstein, and A. Wierse, editors. Information V'isualization'in
Data Mining and, Knowled,ge Discouery. Morgan Kaufmann Publishers, San FYancisco,
CA, September 2001.
[90] M. F]iendly. Gallery of Data Visualization. http://www.math.yorku.ca/SCS/Gallery/,
2005.
[91] J. Gray, S. Chaudhuri, A. Bosworth, A. Layman, D. Reichart, M. Venkatrao, F. Pellow,
and H. Pirahesh. Data Cube: A Relational Aggregation Operator Generalizing Group-
By, Cross-Tab, and Sub-Totals. Journal Data Mining and Knouledge Discouerg, l(I):
29-53, 1997.
f92] B. W. Lindgren. Stat'istical Theory. CRC Press, January 1993.
[93] Mathematica 5.1. Wolfram Research, Inc. http://www.wolfram.comf ,2005.
[94] MATLAB 7.0. The MathWorks, Inc. http://www.mathworks.com, 2005.
[95] Microsoft Excel 2003. Microsoft, Inc. http://www.microsoft.comf ,2003.
[96] R: A language and environment for statistical computing and graphics. The R Project
for Statistical Computing. http: / /www.r-project.org/, 2005.
[97] R Ramakrishnan and J. Gehrke. Database Management Systems. McGraw-Hill, 3rd
edition, August 2002.
198] S-PLUS. Insightful Corporation. http: //www.insightful.com, 2005.
[99] SAS: Statistical Analysis System. SAS Institute Inc. http:f f www.sas.com/, 2005.
[100] A. Shoshani. OLAP and statistical databases: similarities and differences. In Proc.
of the Siateenth ACM SIGACT-SIGMOD-SIGART Symp. on Princ,i,ples of Database
Sgstems, pages 185-196. ACM Press, 1997.
[101] R. Spence. Inforrnation Visual'izati,on ACM Press, New York, December 2000.
[102] SPSS: Statistical Package for the Social Sciences.SPSS, lnc. http://www.spss.com/,
2005.
f103] E. R. Tufte. The Visual Di.splag of Quantitatiue Informat'ion. Graphics Press, Cheshire,
CT, March 1986.
[104] J. W. T\rkey. Exploratory data analys,is. Addison-Wesley, 1977.
[105] P. Velleman and D. Hoaglin. The ABC's of EDA: Applications, Basics, and Computing
of Exploratorg Data Analysis. Duxbury, 1981.
3.6 Exercises
1. Obtain one of the data sets available at the UCI Machine Learning Repository
and apply as many of the different visualization techniques described in the
chapter as possible. The bibliographic notes and book Web site provide pointers
to visualization software.
L42 Chapter 3 Exploring Data
2. Identify at least two advantages and two disadvantages ofusing color to visually
represent information.
3. What are the arrangement issues that arise with respect to three-dimensional
plots?
A Discuss the advantages and disadvantages of using sampling to reduce the num-
ber of data objects that need to be displayed. Would simple random sampling
(without replacement) be a good approach to sampling? Why or why not?
E
d. Describe how you would create visualizations to display information that de-
scribes the following types of systems.
(a) Computer networks. Be sure to include both the static aspects of the
network, such as connectivity, and the dynamic aspects, such as traffic.
(b) The distribution of specific plant and animal species around the world for
a specific moment in time.
(c) The use of computer resources, such as processor time, main memory, and
disk, for a set of benchmark database programs.
(d) The change in occupation of workers in a particular country over the last
thirty years. Assume that you have yearly information about each person
that also includes gender and level of education.
6 . Describe one advantage and one disadvantage of a stem and leaf plot with
respect to a standard histogram.
7. How might you address the problem that a histogram depends on the number
and location of the bins?
8 . Describe how a box plot can give information about whether the value of an
attribute is symmetrically distributed. What can you say about the symmetry
of the distributions of the attributes shown in Fieure 3.11?
9. Compare sepal length, sepal width, petal length, and petal width, using Figure
3.r2.
3.6 Exercises L43
10. Comment on the use of a box plot to explore a data set with four attributes:
age, weight, height, and income.
1 1 . Give a possible explanation as to why most of the values of petal length and
width fall in the buckets along the diagonal in Figure 3.9.
1 2 . Use Figures 3.14 and 3.15 to identify a characteristic shared by the petal width
and petal length attributes.
13. Simple line plots, such as that displayed in Figure 2.L2 on page 56, which
shows two time series, can be used to effectively display high-dimensional data.
For example, in Figure 2.72 iI is easy to tell that the frequencies of the two
time series are different. What characteristic of time series allows the effective
visualization of high-dimensional data?
r4. Describe the typesof situations that produce sparse or dense data cubes. Illus-
trate with examples other than those used in the book.
1 5 . How might you extend the notion of multidimensional data analysis so that the
target variable is a qualitative variable? In other words, what sorts of summary
statistics or data visualizations would be of interest?
16. Construct a data cube from Table 3.14. Is this a dense or sparse data cube? If
it is sparse, identify the cells that empty.
3.14.Fact
Table table 16.
forExercise
Product ID Location ID Number Sold
I I 10
1 3 6
2 1 5
2 2 22
ofgalaxies.
Figure4.1.Classification arefromtheNASA
Theimages website.
L46 Chapter 4 Classification
Input Output
Classilication
onr.'l1,,"
set l---) model
---) Class label
Figure4.2. Classification
asthetaskof mapping setx intoitsclasslabelg.
aninputattribute
4.L Preliminaries
The input data for a classification task is a collection of records. Each record,
also known as an instance or example, is characterizedby a tuple (*,A), where
x is the attribute set and gris a special attribute, designated as the class label
(also known as category or target attribute). Table 4.1 showsa sample data set
used for classifying vertebrates into one of the following categories: mammal,
bird, fish, reptile, or amphibian. The attribute set includes properties of a
vertebrate such as its body temperature, skin cover, method of reproduction,
ability to fly, and ability to live in water. Although the attributes presented
in Table 4.L are mostly discrete, the attribute set can also contain continuous
features. The class label, on the other hand, must be a discrete attribute.
This is a key characteristic that distinguishes classification from regression,
a predictive modeling task in which g is a continuous attribute. Regression
techniques are covered in Appendix D.
Definition 4.1 (Classification). Classification is the task of learning a tar-
get function / that maps each attribute set x to one of the predefined class
Iabels g.
The target function is also known informally as a classification model.
A classification model is useful for the following purposes.
Table
4.1.Thevertebrate
dataset.
Name lJody Skin Gives Aquatic Aerral Has H be Ulass
Temperature Cover Birth Creature Creature Legs nates Label
human warm-blooded hair yes no no yes no mammal
python cold-blooded scales no no no no yes reptile
salmon cold-blooded scales no yes no no no fish
whale warm-blooded hair yes yes no no no mammal
frog cold-blooded none no seml no yes yes amphibian
komodo cold-blooded scales no no no yes no reptile
dragon
bat warm-blooded hair yes no yes yes yes mammal
plgeon warm-blooded feathers no no yes yes no bird
cat warm-blooded fur yes no no yes no mammal
leopard cold-blooded scales yes yes no no no fish
shark
turtle cold-blooded scales no semt no yes no reptile
penguln warm-blooded feathers no seml no yes no bird
porcuptne warm-blooded quills yes no no yes yes mammal
eel cold-blooded scales no yes no no no fish
salamander cold-blooded none no semr no yes yes amphibian
summarizes the data shown in Table 4.1 and explains what features define a
vertebrate as a mammal, reptile, bird, fish, or amphibian.
We can use a classification model built from the data set shown in Table 4.1
to determine the class to which the creature belongs.
turn, is a subclassof mammals) are also ignored. The remainder of this chapter
focusesonly on binary or nominal class labels.
t ;t'' I
ruooel
I I
K",':
Figure4.3. General
approach
forbuilding model.
a classification
4.2 General Approach to Solving a Classification Problem L4g
Table4.2. Confusion
matrix problem.
fora 2-class
Predicted Class
C l a s s: 7 Ulass: U
Actual Class : I T
.t 77 JIO
Class U l a s s: 0 ./ 01 .Ioo
Most classification algorithms seek models that attain the highest accuracy, or
equivalently, the lowest error rate when applied to the test set. We will revisit
the topic of model evaluation in Section 4.5.
1-50 Chapter 4 Classification
o A root node that has no incoming edges and zero or more outgoing
edges.
o Internal nodes, each of which has exactly one incoming edge and two
or more outgoing edges.
o Leaf or terminal nodes, each of which has exactly one incoming edge
and no outgoing edges.
In a decision tree, each leaf node is assigned a class label. The non-
terminal nodes, which include the root and other internal nodes, contain
attribute test conditions to separate records that have different characteris-
tics. For example, the root node shown in Figure 4.4 uses the attribute Body
4.3 Decision TheeInduction 151
Figure4.4. A decision
treeforthemammal problem.
classification
Non-
mammats
4.5.Classifying
Figure anunlabeled lines
Thedashed
vertebrate. represent ofapplying
theoutcomes
various
attribute
testconditions The
vertebrate.
ontheunlabeled iseventually
vertebrate to
assigned
lIg lrf6a-aammalclass.
timum decisions about which attribute to use for partitioning the data. One
such algorithm is fluntts algorithm, which is the basis of many existing de-
cision tree induction algorithms, including ID3, C4.5, and CART. This section
presentsa high-level discussionof Hunt's algorithm and illustrates some of its
design issues.
flunt's Algorithm
Step 1: If ail the records in Dt belong to the same class y1, then t is a leaf
node labeled as y.
Step 2: If D; contains records that belong to more than one class, an at-
tribute test condition is selectedto partition the records into smaller
subsets. A child node is created for each outcome of the test condi-
tion and the records in D1 are distributed to the children based on the
outcomes. The algorithm is then recursively applied to each child node.
4.3 DecisionTYeeInduction 1-53
a.""
"""""""J"
Yes 125K
No 100K
No 70K
Yes 120K
No 95K
No 60K
Yes 220K
No 85K
No 75K
No 90K
Figure4.6.Training
setforpredicting
borrowers onloanpayments.
whowilldefault
Figure algorithm
4.7.Hunt's forinducing trees.
decision
A learning algorithm for inducing decision trees must address the following
two issues.
Warm- Cold-
blooded blooded
Figure4,8.Testcondition
forbinaryattributes.
156 Chapter 4 Classification
Single Divorced
(a) Multiwaysplit
OR
fornominal
Figure4.9.Testconditions attributes.
Nominal Attributes Since a nominal attribute can have many values, its
test condition can be expressed in two ways, as shown in Figure 4.9. For
a multiway split (Figure 4.9(a)), the number of outcomes depends on the
number of distinct values for the corresponding attribute. For example, if
an attribute such as marital status has three distinct values-single, married,
or divorced-its test condition will produce a three-way split. On the other
hand, some decisiontree algorithms, such as CART, produce only binary splits
by considering all 2k-1 - 1 ways of creating a binary partition of k attribute
values. Figure 4.9(b) illustrates three different ways of grouping the attribute
values for marital status into two subsets.
Figure4.10.Different
waysof grouping
ordinal values.
attribute
the same partition while Mediun and Extra Large are combined into another
partition.
Figure4.11. Testcondition
forcontinuous
attributes.
158 Chapter 4 Classification
4.12.Multiway
Figure binary
versus splits.
c-l
Entropy(t) : -ln?.lt)rog2pllt), (4.3)
o1_,
Gini(r) : L -|,lp11t)12, (4.4)
i,:o
Classificationerror(t) : 1 -max[p(ilt)]' (4.5)
Entropy
0.7
eini -.'-'
-'-).' )':-'l'l- ... --.
..' -'\.\ -'aa
o.4 -aat .a,t -aa
-'a.
-at -.a' '\,
,' .'t
\'\.\
0.1
Figure4.13.Comparison
among
theimpurity
measures
forbinary problems.
classification
The preceding examples, along with Figure 4.13, illustrate the consistency
among different impurity measures. Based on these calculations, node lft has
the lowest impurity value, followed by l{z and lf3. Despite their consistency,
the attribute chosen as the test condition may vary depending on the choice
of impurity measure, as will be shown in Exercise 3 on page 198.
To determine how well a test condition performs, we need to compare the
degree of impurity of the parent node (before splitting) with the degree of
impurity of the child nodes (after splitting). The larger their difference, the
better the test condition. The gain, A, is a criterion that can be used to
determine the goodnessof a split:
k
-i
A:I(pare"t) (4.6)
j:t
Yttr),
where 1(.) is the impurity measure of a given node, ly' is the total number of
records at the parent node, k is the number of attribute values, and l/(u3)
is the number of records associated with the child node, u7. Decision tree
induction algorithms often choose a test condition that maximizes the gain
A. Since /(parent) is the same for all test conditions, maximizing the gain is
equivalent to minimizing the weighted average impurity measures of the child
nodes. Finally, when entropy is used as the impurity measurein Equation 4.6,
the difference in entropy is known as the information gain, 461o.
Consider the diagram shown in Figure 4.14. Suppose there are two ways to
split the data into smaller subsets. Before splitting, the Gini index is 0.5 since
there are an equal number of records from both classes.If attribute A is chosen
to split the data, the Gini index for node N1 is 0.4898, and for node N2, it
is 0.480. The weighted averageof the Gini index for the descendentnodes is
(71L2) x 0.4898+ (5112) x 0.480 : 0.486. Similarly, we can show that the
weighted averageof the Gini index for attribute B is 0.375. Since the subsets
for attribute B have a smaller Gini index, it is preferred over attribute A.
Figure
4.14.Splitting
binary
attributes.
{Sports,
6''A
--:-sl,- 6;)
{Family,
tuxut).,/ \Tmrry) nxuryl.z \<{orts}
Figure4.15.Splitting
nominal
attributes.
Luxury) is 0.4922 and the Gini index of {Fa:rily} is 0.3750. The weighted
average Gini index for the grouping is equal to
Figure4.16.Splitting attributes.
continuous
For the multiway split, the Gini index is computed for every attribute value.
Since Gini({raniry}) : 0.375, Gini({Sports}) : 0, and Gini({Luxury}) :
0.219, the overall Gini index for the multiway split is equal to
The multiway split has a smaller Gini index compared to both two-way splits.
This result is not surprising becausethe two-way split actually merges some
of the outcomes of a multiway split, and thus, results in less pure subsets.
Consider the example shown in Figure 4.16, in which the test condition Annual
Income ( u is used to split the training records for the loan default classifica-
tion problem. A brute-force method for finding u is to consider every value of
the attribute in the ly' records as a candidate split position. For each candidate
u, the data set is scanned once to count the number of records with annual
income less than or greater than u. We then compute the Gini index for each
candidate and choose the one that gives the lowest value. This approach is
computationally expensive because it requires O(,nf) operations to compute
the Gini index at each candidate split position. Since there are -l[ candidates,
the overall complexity of this task is O(N\. To reduce the complexity, the
training records are sorted based on their annual income, a computation that
requires O(,n/logli) time. Candidate split positions are identified by taking
the midpoints between two adjacent sorted values: 55, 65, 72, and so on. How-
ever, unlike the brute-force approach, we do not have to examine all ly' records
when evaluating the Gini index of a candidate split position.
For the first candidate. u : 55. none of the records has annual income less
than $55K. As a result, the Gini index for the descendentnode with Annual
4.3 Decision Tlee Induction 163
fncome < $55K is zero. On the other hand, the number of records with annual
income greater than or equal to $55K is 3 (for class Yes) and 7 (for class No),
respectively. Thus, the Gini index for this node is 0.420. The overall Gini
index for this candidate split position is equal to 0 x 0 + 1 x 0.420 :0.420.
For the second candidate. u : 65. we can determine its class distribution
by updating the distribution of the previous candidate. More specifically,the
new distribution is obtained by examining the class label of the record with
the lowest annual income (i.e., $60K). Since the class label for this record is
No, the count for classNo is increasedfrom 0 to 1 (for Annual Income < $65K)
and is decreasedfrom 7 to 6 (for Annual- Incone > $65K). The distribution
for class Yes remains unchanged. The new weighted-average Gini index for
this candidate split position is 0.400.
This procedure is repeated until the Gini index values for all candidates are
computed, as shown in Figure 4.16. The best split position correspondsto the
one that producesthe smallest Gini index, i.e., u:97. This procedureis less
expensive because it requires a constant amount of time to update the class
distribution at each candidate split position. It can be further optimized by
consideringonly candidate split positions located betweentwo adjacent records
with different class labels. For example, because the first three sorted records
(with annual incomes $60K, $70K, and $75K) have identical class labels, the
best split position should not reside between $60K and $75K. Therefore, the
candidatesplit positionsat a : $55K, $65K, $72K, $87K, $92K, $110K, $I22K,
$772K, and $230K are ignored becausethey are located between two adjacent
records with the same class labels. This approach allows us to reduce the
number of candidate split positions from 11 to 2.
Gain Ratio
Impurity measuressuch as entropy and Gini index tend to favor attributes that
have a large number of distinct values. Figure 4.12 shows three alternative
test conditions for partitioning the data set given in Exercise 2 on page 198.
Comparing the first test condition, Gender, with the second, Car Type, it
is easy to see that Car Type seems to provide a better way of splitting the
data since it produces purer descendentnodes. However, if we compare both
conditions with Customer ID, the latter appears to produce purer partitions.
Yet Custoner ID is not a predictive attribute becauseits value is unique for
each record. Even in a lessextreme situation, a test condition that results in a
large number of outcomes may not be desirable becausethe number of records
associated with each partition is too small to enable us to make anv reliable
predictions.
L64 Chapter 4 Classification
There are two strategies for overcoming this problem. The first strategy is
to restrict the test conditions to binary splits only. This strategy is employed
by decision tree algorithms such as CART. Another strategy is to modify the
splitting criterion to take into account the number of outcomes produced by
the attribute test condition. For example, in the C4.5 decision tree algorithm,
a splitting criterion known as gain ratio is used to deterrnine the goodness
of a split. This criterion is defined as follows:
Ai"fo
Ualn "
ratlo : (4.7)
;--;.,--*-.
5pt1t rnlo
tree (Steps 11 and 12) until the stopping criterion is met (Step 1). The details
of this algorithm are explained below:
where the argmax operator returns the argument i that maximizes the
expressionp(i,lt). Besidesproviding the information neededto determine
the class label of a leaf node, the fraction p(i,lt) can also be used to es-
timate the probability that a record assignedto the leaf node t belongs
to class z. Sections 5.7.2 and 5.7.3 describe how such probability esti
mates can be used to determine the oerformance of a decisiontree under
different cost functions.
Totalnumberof pagesretrieved
in a Websession
umn.edu/-kumar
htto://www.cs. Totalnumberof imaqepaqesretrievedin a Websession
Totalamountol timesDentbv Websitevisitor
morethanoncein a Websession
madeusingHEADmethod
of requests
MlNDS/MlNDS_papers.htm
4.17.InputdataforWebrobotdetection.
Figure
Web usage mining is the task of applying data mining techniques to extract
useful patterns from Web accesslogs. These patterns can reveal interesting
characteristicsof site visitors; e.g., people who repeatedly visit a Web site and
view the same product description page are more likely to buy the product if
certain incentives such as rebates or free shipping are offered.
In Web usage mining, it is important to distinguish accessesmade by hu-
man users from those due to Web robots. A Web robot (also known as a Web
crawler) is a software program that automatically locates and retrieves infor-
mation from the Internet by following the hyperlinks embeddedin Web pages.
These programs are deployedby searchengine portals to gather the documents
necessaryfor indexing the Web. Web robot accessesmust be discarded before
applying Web mining techniques to analyze human browsing behavior.
4.3 Decision Tree Induction 167
2 . Unlike human users, Web robots seldom retrieve the image pages asso-
ciated with a Web document.
DecisionTree:
depth= 1:
breadth>7: class 1
breadth<=7:
breadth<= 3:
lmagePages>0.375: class 0
lmagePages<=0.375:
totalPages<=6: class 1
totalPages>6:
I breadth<= 1: class 1
I breadth> 1: class 0
width > 3:
MultilP= 0:
lmagePages<=0.1333: class 1
lmagePages>0.1333:
breadth<= 6: class 0
breadth> 6: class 1
MultilP= 1:
I TotalTime<= 361: class 0
I TotalTime> 361: class 1
depth>1:
MultiAgent= 0:
deoth> 2: class 0
deoth< 2:
MultilP= 1: class 0
MultilP= 0:
breadth<= 6: class 0
breadth> 6:
I RepeatedAccess<= 0.322: class 0
I RepeatedAccess> 0.322: class 1
MultiAgent= 1:
I totalPages<= 81: class 0
I totalPages> 81: class 1
4.18.Decision
Figure treemodelfor
Webrobot
detection,
4. Web robots are more likely to make repeated requestsfor the same doc-
ument since the Web pages retrieved by human users are often cached
by the browser.
6 . Decision tree algorithms are quite robust to the presenceof noise, espe-
cially when methods for avoiding overfitting, as described in Section 4.4,
are employed.
7 . The presence of redundant attributes does not adversely affect the ac-
curacy of decision trees. An attribute is redundant if it is strongly cor-
related with another attribute in the data. One of the two redundant
attributes will not be used for splitting once the other attribute has been
chosen. However, if the data set contains many irrelevant attributes, i.e.,
attributes that are not useful for the classificationtask, then some of the
irrelevant attributes may be accidently chosen during the tree-growing
process, which results in a decision tree that is larger than necessary.
Feature selection techniques can help to improve the accuracy of deci-
sion trees by eliminating the irrelevant attributes during preprocessing.
We will investigate the issue of too many irrelevant attributes in Section
4.4.3.
170 Chapter4 Classification
problem.
4.19.Treereplication
Figure Thesame canappear
subtree atdifferent
branches.
10. The test conditions described so far in this chapter involve using only a
single attribute at a time. As a consequence,the tree-growing procedure
can be viewed as the process of partitioning the attribute space into
disjoint regions until each region contains records of the same class (see
Figure 4.20). The border between two neighboring regions of different
classesis known as a decision boundary. Since the test condition in-
volves only a single attribute, the decision boundaries are rectilinear; i.e.,
parallel to the "coordinate axes." This limits the expressivenessof the
4.3 Decision Tree Induction L7L
1
0.9 oiv
0.8 V
0.7 oi
i
0.6 al
V
> 0.5
vi
0.4 V' i v
-----------d----
0.3
0.2 vi
0.1 vio
0r ,
0 0.1 0.3 0.4 0.5 0.6 0.7 0.8 0.9
x
Figure4.20.Example treeanditsdecision
ofa decision fora two-dimensional
boundaries dataset.
'I
i: .'l
.::... ..' '.' ' t
t
0.9
;\ ..1.'- ' t:.tt..t'
ata atat. 3
0.8 t
.t'
:rt
o.7 'ao-t
a
t. .
.t "t
u,o a
jltt'
r- a oo a a
to '
o.4
0
.l
o.2 + + ++ \ .
0.1 ..i..1;j- ;- \
oot
0.1 o.2 0.3 0.4 0.6 o.7 0.9
of datasetthatcannotbepartitioned
Figure4.21. Example involving
usingtestconditions
optimally
single
attributes.
r+A<I.
Although such techniques are more expressive and can produce more
compact trees, finding the optimal test condition for a given node can
be computationally expensive.
Constructive induction provides another way to partition the data
into homogeneous)nonrectangular regions (seeSection 2.3.5 on page 57).
This approach creates composite attributes representing an arithmetic
or logical combination of the existing attributes. The new attributes
provide a better discrimination of the classesand are augmented to the
data set prior to decisiontree induction. Unlike the oblique decision tree
approach, constructive induction is less expensive because it identifies all
the relevant combinations of attributes once, prior to constructing the
decision tree. In contrast, an oblique decision tree must determine the
right attribute combination dynamically, every time an internal node is
expanded. However, constructive induction can introduce attribute re-
dundancy in the data since the new attribute is a combination of several
existing attributes.
11. Studies have shown that the choice of impurity measure has little effect
on the performance of decisiontree induction algorithms. This is because
many impurity measuresare quite consistent with each other, as shown
in Figure 4.13 on page 159. Indeed, the strategy used to prune the
tree has a greater impact on the final tree than the choice of impurity
measure.
Trainingsel
16
,{.}tll.*fi :rliT"f,-:-g:'i;
14
-
(\l
't2
10
t .. *'-+ *
i **-
*;.**-*3S**o*l 1 * ++ +t*+
* ,** * + * * * +
* qoF oL-Y o
.^ r^**l * ** *
8
I .dr;
b
2 **** t
*l *aoi**3o-..*ia:..-i.^oo.i
0E
0 10 12 16 18
x1
Figure4.22.Example classes.
of a datasetwithbinary
seen before. In other words, a good model must have low training error as
well as low generalization error. This is important becausea model that fits
the training data too well can have a poorer generalization error than a model
with a higher training error. Such a situation is known as model overfitting.
o.4
- TrainingError
0.35 .- - TestError
0.25
o
G
r
h 0.2
Y
ul
0.1s
0.1
0.05
Figure4.23.Training
andtesterrorrates.
Notice that the training and test error rates of the model are large when the
size of the tree is very small. This situation is known as model underfitting.
Underfitting occurs becausethe model has yet to learn the true structure of
the data. As a result, it performs poorly on both the training and the test
sets. As the number of nodes in the decision tree increases,the tree will have
fewer training and test enors. However, once the tree becomes too large, its
test error rate begins to increase even though its training error rate continues
to decrease.This phenomenon is known as model overfitting.
To understand the overfitting phenomenon, note that the training error of
a model can be reduced by increasing the model complexity. For example, the
Ieaf nodes of the tree can be expanded until it perfectly fits the training data.
Although the training error for such a complex tree is zero, the test error can
be large because the tree may contain nodes that accidently fit some of the
noise points in the training data. Such nodes can degrade the performance
of the tree becausethey do not generalize well to the test examples. Figure
4.24 shows the structure of two decision trees with different number of nodes.
The tree that contains the smaller number of nodes has a higher training error
rate, but a lower test error rate compared to the more complex tree.
Overfitting and underfitting are two pathologies that are related to the
model complexity. The remainder of this section examines some of the poten-
tial causes of model overfitting.
4.4 Model Overfitting L75
2n
+
(a) Decision tree with 11 leaf (b) Decision tree with 24 leaf nodes.
nodes.
Figure
4.24.Decision withditferent
trees model
complexities.
Table4.3. Anexampletraining
setforclassifying Classlabels
mammals. withasterisk repre-
symbols
sentmislabeled
records.
Table4.4.Anexample
testsetforclassifying
mammals.
Name tsody Gl ves Four- Hibernates UIaSS
Temperature Birth legged Label
human warm-blooded yes no no yes
plgeon warm-blooded no no no no
elephant warm-blooded yes yes no yes
leopard shark coid-blooded yes no no no
turtle cold-blooded no yes no no
penguin cold-blooded no no no no
eel cold-blooded no no no no
dolphin warm-blooded yes no no yes
spiny anteater warm-blooded no yes yes yes
gila monster cold-blooded no yes yes no
Figure4.25.Decision
treeinduced
fromthedatasetshowninTable
4.3.
the test set is 30%. Both humans and dolphins were misclassified as non-
mammals becausetheir attribute values for Body Tenperature, Gives Birth,
and Four-legged are identical to the mislabeled records in the training set.
Spiny anteaters, on the other hand, represent an exceptional casein which the
class label of a test record contradicts the class labels of other similar records
in the training set. Errors due to exceptional casesare often unavoidable and
establish the minimum error rate achievable bv anv classifier.
4.4 Model Overfitting L77
In contrast, the decision tree M2 shown in Figure 4.25(b) has a lower test
error rate (I0%) even though its training error rate is somewhat higher (20%).
It is evident that the first decision tree, MI, has overfitted the training data
becausethere is a simpler model with lower error rate on the test set. The
Four-legged attribute test condition in model MI is spurious becauseit fits
the mislabeled training records, which leads to the misclassificationof records
in the test set.
Table4.5.Anexample
training
setforclassifying
mammals.
Name Body Lt lves Four- Hibernates Class
Temperature Birth Iegged Label
salamander cold- blooded no yes yes no
guppy cold-blooded yes no no no
eagle warm-blooded no no no no
poorwill warm-blooded no no yes no
platypus warm-blooded no yes Yes yes
Figure4.26.Decision
treeinduced
fromthedatasetshowninTable
4.5.
which is very high. Although each analyst has a low probability of predicting
at least eight times correctly, putting them together, we have a high probability
of finding an analyst who can do so. Furthermore, there is no guarantee in the
4.4 Model Overfitting LTg
future that such an analyst will continue to make accurate predictions through
random guessing.
How does the multiple comparison procedure relate to model overfitting?
Many learning algorithms explore a set of independent alternatives, {7a}, and
then choose an alternative, 'y*ur., that maximizes a given criterion function.
The algorithm will add 7*ur" to the current model in order to improve its
overall performance. This procedure is repeated until no further improvement
is observed. As an example, during decision tree growing, multiple tests are
performed to determine which attribute can best split the training data. The
attribute that leads to the best split is chosen to extend the tree as long as
the observed improvement is statistically significant.
Let ?o be the initial decision tree and Trbe the new tree after inserting an
internal node for attribute r. In principle, r can be added to the tree if the
observedgain, A(?s, T*), is greater than some predefined threshold a. If there
is only one attribute test condition to be evaluated, then we can avoid inserting
spurious nodes by choosing a Iarge enough value of a. However, in practice,
more than one test condition is available and the decision tree algorithm must
choosethe best attribute r,,,u* from a set of candidates,{*r,*2,. ..,rp}, to
partition the data. In this situation, the algorithm is actually using a multiple
comparison procedure to decide whether a decision tree should be extended.
More specifically, it is testing for A(?s, T*^u*) > a instead of A(?0, T") > o.
As the number of alternatives, k, increases, so does our chance of finding
A(fo, T*^u*) ) a. Unless the gain function A or threshold a is modified to
account for k, the algorithm may inadvertently add spurious nodes to the
model, which leads to model overfitting.
This effect becomesmore pronounced when the number of training records
from which z-ur. is chosenis small, becausethe variance of A(Tg, Tr^u*) is high
when fewer examples are available for training. As a result, the probability of
finding A(fo, Tr^u*) ) c increaseswhen there are very few training records.
This often happens when the decisiontree grows deeper, which in turn reduces
the number of records covered by the nodes and increases the likelihood of
adding unnecessarynodes into the tree. Failure to compensate for the large
number of alternatives or the small number of training records will therefore
lead to model overfitting.
Decision
Tree,Ta DecisionTree, Ta
Figure4.27.Example treesgenerated
oftwodecision fromthesametraining
data.
4.4 Model Overfitting L81
As previously noted, the chance for model overfitting increases as the model
becomes more complex. For this reason, we should prefer simpler models, a
strategy that agreeswith a well-known principle known as Occam's razor or
the principle of parsimony:
Definition 4.2. Occam's Razor: Given two models with the same general-
ization errors, the simpler model is preferred over the more complex model.
Occam's razor is intuitive becausethe additional components in a complex
model stand a greater chanceof being fitted purely by chance. In the words of
Einstein, "Everything should be made as simple as possible, but not simpler."
Next, we present two methods for incorporating model complexity into the
evaluation of classification models.
- eQ)+ o(r)
If:, [".(t')+ cl(to)]
Y' :
e.(T\
l/,
Df:rn(tt)
where k is the number of leaf nodes, e(") is the overall training error of the
decision tree, N1 is the number of training records, and O(t6) is the penalty
term associatedwith each node l;.
Example 4.2. Consider the binary decision trees shown in Figure 4.27. If
the penalty term is equal to 0.5, then the pessimistic error estimate for the
left tree is
4-t7 x0.5 7.5
eg(Tr): : 0.3125
24 24
and the pessimistic error estimate for the right tree is
/m \ 6+4x0.5
e s \ tR ) : :
24 *,:0'3333'
182 Chapter 4 Classification
A B
.) .)
T T
Unlabeled
Figure
4.28.Theminimum (MDL)principle.
length
description
Thus, the left tree has a better pessimistic error rate than the right tree. For
binary trees, a penalty term of 0.5 means a node should always be expanded
into its two child nodes as long as it improves the classification of at least one
training record because expanding a node, which is equivalent to adding 0.5
to the overall error, is less costly than committing one training error.
If fr(r) : 1 for all the nodes t, the pessimistic error estimate for the left
tree is es(Tr) : 71124: 0.458, while the pessimisticerror estimate for the
right tree is en(Tp):10124:0.4L7. The right tree thereforehas a better
pessimistic error rate than the left tree. Thus, a node should not be expanded
into its child nodes unless it reduces the misclassification error for more than
one training record.
form before being transmitted to B. If the model is 100% accurate, then the
cost of transmission is equivalent to the cost of encoding the model. Otherwise,
A must also transmit information about which record is classified incorrectly
by the model. Thus, the overall cost of transmission is
where the first term on the right-hand side is the cost of encoding the model,
while the second term representsthe cost of encoding the mislabeled records.
According to the MDL principle, we should seek a model that minimizes the
overall cost function. An example showing how to compute the total descrip-
tion length of a decision tree is given by Exercise 9 on page 202.
_2 T: .2
,+7#a",/2\,1t1+=/
+ffi
euw.r(Nrercr): , , (4.10)
-d/2
1 -l-
rrly'
where c is the confidence \evel, zo12is the standardized value from a standard
normal distribution, and -Ay'is the total number of training records used to
compute e. By replacing a : 25To,N : 7, and e : 217, the upper bound for
the error rate is eupp.r(7,217,0.25):0.503, which correspondsto 7 x 0.503:
3.521 errors. If we expand the node into its child nodes as shown in ft,, the
training error rates for the child nodes are Lf 4: 0.250 and 1/3 : 0.333,
L84 Chapter 4 Classification
respectively. Using Equation 4.10, the upper bounds of these error rates are
eupp.,(4,714,0.25):0.537 and e,,*",(3,1f 3,0.25) : 0.650,respectively.The
overall training error of the child nodesis 4 x 0.537+3 x 0.650:4.098, which
is larger than the estimated error for the corresponding node in 76. r
In this approach, instead of using the training set to estimate the generalization
error, the original training data is divided into two smaller subsets. One of
the subsets is used for training, while the other, known as the validation set,
is used for estimating the generalization error. Typically, two-thirds of the
training set is reserved for model building, while the remaining one-third is
used for error estimation.
This approach is typically used with classification techniques that can be
parameterized to obtain models with different levels of complexity. The com-
plexity of the best model can be estimated by adjusting the parameter of the
learning algorithm (e.g., the pruning level of a decision tree) until the empir-
ical model produced by the learning algorithm attains the lowest error rate
on the validation set. Although this approach provides a better way for esti-
mating how well the model performs on previously unseen records, less data
is available for training.
lmagePages>0.375: class 0
lmagePages<=0.375:
Simplified Decision Tree:
totalPages>6:
I breadth <= 1: class 1 depth= 1: -c-tass
I breadth > 1: class 0 leds:
t iimageP-a-ges-<---o T--l
I ilmagePages> 0.1333: I
1\Lul!ilP-=-o---- I breadth <= 6: class 0
tilmagePages:fo.i$3: Gtas-sT'i I i I breadth > 6: class I
I i lmagePages>0.1333: d e D t h> 1 :
I i breadth <= 6: class 0 i ------'l
uMuiriAsaT=oaEE;to
I Lbjqaltl jbgs_l_ _ _ _ _ _ _ _l
=
M u l t i l P 1"]j-
: T tr,tuniaGn-t-=l:
I TotalTime<= 361: class 0 | | t o t a l P a g e s < = 8 1 :c l a s s 0
I TotalTime> 361: class 1 | | totalPages>81: classl
NLul!i4s_e!t_=_ot
- _ ------------|
I ideoth"iz-:
^l
c-la-ss-il
| | deplh <= 2:
I i I MultilP= 1: class 0
lrlMultilP=0:
I I | | breadth <= 6: class 0
lrl I breadth>6:
lll | | RepeatedAccess<=0.322:classo i
liLIlEgp_eet9dAc9es1>_q jq2_2i_c!_a9s_1__l
MultiAgent= 1:
I t o t a l P a g e s < = 8 1 :c l a s s 0
I totalPages> 81: class I
even if no significant gain is obtained using one of the existing attribute test
conditions, subsequentsplitting may result in better subtrees.
depth : t have been replaced by one of the branches involving the attribute
InagePages. This approach is also known as subtree raising. The depth )
1 and MultiAgent : 0 subtree has been replaced by a leaf node assignedto
class 0. This approach is known as subtree replacement. The subtree for
depth ) 1 and MultiAgent : 1 remains intact.
of each other. Because the training and test sets are subsets of the original
data, a class that is overrepresentedin one subset will be underrepresentedin
the other, and vice versa.
The holdout method can be repeated several times to improve the estimation
of a classifier'sperformance. This approach is known as random subsampling.
Let acc.i be the model accuracy during the i,th iteration. The overall accuracy
is given by acq,,6 : Ditaccif k. Random subsampling still encounters some
of the problems associatedwith the holdout method becauseit does not utilize
as much data as possiblefor training. It also has no control over the number of
times each record is used for testing and training. Consequently,some records
might be used for training more often than others.
4.5.3 Cross-Validation
An alternative to random subsampling is cross-validation. In this approach,
each record is used the same number of times for training and exactly once
for testing. To illustrate this method, suppose we partition the data into two
equal-sizedsubsets. First, we choose one of the subsets for training and the
other for testing. We then swap the roles of the subsets so that the previous
training set becomesthe test set and vice versa. This approach is called a two-
fold cross-validation. The total error is obtained by summing up the errors for
both runs. In this example, each record is used exactly once for training and
once for testing. The k-fold cross-validation method generalizesthis approach
by segmenting the data into k equal-sizedpartitions. During each run, one of
the partitions is chosenfor testing, while the rest of them are used for training.
This procedure is repeated k times so that each partition is used for testing
exactly once. Again, the total error is found by summing up the errors for
all k runs. A special case of the k-fold cross-validation method sets k : N,
the size of the data set. In this so-called leave-one-out approach, each test
set contains only one record. This approach has the advantage of utilizing
as much data as possible for training. In addition, the test sets are mutually
exclusive and they effectively cover the entire data set. The drawback of this
approach is that it is computationally expensive to repeat the procedure ly'
times. Furthermore, since each test set contains only one record, the variance
of the estimated performance metric tends to be high.
188 Chapter 4 Classification
4.5.4 Bootstrap
The methods presented so far assume that the training records are sampled
without replacement. As a result, there are no duplicate records in the training
and test sets. In the bootstrap approach, the training records are sampled
with replacement; i.e., a record already chosen for training is put back into
the original pool of records so that it is equally likely to be redrawn. If the
original data has .ly' records, it can be shown that, on average, a bootstrap
sample of size ly' contains about 63.2%of the records in the original data. This
approximation follows from the fact that the probability a record is chosen by
a bootstrap sample is 1 - (1 - 1/,^f)^i. When l,r is sufficiently large, the
probability asymptotically approaches 1 - e-r :0.632. Records that are not
included in the bootstrap sample become part of the test set. The model
induced from the training set is then applied to the test set to obtain an
estimate of the accuracy of the bootstrap sample, e.;.The sampling procedure
is then repeated b times to generate b bootstrap samples.
There are several variations to the bootstrap sampling approach in terms
of how the overall accuracy of the classifier is computed. One of the more
widely used approaches is the .632 bootstrap, which computes the overall
accuracy by combining the accuraciesof each bootstrap sample (e;) with the
accuracy computed from a training set that contains all the labeled examples
in the original data (acc"):
1-a
Accuracy, (rcc6661
: x e6+ 0.368 x acc"). (4.11)
i ),{0.U32
The preceding example raises two key questions regarding the statistical
significance of the performance metrics:
The first question relates to the issue of estimating the confidence interval of a
given model accuracy. The second question relates to the issue of testing the
statistical significanceof the observeddeviation. These issuesare investigated
in the remainder of this section.
P(X:u):
On,' - p)N-"
For example, if the coin is fair (p : 0.5) and is flipped fifty times, then the
probability that the head shows up 20 times is
If the experiment is repeated many times, then the average number of heads
expectedto show up is 50 x 0.5 : 25, while its varianceis 50 x 0.5 x 0.5 : I2.5.
190 Chapter 4 Classification
The task of predicting the class labels of test records can also be consid-
ered as a binomial experiment. Given a test set that contains l{ records, let
X be the number of records correctly predicted by a model and p be the true
accuracy of the model. By modeling the prediction task as a binomial experi-
ment, X has a binomial distribution with mean I/p and variance Np(L - p).
It can be shown that the empirical accuracy?acc : X lN , also has a binomial
distribution with mean p and variance p(t-p)lN (seeExercise 12). Although
the binomial distribution can be used to estimate the confidence interval for
acc, it is often approximated by a normal distribution when N is sufficiently
large. Based on the normal distribution, the following confidenceinterval for
acc car:'be derived:
acc-p
t(- z o t zI < zr_.p) :7 _ (r, (4.12)
where Zo12 and Zt-o/z are the upper and lower bounds obtained from a stan-
dard normal distribution at confidencelevel (1 - a). Since a standard normal
distribution is symmetric around Z:0, it follows that Zop: Zt-o/z.Rear-
ranging this inequality leads to the following confidence interval for p:
2xNxacc*Z',tr+Z*/r@
(4.13)
2(N + 22^,r) -
"t
The following table shows the values of Zo12 at different confidence levels:
Example 4.4. Consider a model that has an accuracy of 80% when evaluated
on 100 test records. What is the confidenceinterval for its true accuracy at a
95% confidencelevel? The confidencelevel of 95% correspondsto Zo12:1.96
according to the table given above. Inserting this term into Equation 4.13
yields a confidence interval between 71.1% and 86.7%. The following table
shows the confidenceinterval when the number of records, l/, increases:
Consider a pair of models, M1 and M2, that are evaluated on two independent
test sets, D1 and D2. Let n1 denote the number of records in D1 and n2 denote
the number of records in D2. In addition, suppose the error rate for M1 oL
Dl is el and the error rate for Mz on D2 is e2. Our goal is to test whether the
observed difference between e1 and e2 is statisticaliy significant.
Assuming that n1 and n2 are sufficiently large, the error rates e1 and e2
can be approximated using normal distributions. If the observed differencein
the error rate is denoted as d : er - €2t then d is also normally distributed
with mean d1,its true difference, and variance, o]. Tne variance of d can be
computed as follows:
n 2 .- - i ?" d -
e1(L-e1) , -e1 2 ( l - e 2 )
-7 (4.r4)
"d
nL n2
where - et)lu and e2(1 - ez)lnz are the variances of the error rates.
"t(I
Finally, at the (t - a)% confidencelevel, it can be shown that the confidence
interval for the true difference dl is given by the following equation:
dt:dLzo12G6. (4.15)
Example 4.5. Consider the problem described at the beginning of this sec-
tion. Model Ma has an error rate of er : 0.15 when applied to A1 : 39
test records, while model Ms has an error rate of ez : 0.25 when applied
to Ab : 5000 test records. The observed difference in their error rates is
d : 10.15- 0.251: 0.1. In this example, we are performing a two-sided test
to check whether dt : 0 or d,6I 0. The estimated variance of the observed
difference in error rates can be computed as follows:
0 . 1 5 ( 1- 0 . 1 5 )
^,
wd -
30
.qag#a:ooo43
or 64 :0.0655. Inserting this value into Equation 4.L5, we obtain the following
confidence interval for d+ at 95% confidence level:
d +: 0 . 1 + 1 . 9 6x 0 . 0 6 5 5: 0 . 1* 0 . 1 2 8 .
As the interval spans the value zero) we can conclude that the observed differ-
ence is not statistically significant at a g5% confidence level. I
L92 Chapter 4 Classification
(4.16)
dt":dItg_.'1,t_r6a.".
The coefficient t1r-a;,r-1 is obtained from a probability table with two input
parameters, its confidencelevel (1 - and the number of degreesof freedom,
k - I. The probability table for the ")
t-distribution is shown in Table 4.6.
Example 4.6. Suppose the estimated difference in the accuracy of models
generated by two classification techniques has a mean equal to 0.05 and a
standard deviation equal to 0.002. If the accuracy is estimated using a 30-fold
cross-validation approach, then at a gbToconfidence level, the true accuracy
difference is
df" :0.05 +2.04x 0.002. (4.17)
4.7 BibliographicNotes 193
Table4.6. Probability
tablefort-distribution.
(1-o
k-7 0.99 0.98 0.95 0.9 0.8
1
l- 3.08 6.31 72.7 31.8 63.7
2 1.89 2.92 4.30 6.96 9.92
A 1.53 2.L3 2.78 3.75 4.60
9 1.38 1.83 2.26 2.82 3.25
I4 7.34 r.76 2.L4 2.62 2.98
19 1.33 1 .73 2.09 2.54 2.86
24 r.32 7 . 7 r 2.06 2.49 2.80
29 1 . 3 1 7 .70 2.04 2.46 2.76
Since the confidence interval does not span the value zero, the observed dif-
ference between the techniques is statistically significant. r
primary reasons for overfitting [t35, 140], Jensen and Cohen [123] argued
that overfitting is the result of using incorrect hypothesis tests in a multiple
comparison procedure.
Schapire 1149]defined generalization error as "the probability of misclas-
sifying a new example" and test error as "the fraction of mistakes on a newly
sampled test set." Generalization error can therefore be consideredas the ex-
pected test error of a classifier. Generalization error may sometimes refer to
the true error 1136]of a model, i.e., its expected error for randomly drawn
data points from the same population distribution where the training set is
sampled. These definitions are in fact equivalent if both the training and test
sets are gathered from the same population distribution, which is often the
casein many data mining and machine learning applications.
The Occam's razor principle is often attributed to the philosopher William
of Occam. Domingos [113] cautioned against the pitfall of misinterpreting
Occam's razor as comparing models with similar training errors, instead of
generalization errors. A survey on decision tree-pruning methods to avoid
overfitting is given by Breslow and Aha [109] and Esposito et al. [116]. Some
of the typical pruning methods include reduced error pruning [144],pessimistic
error pruninglL44], minimum error pruning [141], critical value pruning 1134],
cost-complexity pruning [108], and error-based pruning [1a5]. Quinlan and
Rivest proposed using the minimum description length principle for decision
tree pruning in [146].
Kohavi [127] had performed an extensive empirical study to compare the
performance metrics obtained using different estimation methods such as ran-
dom subsampling, bootstrapping, and k-fold cross-validation. Their results
suggest that the best estimation method is based on the ten-fold stratified
cross-validation. Efron and Tibshirani [115] provided a theoretical and empir-
ical comparison between cross-validation and a bootstrap method known as
the 632* rule.
Current techniquessuch as C4.5 require that the entire training data set fit
into main memory. There has been considerable effort to develop parallel and
scalable versions of decision tree induction algorithms. Some of the proposed
algorithms include SLIQ by Mehta et al. [131], SPRINT by Shafer et al. [151],
CMP by Wang and Zaniolo [153], CLOUDS by Alsabti et al. [106],RainForest
by Gehrke et al. [119], and ScalParC by Joshi et al. j2al. A general survey
of parallel algorithms for data mining is available in 1129].
196 Chapter 4 Classification
Bibliography
[106] K. Alsabti, S. Ranka, and V. Singh. CLOUDS: A Decision TYee Classifier for Large
Datasets. In Proc. of the lth Intl. Conf. on Knowledge D'iscouery and Data M'ining,
pages 2-8, New York. NY, August 1998.
11071 C. M. Bishop. Neural Networks for Pattern Recogniti,on. Oxford University Press,
Oxford, U.K., 1995.
l1o8lL. Breiman, J. H. Friedman, R. Olshen, and C. J. Stone. Classi,fi'cati'onand Regression
Trees. Chaprnan & Hall, New York, 1984.
l1OelL. A. Breslow and D. W. Aha. Simplifying Decision Tlees: A Survey. Knowledge
Engineering Reui,ew,L2(l):L-40, 1997.
[110] W. Buntine. Learning classification trees. In Artifici,al Intelligence Frontiers i;n Statis-
lics, pages I82 20I. Chapman & Hall, London, 1993.
1111] E. Cantri-Paz and C. Kamath. Using evolutionary algorithms to induce oblique decision
trees. In Proc. of the Genetic and Euoluti,onarg Computation Conf., pages 1053-1060,
San Flancisco, CA, 2000.
[112] V. Cherkassky and F. Mulier. Learning from Data: Concepts, Theory, and Method's.
Wiley Interscience, 1998.
[113] P. Domingos. The Role of Occam's Razor in Knowledge Discovery. Data Mi'ning and
Knouledg e Discouery, 3(4) :409-425, t999.
[114] R. O. Duda, P. E. Hart, and D. G. Stork. Pattern Class'ification John Wiley & Sons,
Inc., New York, 2nd edition, 2001.
[115] B. Efron and R. Tibshirani. Cross-validation and the Bootstrap: Estimating the Error
Rate of a Prediction Rule. Technical report, Stanford University, 1995.
[116] F. Esposito, D. Malerba, and G. Semeraro. A Comparative Analysis of Methods for
Pruning Decision Trees. IEEE Trans. Pattern Analysis and Machine Intelli,gence, 19
(5):476-491,May 1997.
[117] R. A. Fisher. The use of multiple measurements in taxonomic problems. Annals of
Eugenics,7:179 188,1936.
11181K. Fukunaga. Introduct'ion to Statist'icalPattern Recognit'i,on.Academic Press, New
York, 1990.
1119] J. Gehrke, R. Ramakrishnan, and V. Ganti. RainForest-A Framework for Fast De-
cision Tree Construction of Large Datasets. Data Mi,ning and Knowledge D'iscouerg, 4
(213):127-162,2000.
[120] T. Hastie, R. Tibshirani, and J. H. Friedman. The Elements of Stati.stical Leanting:
Data Mi,ning, Inference, Pred'icti,on. Springer, New York, 2001.
f121] D. Heath, S. Kasif, and S. Salzberg. Induction of Oblique Decision Trees. In Proc. of
the 13th IntI. Joint Conf. on Arti,fici,al Intelligence, pages 1002-1007, Chambery, France,
August 1993.
ll22] A. K. Jain, R. P. W. Duin, and J. Mao. Statistical Pattern Recognition: A Review.
IEEE Tfan. Patt. Anal. and,Mach. Intellig.,22(I):4 37,2000.
f123] D. Jensen and P. R. Cohen. Multiple Comparisons in Induction Algorithms. Mach'ine
Learning, 38(3) :309-338, March 2000.
ll24l M. V. Joshi, G. Karypis, and V. Kumar. ScalParC: A New Scalable and Efficient
Parallel Classification Algorithm for Mining Large Datasets. In Proc. of 12th IntI.
Parallel Processing Sgmp. (IPPS/SPDP), pages 573 579, Orlando, FL, April 1998.
[125] G. V. Kass. An Exploratory Technique for Investigating Large Quantities of Categor-
ical Data. Appli,ed Statistics, 29:Ll9-127, 1980.
Bibtiography Lg7
[126]
lr27l
u28l
[12e]
[132] R' S' Michalski' A theory and methodologyof inductive learning. Arti,fi,cial
Intell,igence,
20:111-116,1988.
[133j D. Michie, D. J. Spiegelhalter, and C. C. Taylor. Machine Learning,
Neural and
Statistical Classi,fi,cati,oz.Ellis Horwood, Upper
. Saddle River, NJ, 1g94.
[134] -J' Mingers. Expert systems-Rule Induction with statisticar Data.
J Operational
Research Soc'ietg,Bg:89 47, 19g2.
[135] J' Mingers' An empirical comparisonof pruning methods for decisiontree
induction.
Machine Learni,ng,4:227_24J,Iggg.
[136] T. Mitchell. Machine Learn,ing.McGraw_Hill,Boston, MA, IggT.
1137]B. M. E' Moret. DecisionT}eesand Diagrams. computing suraegs, r4(4):893-62J,
t982.
I138]-S' K' Murthy. Automatic Construction of Decision TYeesfrom Data:
A
Disciplinarysurvey. Data Mi,ning and KnowredgeDiscouery,2(4):34b-3gg, Multi-
1ggg.
[139] S' K' Murthy, s. r.<3if, S.
_and salzberg. A system for induction of oblique decision
trees. ,.Iof Artificial Intelligence Research,2:I,JJ, Igg4.
[140] T' Niblett. constructing decisiontrees in noisy domains. In proc. of the
2nd.European
Working Sessionon Leaming, pages67_2g,Bled, yugoslavia,
May 19g7.
[141] T' Niblett and I. Bratko' LearningDecisionRulesin Noisy Domai ns.rn
Researchand,
Deuelopmentin Er,pert systems r11,cambridge, 1gg6.
cu-bridg" University press.
[142] K' R' Pattipati and M. G. Alexandri<Iis.Application of heuristic searchand
information
theory to sequentiarfault diagnosis. IEEE Trans. on
sgstems, Mon, ord, cgbernetics,
2o(4):872-s82,
rss}.
[143] J' R' Quinlan. Discovering rules by induction from large collection of
examples. In
D' Michie, editot, Eupert systems ,in the M,icro Erectronic
Ag". Edinburgh university
Press,Edinburgh,UK, 1g79.
Ir44) J- R' Quinlan. simplifying DecisionTtees. 1nrl. J. Man-Machinestud,ies,2T:22r_284,
1987.
[145] J. R. Quinlan. cl.s: progr.amsfor Machine Learni,ng.Morgan-Kaufmann publishers,
San Mateo, CA, 1gg3.
[146] J' R' Quinlan and R. L. Rivest. Inferring DecisionTleesusing the Minimum
Descrip-
tion Length Principle. Information and Computation,g0(B):2i7_24g,
19gg.
1-98 Chapter 4 Classification
4.8 Exercises
1 . Draw the full decision tree for the parity function of four Boolean attributes,
A, B, C, and D. Is it possible to simplify the tree?
2 . Consider the training examples shown in Table 4.7 for a binary classification
problem.
(a) Compute the Gini index for the overall collection of training examples.
(b) Compute the Gini index for the Custoner ID attribute.
(c) Compute the Gini index for the Gender attribute.
(d) Compute the Gini index for the Car Type attribute using multiway split.
(e) Compute the Gini index for the Shirt Size attribute using multiway
split.
(f) Which attribute is better, Gender, Car Type, or Shirt Size?
(g) Explain why Custoner ID should not be used as the attribute test con-
dition even though it has the lowest Gini.
.f. Consider the training examples shown in Table 4.8 for a binary classification
problem.
(a) What is the entropy of this collection of training examples with respect
to the positive class?
4.8 Exercises 199
Table
4.7.DatasetforExercise
2.
CustomerID Gender Car Type Shirt Size Class
1 M Family Small CO
2 M Sports Medium CO
3 M Sports Medium CO
4 M Sports Large CO
b M Sports Extra Large CO
6 M Sports Extra Large CO
F7
I F Sports Small CO
8 F Sports Small CO
9 F Sports Medium CO
10 F Luxury Large CO
11 M Family Large C1
t2 M Family Extra Large C1
13 M Family Medium C1
t4 M Luxury Extra Large C1
15 F Luxury Small C1
16 F Luxury Small C1
77 F Luxury Medium C1
18 F Luxury Medium C1
19 F Luxury Medium C1
20 F Luxury Larqe C1
Table
4,8.DatasetforExercise
3.
Instance aL a2 as Target Class
I TT1.O T
2 TT6.0 -T
3 TF5.O
4 FF4.O -T-
5 F T 7.0
6 FT3.O
a
T FF8.O
8 T F 7.0 -T-
o FT5.O
(b) What are the information gains of o1 and o2 relative to these training
examples?
(") For o3, which is a continuous attribute, compute the information gain for
every possible split.
200 Chapter 4 Classification
(d) What is the best split (among e7t a2t and o3) according to the information
gain?
(e) What is the best split (between 01 and o2) according to the classification
error rate?
(f) What is the best split (between 01 and o2) according to the Gini index?
4. Show that the entropy of a node never increases after splitting it into smaller
successornodes.
A B ClassLabel
I !' -r
T T -r
T T +
T F
T T +
F F
F F
F F
T T
T F
(a) Calculate the information gain when splitting on ,4 and B. Which at-
tribute would the decision tree induction algorithm choose?
(b) Calculate the gain in the Gini index when splitting on .A and B. Which
attribute would the decision tree induction algorithm choose?
(c) Figure 4.13 shows that entropy and the Gini index are both monotonously
increasing on the range [0, 0.5] and they are both monotonously decreasing
on the range [0.5, 1]. Is it possible that information gain and the gain in
the Gini index favor different attributes? Explain.
(a) Compute a two-level decision tree using the greedy approach described in
this chapter. Use the classification error rate as the criterion for splitting.
What is the overall error rate of the induced tree?
(b) Repeat part (a) using X as the first splitting attribute and then choosethe
best remaining attribute for splitting at each of the two successor nodes.
What is the error rate of the induced tree?
(c) Compare the results of parts (a) and (b). Comment on the suitability of
the greedy heuristic used for splitting attribute selection.
7 The following table summarizes a data set with three attributes A, B. C and
two class labels *, -. Build a two-level decision tree.
Number of
A B C Instances
+
T T T ( 0
F T T 0 20
T F T 20 0
F F T 0 K
T T F 0 0
F T F 25 0
T F F 0 0
F F F 0 25
(a) According to the classification error rate, which attribute would be chosen
as the first splitting attribute? For each attribute, show the contingency
table and the gains in classification error rate.
(b) Repeat for the two children of the root node.
(c) How many instances are misclassified by the resulting decision tree?
(d) Repeat parts (a), (b), and (c) using C as the splitting attribute.
(e) Use the results in parts (c) and (d) to conclude about the greedy nature
of the decision tree induction algorithm.
(a) Compute the generalization error rate of the tree using the optimistic
approach.
(b) Compute the generalization error rate of the tree using the pessimistic
approach. (For simplicity, use the strategy of adding a factor of 0.5 to
each leaf node.)
(c) Compute the generalization error rate of the tree using the validation set
shown above. This approach is known as reduced error pruning.
2O2 Chapter 4 Classification
Instance A B c Class
+
2 0 0 +
3 1 +
4 1
5 1 0 0 +
6 1 0 0 +
7 1 1 0
8 1 0 +
I 1 1 0
10 1 1 0
Validation:
lnstance A B c Class
0 0 0 +
12 0 1 1 +
13 1 1 0 +
14 1 0 1
15 1 0 0 +
Figure treeanddatasetsforExercise
4.30.Decision 8.
9 . Consider the decision trees shown in Figure 4.31. Assume they are generated
from a data set that contains 16 binarv attributes and 3 classes,C1, C2, and
C3.
4.31.Decision
Figure forExercise
trees 9.
4.8 Exercises 2Og
C ost (tr ee, dat a) : C ost (tr ee) -f C ost (dat altr ee).
Each internal node of the tree is encoded by the ID of the splitting at-
tribute. If there are rn attributes, the cost of encodins each attribute is
Iog, rn bits.
Each leaf is encoded using the ID of the class it is associated with. If
there are k classes,the cost of encoding a class is log, k bits.
Cost(tree) is the cost of encoding all the nodes in the tree. To simplify the
computation, you can assume that the total cost of the tree is obtained
by adding up the costs of encoding each internal node and each leaf node.
Cost(dataltree) is encoded using the classificationerrors the tree commits
on the training set. Each error is encoded by log2 n bits, where n is the
total number of training instances.
10. While the .632 bootstrap approach is useful for obtaining a reliable estimate of
model accuracy, it has a known limitation 1127]. Consider a two-class problem,
where there are equal number of positive and negative examples in the data.
Suppose the class labels for the examples are generated randomly. The classifier
used is an unpruned decision tree (i.e., a perfect memorizer). Determine the
accuracy of the classifier using each of the following methods.
(a) The holdout method, where two-thirds of the data are used for training
and the remaining one-third are used for testing.
(b) Ten-fold cross-validation.
(c) The .632 bootstrap method.
(d) Flom the results in parts (u), (b), and (c), which method provides a more
reliable evaluation of the classifier's accuracy?
11. Consider the following approach for testing whether a classifier A beats another
classifier B. Let l[ be the size of a given data set, pa be the accuracy of classifier
A, ps be the accuracy of classifier B, and p: (pt +pB)12 be the average
accuracy for both classifiers. To test whether classifier A is significantly better
than B, the following Z-statistic is used:
PA-PB
Table 4.9 compares the accuracies of three different classifiers, decision tree
classifiers, naive Bayes classifiers, and support vector machines, on various data
sets. (The latter two classifiersare described in Chapter 5.)
4.9.Comparing
Table theaccuracy
ofvarious methods.
classification
Data Set Size Decision nalve Support vector
(r/) Tlee (%) Bayes (%) machine (%)
nneal 898 92.09 79.62 87.19
Australia 690 6b.bl 76.81 84.78
Auto 205 81.95 58.05 1 U .1 J
Summarize the performance of the classifiers given in Table 4.9 using the fol-
lowing3 x 3table:
Each cell in the table contains the number of wins. losses, and draws when
comparing the classifier in a given row to the classifier in a given column.
4.8 Exercises 2O5
1 2 . Let X be a binomial random variable with mean lr'p and variance lfp(l -p).
Show that the ratio Xf N also has a binomial distribution with mean p and
v a r i a n c ep ( t - p ) l N .
Classification:
AlternativeTechniques
The previous chapter described a simple, yet quite effective, classification tech-
nique known as decision tree induction. Issues such as model overfitting and
classifier evaluation were also discussedin great detail. This chapter presents
alternative techniques for building classification models-from simple tech-
niques such as rule-based and nearest-neighbor classifiers to more advanced
techniques such as support vector machines and ensemble methods. Other
key issues such as the class imbalance and multiclass problems are also dis-
cussedat the end of the chapter.
Table
5.1.Example
ofa rulesetforthevertebrate problem.
classification
rri (Gives Birth : no) n (Aerial Creature : yes) ------+
Birds
r2i (Gives Birth : no) n (Aquatic Creature : yes) ------+Fishes
13: (Gives Birth : yes) n (Body Temperature : warm-blooded) ------+
Mammals
14: (Gives Birth : no) n (Aerial Creature : no) ----- Reptiles
rbi (Aquatic Creature : semi) ------+
Amphibians
208 Chapter 5 Classification: Alternative Techniques
The left-hand side of the rule is called the rule antecedent or precondition.
It contains a conjunction of attribute tests:
Coverage(r
) !!l
tDl
. :
Accuracy(r) lAnal (5.3)
T
where lAl is the number of records that satisfy the rule antecedent, lA n gl is
the number of records that satisfy both the antecedent and consequent, and
lDl is the total number of records.
5.1 Rule-Based Classifier 2Og
Table5,2.Thevertebrate
dataset.
l\ame lJody Skin Gives Aquatic Aerial -nas lllDer- C'lass Label
Temperature Cover Birth Creature Creature Legs nates
numan warm-blooded nalr yes no no yes no IVlammals
python cold-blooded scales no no no no yes Reptiles
salmon cold-blooded scales no yes no no no Fishes
whale warm-blooded hair yes yes no no no Mammals
froo cold-blooded none no semr no yes yes Amphibians
komodo cold-blooded scales no no no yes no Reptiles
dragon
bat warm-blooded hair yes no yes yes yes Mammals
prgeon warm-blooded feathers no no yes yes no Birds
cat warm-blooded fur yes no no yes no Mammals
guppv cold-blooded scales yes yes no no no Fishes
alligator cold-blooded scales no seml no yes no Reptiles
penguln warm-blooded feathers no semr no yes no Birds
porcuplne warm-blooded quills yes no no yes yes Mammals
eel cold-blooded scales no yes no no no Fishes
salamander cold-blooded none no semr no yes yes Amphibians
Example 5.1. Consider the data set shown in Table 5.2. The rule
has a coverage of 33% since five of the fifteen records support the rule an-
tecedent. The rule accuracy is 100% because all five vertebrates covered by
the rule are mammals. r
o The second vertebrate, which is a turtle, triggers the rules 14 and rs.
Since the classespredicted by the rules are contradictory (reptiles versus
amphibians), their conflicting classesmust be resolved.
The previous example illustrates two important properties of the rule set gen-
erated by a rule-based classifier.
Mutually Exclusive Rules The rules in a rule set .R are mutually exclusive
if no two rules in .R are triggered by the same record. This property ensures
that every record is covered by at most one rule in R. An example of a
mutually exclusive rule set is shown in Table 5.3.
ofa mutually
Table5.3. Example andexhaustive
exclusive ruleset.
Ordered Rules In this approach, the rules in a rule set are ordered in
decreasing order of their priority, which can be defined in many ways (e.g.,
based on accuracy, coverage,total description length, or the order in which
the rules are generated). An ordered rule set is also known as a decision
list. When a test record is presented,it is classifiedby the highest-ranked rule
that covers the record. This avoids the problem of having conflicting classes
predicted by multiple classification rules.
has the following interpretation: If the vertebrate does not have any feathers
or cannot fly, and is cold-blooded and semi-aquatic, then it is an amphibian.
2L2 Chapter 5 Classification: Alternative Techniques
Rule-BasedOrdering Class-BasedOrdering
(SkinCover=feathers,
Aerial9r"31u1s=yes) Aerialgte2luvs=yes)
(SkinCover=feathers,
==> Birds ==> Birds
(Bodytemperature=warm-blooded, (Bodytemperature=warm-blooded,
==> 1446t";.
GivesBirth=yes) ==> Birds
GivesBirth=no)
(Bodytemperature=warm-blooded, (Bodytemperature=warm-blooded,
=-> Birds
GivesBirth=no) ==> J1l36P41t
GivesBirth=yes)
==>4606;6;"n.
(AquaticCreature=semi)) ==>4601'';6'"n.
(AquaticCreature=semi))
(SkinCover=scales,
AquaticCreature=no) ==>Amphibians
(SkinCover=none)
=-> Reptiles
Aquaticgr"s1u1e=no)
(SkinCover=scales,
Aquaticgt"u1u1s=yes)
(SkinCover=scales, ==> Reptiles
==> Fishes
Aquaticgtsslups=yes)
(SkinCover=scales,
==>Amphibians
(SkinCover=none) ==> Fishes
Figure5.1. Comparison
between
rule-based
andclass-based schemes.
ordering
The additional conditions (that the vertebrate does not have any feathers or
cannot fly, and is cold-blooded) are due to the fact that the vertebrate does
not satisfy the first three rules. If the number of rules is large, interpreting the
meaning of the rules residing near the bottom of the list can be a cumbersome
task.
There are two broad classesof methods for extracting classification rules: (1)
direct methods, which extract classification rules directly from data, and (2)
indirect methods, which extract classification rules from other classification
models, such as decision trees and neural networks.
Direct methods partition the attribute spaceinto smaller subspacesso that
all the records that belong to a subspacecan be classifiedusing a single classi-
fication rule. Indirect methods use the classificationrules to provide a succinct
description of more complex classificationmodels. Detailed discussionsof these
methods are presented in Sections 5.1.4 and 5.1.5, respectively.
-+
+,+ T
(a)OriginalData (b)Step1
:R1 i
- : .., .. ... .. i
-+
*+* :R2
Figure5.2.Anexample
ofthesequential algorithm.
covering
5.1 Rule-BasedClassifier2L5
Learn-One-Rule F\rnction
(a) General-to-specif
ic
(b) Specificto-general
Figure
5.3.General{o-specific
andspecific-to-general
rule-growing
strategies.
2L6 Chapter 5 Classification: Alternative Techniques
conjuncts are subsequently added to improve the rule's quality. Figure 5.3(a)
shows the general-to-specific rule-growing strategy for the vertebrate classifi-
cation problem. The conjunct Body Tenperature=warn-blooded is initially
chosento form the rule antecedent. The algorithm then explores all the possi-
ble candidates and greedily choosesthe next conjunct, Gives Birth=yes, to
be added into the rule antecedent. This process continues until the stopping
criterion is met (e.g., when the added conjunct does not improve the quality
of the rule).
For the specific-to-general strategy, one of the positive examples is ran-
domly chosen as the initial seed for the rule-growing process. During the
refinement step, the rule is generalized by removing one of its conjuncts so
that it can cover more positive examples. Figure 5.3(b) shows the specific-to-
general approach for the vertebrate classification problem. Suppose a positive
example for mammals is chosen as the initial seed. The initial rule contains
the same conjuncts as the attribute values of the seed. To improve its cov-
erage, the rule is generalized by removing the conjunct Hibernate=no. The
refinement step is repeated until the stopping criterion is met, e.g., when the
rule starts covering negative examples.
The previous approachesmay produce suboptimal rules becausethe rules
are grown in a greedy fashion. To avoid this problem, a beam search may be
used, where k of the best candidate rules are maintained by the algorithm.
Each candidate rule is then grown separately by adding (or removing) a con-
junct from its antecedent. The quality ofthe candidates are evaluated and the
k best candidates are chosen for the next iteration.
The accuracies for 11 and 12 are 90.9% and 100%, respectively. However,
11 is the better rule despite its lower accuracy. The high accuracy for 12 is
potentially spurious becausethe coverageof the rule is too low.
5.1 Rule-BasedClassifier 2L7
1. A statistical test can be used to prune rules that have poor coverage.
For example, we may compute the following likelihood ratio statistic:
R: 2\ fitosff,;le),
i:I
f , -r1
Laplace : (5.4)
nl k'
f+ -t kp+
m-estimate : I (O.DJ
n-fk
where n is the number of examples covered by the rule, /-p is the number
of positive examplescoveredby the rule, k is the total number of classes,
and p1 is the prior probability for the positive class. Note that the m-
estimate is equivalent to the Laplace measure by choosing p+ : llk.
Depending on the rule coverage, these measures capture the trade-off
218 Chapter 5 Classification: Alternative Techniques
between rule accuracy and the prior probability of the positive class. If
the rule does not cover any training example, then the Laplace mea-
sure reduces to lf k, which is the prior probability of the positive class
assuming a uniform class distribution. The m-estimate also reduces to
the prior probability (p1) when n : 0. However, if the rule coverage
is large, then both measuresasymptotically approach the rule accuracy,
f+ln. Going back to the previous example, the Laplace measure for
11 is 51157 : 89.47To,which is quite close to its accuracy. Conversely,
the Laplace measure for 12 (75%) is significantly lower than its accuracy
because 12 has a much lower coverage.
3. An evaluation metric that takes into account the support count of the
rule can be used. One such metric is the FOILts information gain.
The support count of a rule correspondsto the number of positive exam-
ples covered by the rule. Suppose the rule r : A ------* covers ps positive
examples and ns negative examples. After adding a new conjunct B, the
extended rule r' : A tt,B ------+
* covers p1 positive examples and n1 neg-
ative examples. Given this information, the FOIL's information gain of
the extended rule is defined as follows:
R3 R2
T
+
class= + + +
+
++
class=
Figure5.4. Elimination
of training
records
bythesequential
covering R7,R2, andR3
algorithm.
represent
regions
coveredbythreedifferent
rules.
Figure 5.4 shows three possible rules, R7, R2, and R3, extracted from a
data set that contains 29 positive examples and 21 negative examples. The
accuraciesof .R1,R2, and E3 are I2115 (80%), 7lI0 (70%), and 8f L2 (66.7%),
respectively. .R1 is generated first because it has the highest accuracy. After
generating R1, it is clear that the positive examplescoveredby the rule must be
removed so that the next rule generated by the algorithm is different than .R1.
Next, supposethe algorithm is given the choice of generating either R2 or R3.
Even though R2 has higher accuracy than -R3, Rl and -R3 together cover 18
positive examples and 5 negative examples (resulting in an overail accuracy of
78.3%), whereasR1 and .R2together cover 19 positive examplesand 6 negative
examples (resulting in an overall accuracy of 76%). The incremental impact of
R2 or -R3on accuracy is more evident when the positive and negative exarnples
coveredby -Rl are removed before computing their accuracies.In particular, if
positive examples covered by R1 are not removed, then we may overestimate
the effective accuracy of ,R3, and if negative examples are not removed, then
we may underestimate the accuracy of R3. In the latter caseTwe might end up
preferring R2 over fi3 even though half of the false positive errors committed
by E3 have already been accounted for by the preceding rule, .R1.
22O Chapter 5 Classification: Alternative Techniques
RIPPER Algorithm
To illustrate the direct method, we consider a widely used rule induction algo-
rithm called RIPPER. This algorithm scalesalmost linearly with the number
of training examples and is particularly suited for building models from data
sets with imbalanced class distributions. RIPPER also works well with noisy
data sets becauseit uses a validation set to prevent model overfitting.
For two-class problems, RIPPER choosesthe majority class as its default
classand learns the rules for detecting the minority class. For multiclass prob-
lems, the classesare ordered according to their frequencies.Let (y,Az, . . . ,U")
be the ordered classes,where 91 is the least frequent class and g" is the most
frequent class. During the first iteration, instances that belong to 91 are Ia-
beled as positive examples,while those that belong to other classesare labeled
as negative examples. The sequentialcovering method is used to generaterules
that discriminate between the positive and negative examples. Next, RIPPER
extracts rules that distinguish y2 frorn other remaining classes. This process
is repeated until we are left with g., which is designated as the default class.
Building the Rule Set After generating a rule, all the positive and negative
examples covered by the rule are eliminated. The rule is then added into the
rule set as long as it does not violate the stopping condition, which is based
on the minimum description length principle. If the new rule increasesthe
total description length of the rule set by at least d bits, then RIPPER stops
adding rules into its rule set (by default, d is chosento be 64 bits). Another
stopping condition used by RIPPER is that the error rate of the rule on the
validation set must not exceed 50%.
5.1 Rule-BasedClassifier22L
Rule Set
=-> -
rl: (P=No,Q=No)
12:(P=No,Q=Yes)==2 'i
==1 .'
r3; (P=Yes,Q=No)
14:(P=Yes,R=Yes,Q=No) ==> -
r5: (P=Yes,R=Yes,Q=Yes)==> a
Example 5.2. Consider the following three rules from Figure 5.5:
12: (P : No) A (Q : Yes) ------+
-1-
r3: (P : Yes) n (R: No) -----+
1
r5: (P : Yes) A (R: Yes) n (Q : Yes) ------+
f
Observe that the rule set always predicts a positive class when the value of Q
is Yes. Therefore, we may simplify the rules as follows:
r2t; (Q : Yes) ----+f
r3: (P : Yes) A (R: No) ------+
1.
222 Chapter 5 Classification: Alternative Techniques
Rul+Based
Classifier:
(GivesBirth=No, => Birds
AerialCreature=Yes)
(GivesBirth=No, => Fishes
AquaticCreature=Yes)
(GivesBirth=Yes)=> Mammals
(GivesBirth=No,
AerialCreature=No,
AquaticCreature=No)
=> Reptiles
( ) => Amphibians
Figure5.6. Classification
rulesextracted
froma decision
treeforthevertebrate problem.
classification
Rule Generation Classification rules are extracted for every path from the
root to one of the leaf nodes in the decision tree. Given a classification rule
r : A -------+
gr, we consider a simplified rule, r' : A' + A, where A/ is obtained
by removing one of the conjuncts in A. The simplified rule with the lowest
pessimistic error rate is retained provided its error rate is lessthan that of the
original rule. The rule-pruning step is repeated until the pessimistic error of
the rule cannot be improved further. Becausesome of the rules may become
identical after pruning, the duplicate rules must be discarded.
Rule Ordering After generating the rule set, C4.5rules usesthe class-based
ordering schemeto order the extracted rules. Rules that predict the same class
are grouped together into the same subset. The total description length for
each subset is computed, and the classesare arranged in increasing order of
their total description length. The class that has the smallest description
5.2 Nearest-Neighborclassifiers 223
length is given the highest priority becauseit is expected to contain the best
* gX
set of rules. The total description length for a class is given by tr"*ception
Imodel, where trexceptionis the number of bits neededto encodethe misclassified
examples, Zmodelis the number of bits neededto encode the model, and g is a
tuning parameter whose default value is 0.5. The tuning parameter depends
on the number of redundant attributes present in the model. The value of the
tuning parameter is small if the model contains many redundant attributes.
+ + + +
(a) 1-nearest
neighbor (b)2-nearestneighbor (c) 3-nearestneighbor
Figure5.7. The1-,2-,and3-nearest
neighbors
ofaninstance.
neighbor
Figure5.8. k-nearest withlarge/c.
classification
5.2.L Algorithm
A high-level summary of the nearest-neighbor classification method is given in
Algorithm 5.2. The algorithm computes the distance (or similarity) between
each test example , : (*',y') and all the training examples (x, g) e D to
determine its nearest-neighborlist, D". Such computation can be costly if the
number of training examples is large. However, efficient indexing techniques
are available to reduce the amount of comoutations needed to find the nearest
neighbors of a test example.
a global model that fits the entire input space. Becausethe classification
decisionsare made locally, nearest-neighborclassifiers(with small values
of /c) are quite susceptible to noise.
knowledge of the classeswith new evidence gathered from data. The use of the
Bayes theorem for solving classification problems will be explained, followed
by a description of two implementations of Bayesian classifiers: naiVe Bayes
and the Bayesian belief network.
This question can be answered by using the well-known Bayes theorem. For
completeness, we begin with some basic definitions from probability theory.
Readerswho are unfamiliar with conceptsin probability may refer to Appendix
C for a brief review of this topic.
Let X and Y be a pair of random variables. Their joint probability, P(X :
r,Y : g), refers to the probability that variable X will take on the value
r and variable Y will take on the value g. A conditional probability is the
probability that a random variable will take on a particular value given that the
outcome for another random variable is known. For example, the conditional
probability P(Y :UlX: r) refers to the probability that the variable Y will
take on the value g, given that the variable X is observedto have the value r.
The joint and conditional probabilities for X and Y are related in the following
way:
P(x,Y) : P(Ylx) x P(X) : P(XIY) x P(Y). (5.e)
Rearranging the last two expressionsin Equation 5.9 leads to the following
formula, known as the Bayes theorem:
P(xlY)P(Y)
P(Ylx): (5.10)
P(X)
The Bayes theorem can be used to solve the prediction problem stated
at the beginning of this section. For notational convenience, let X be the
random variable that represents the team hosting the match and Y be the
random variable that representsthe winner of the match. Both X and Y can
5.3 Bayesian Classifiers 229
take on values from the set {0,1}. We can summarize the information given
in the problem as follows:
P (X : rl Y :1 ) x P( Y : 1)
P(Y:llx : 1) :
P(X :1)
P(X :LlY :1) x P(Y : 1)
P ( X : ! , Y : 1 )+ P ( X : 1 , Y : 0 )
P ( X : L I Y: 1 ) x P ( Y : 1 )
P (X : IIY :I) P( Y : 1)* P( X : r lY :O) P( Y : 0)
0.75x 0.35
0.75x0.35+0.3x0.65
: 0.5738.
where the law of total probability (seeEquation C.5 on page 722) was applied
in the secondline. Furthermore, P(Y :OlX : 1) : t - P(Y : llx - 1) :
0.4262. Since P(Y : llx : 1) > P(Y : OlX : 1), Team t has a better
chance than Team 0 of winning the next match.
Before describing how the Bayes theorem can be used for classification, let
us formalize the classification problem from a statistical perspective. Let X
denote the attribute set and Y denote the class variable. If the class variable
has a non-deterministic relationship with the attributes, then we can treat
X and Y as random variables and capture their relationship probabilistically
using P(YIX). This conditional probability is also known as the posterior
probability for Y, as opposed to its prior probability, P(Y).
During the training phase, we need to learn the posterior probabilities
P(ylX) for every combination of X and Y based on information gathered
from the training data. By knowing these probabilities, a test record X' can
be classified by finding the class Yt that maximizes the posterior probability,
230 Chapter 5 Classification: Alternative Techniques
a."'
"""""od"
Figure5.9.Training
setforpredicting problem.
theloandefault
Suppose we are given a test record with the following attribute set: X :
(HoneOwner: No, Marital Status : Married, Annual Income : $120K). To
classify the record, we need to compute the posterior probabilities P(YeslX)
and P(NolX) basedon information available in the training data. If P(YeslX) >
P(NolX), then the record is classified as Yes; otherwise, it is classifiedas No.
Estimating the posterior probabilities accurately for every possible combi-
nation of class labiel and attribute value is a difficult problem because it re-
quires a very large training set, even for a moderate number of attributes. The
Bayes theorem is useful becauseit allows us to expressthe posterior probabil-
ity in terms of the prior probability P(f), the class-conditional probability
P(X|Y), and the evidence,P(X):
P( xlY) x P( Y)
P(ylx): (5.11)
P(x)
When comparing the posterior probabilities for different values of Y, the de-
nominator term, P(X), is always constant, and thus, can be ignored. The
5.3 BayesianClassifiers 23L
prior probability P(f) can be easily estimated from the training set by com-
puting the fraction of training records that belong to each class. To estimate
the class-conditionalprobabilities P(Xlf), we present two implementations of
Bayesian classification methods: the naiVe Bayes classifier and the Bayesian
belief network. These implementations are described in Sections 5.3.3 and
5.3.5,respectively.
&
P ( X I Y: a ) : f r l x S v : 11, (5.12)
i:l
Conditional Independence
Before delving into the details of how a naive Bayes classifier works, let us
examine the notion of conditional independence. Let X, Y, and Z denote
three sets of random variables. The variables in X are said to be conditionally
independent of Y, given Z, 1f the following condition holds:
P\X,Y,Z)
P(x,Ylz) :
P(Z)
P (
-FEqX .Y , Z ) , . P ( Y . Z )
^
P(z)
P(xlY,z) x P(vlz)
P(xlz)x P(Ylz), (5.14)
where Equation 5.13 was used to obtain the last line of Equation 5.14.
Since P(X) is fixed for every Y, it is sufficient to choosethe class that maxi-
mizes the numerator term, p(V)l[i:tP(X,lY). In the next two subsections,
we describe several approaches for estimating the conditional probabilities
P(X,lY) for categorical and continuous attributes.
There are two ways to estimate the class-conditional probabilities for contin-
uous attributes in naive Bayes classifiers:
1. We can discretize each continuous attribute and then replace the con-
tinuous attribute value with its corresponding discrete interval. This
approach transforms the continuous attributes into ordinal attributes.
The conditional probability P(X,IY : U) is estimated by computing
the fraction of training records belonging to class g that falls within the
corresponding interval for Xi. The estimation error depends on the dis-
cretization strategy (as described in Section 2.3.6 on page 57), as well as
the number of discrete intervals. If the number of intervals is too large,
there are too few training records in each interval to provide a reliable
estimate for P(XrlY). On the other hand, if the number of intervals
is too small, then some intervals may aggregate records from different
classesand we may miss the correct decision boundary.
., tt:j)2
_(tt_
zofi
P(Xi: r,ilY : y) : -)- exp (5.16)
1/2troii
r 2 5 + 1 0 0 + 7 0 + . . . + 7 5:
110
(
, ( 1 2 5 1 1 0 ) 2+ ( 1 0 0- 1 1 0 ) 2+ . . . + ( 7 5- 1 1 0 ) 2
-
:2975
7(6)
s: t/2975:54.54.
234 Chapter 5 Classification: Alternative Techniques
Given a test record with taxable income equal to $120K, we can compute
its class-conditionalprobability as follows:
:
P(rncome=12olNo) : 0.0072.
6h.b4)"*p-95#f
f rtle
P ( * o< X ; I r i * e l y : y r 1 : I fqo;ttij,oij)dxi
J:r'
= f (rt; ttti,o,ii) x e. (5.17)
Consider the data set shown in Figure 5.10(a). We can compute the class-
conditional probability for each categorical attribute, along with the sample
mean and variance for the continuous attribute using the methodology de-
scribed in the previous subsections. These probabilities are summarized in
Figure 5.10(b).
To predict the class label of a test record ;q : (HomeOwner:No, Marital
Status : Married, Income : $120K), we need to compute the posterior prob-
abilities P(UolX) and P(YeslX). Recall from our earlier discussionthat these
posterior probabilities can be estimated by computing the product between
the prior probability P(Y) and the class-conditionalprobabilitiesll P(X,lY),
which corresponds to the numerator of the right-hand side term in Equation
5.15.
The prior probabilities of each class can be estimated by calculating the
fraction of training records that belong to each class. Since there are three
records that belong to the classYes and sevenrecords that belong to the class
5.3 Bayesian Classifiers 235
P(HomeOwner=YeslNo) = 317
P(HomeOwner=NolNo) = 4fl
P(HomeOwner=YeslYes) =0
P(HomeOwner=NolYes) =1
P(Marital = 2n
Status=SinglelNo)
Yes 125K
No)= 1/7
P(MaritalStatus=Divorcedl
No 100K = 4t7
P(MaritalStatus=MarriedlNo)
No 70K = 2/3
P(MaritalStatus=SinglelYes)
Yes 120K = 1/3
P(MaritalStatus=DivorcedlYes)
=0
P(MaritalStatus=MarriedlYes)
No 95K
No 60K ForAnnualIncome:
Yes 220K lf class=No:samplemean=110
No 85K samplevariance=2975
No 75K samplemedn=90
lf class=Yes:
samplevariance=2S
No 90K
(a) (b)
Figure
5.10.Thenalve
Bayes
classifier problem.
fortheloanclassification
No, P(Yes) :0.3 and P(no) :0.7. Using the information provided in Figure
5.10(b), the class-conditionalprobabilities can be computed as follows:
The naive Bayes classifier will not be able to classify the record. This prob-
lem can be addressed by using the m-estimate approach for estimating the
conditional probabilities :
!!
P (r,l a- ) : ?s! , (5.18)
n+Tn
where n is the total number of instances from class 3ry,n" is the number of
training examples from class gi that take on the value ri, rrl is a parameter
known as the equivalent sample size, and p is a user-specifiedparameter. If
there is no training set available (i.e., n:0), then P(rilyi) : p. Therefore
p can be regarded as the prior probability of observing the attribute value
ri among records with class 97. The equivalent sample size determines the
tradeoff between the prior probability p and the observed probability n.f n.
In the example given in the previous section, the conditional probability
P(Status : MarriedlYes) : 0 because none of the training records for the
class has the particular attribute value. Using the m-estimate approach with
m:3 and p :113, the conditional probability is no longer zero:
If we assumep : If 3 for all attributes of class Yes and p : 213 for all
attributes of class No. then
o They are robust to isolated noise points becausesuch points are averaged
out when estimating conditional probabilities from data. Naive Bayes
classifiers can also handle missing values by ignoring the example during
model building and classification.
P ( A : O l y : 0 ) P ( B : O l y : O ) P ( Y: 0 )
P(Y:0lA:0, B : 0) :
P(A:0, B : 0)
0 . 1 6x P ( Y : 0 )
P(A:0, B : 0)'
P ( A : O l y : I ) P ( B : O l y: l ) P ( Y : 1 )
P(Y : IlA:0,8 : 0) :
P(A:0, B : 0)
0 . 3 6x P ( Y 1 )
:
P(A:0, B : 0)'
If P(Y - 0) : P(Y : 1), then the naiVe Bayes classifier would assign
the record to class 1. However, the truth is,
P ( A : 0 ,B : O l Y : 0 ) : P ( A : 0l)' : 0) : 0.4,
P ( A : 0 , 8 : O l Y : 0 ) P ( Y: 0 )
P(Y :0lA:0, B : 0) :
P(A:0,8:0)
0 . 4x P ( Y : 0 )
P(A :0,8 : 0 )'
which is larger than that for Y : 1. The record should have been
classifiedas class 0.
\, Crocodile
\
\
\
\
\
\
\
\
\
\
\
\
\
5 10 tu
Length,*
Figure5.11.Comparing
thelikelihood of a crocodile
functions andanalligator.
:
P(Xlcrocodile) ( 5.1e)
#"""0 1
:
P(Xlnrri.gator) ;(ry)'l (5.20)
#""*o[ "(ry)')
Figure 5.11 shows a comparison between the class-conditionalprobabilities
for a crocodile and an alligator. Assuming that their prior probabilities are
the same, the ideal decision boundary is located at some length i such that
(ft-rb\2
:\ /i-r2\2
\ , / , /'
which can be solved to yield f : 13.5. The decision boundary for this example
is located halfway between the two means. r
24O Chapter 5 Classification: Alternative Techniques
Figure probabilistic
5.12.Representing relationships
usingdirected graphs.
acyclic
When the prior probabilities are different, the decision boundary shifts
toward the class with lower prior probability (see Exercise 10 on page 319).
Furthermore, the minimum error rate attainable by any classifieron the given
data can also be computed. The ideal decision boundary in the preceding
example classifies all creatures whose lengths are less than ft as alligators and
those whose lengths are greater than 0 as crocodiles. The error rate of the
classifier is given by the sum of the area under the posterior probability curve
for crocodiles (from length 0 to i) and the area under the posterior probability
curve for alligators (from f to oo):
Model Representation
1. If a node X does not have any parents, then the table contains only the
prior probability P(X).
2. If a node X has only one parent, Y, then the table contains the condi-
tional probability P(XIY).
3. If a node X has multiple parents, {Yt,Yz, . . . ,Yn}, then the table contains
the conditionalprobability P(XlY,Yz,. . ., Yr.).
242 Chapter 5 Classification: Alternative Techniques
Hb=Yes
HD=Yes
D=Healthy 0.2
E=Yes D=Unhealthy 0.85
D=Heatthy 0.25
E=Yes 0.45
D=Unhealthl
E=No
D=Healthy 0.55
E=No
0.75 CP=Yes
D=Unhealth!
HD=Yes
Hb=Yes
0.8
HD=Yes
Hh=Nn
0.6
HD=No
0.4
Hb=Yes
HD=No
Hb=No
0.1
Figure5.13.A Bayesian
beliefnetwork
fordetecting
heartdisease in patients.
andheartburn
Model Building
Model building in Bayesiannetworks involves two steps: (1) creating the struc-
ture of the network, and (2) estimating the probability values in the tables
associatedwith each node. The network topology can be obtained by encod-
ing the subjective knowledge of domain experts. Algorithm 5.3 presents a
systematic procedure for inducing the topology of a Bayesian network.
Example 5.4. Consider the variables shown in Figure 5.13. After performing
Step 1, Iet us assume that the variables are ordered in the following way:
(E,D,HD,H\,CP,BP). From Steps 2 to 7, starting with variable D, we
obtain the following conditional probabilities:
. P(DIE) is simplified to P(D).
Supposewe are interested in using the BBN shown in Figure 5.13 to diagnose
whether a person has heart disease. The following cases illustrate how the
diagnosis can be made under different scenarios.
Without any prior information, we can determine whether the person is likely
to have heart disease by computing the prior probabilities P(HD : Yes) and
P(HD: No). To simplify the notation, let a € {Yes,No} denote the binary
values of Exercise and B e {Healthy,Unhealthy} denote the binary values
of Diet.
P(HD:ves) : ttP(Hn
: Y e s l E : ( t , D : P ) P ( E: a , D : 0 )
d13
: ttp(uo : yesl,O
: (t,D: ilP(E : a)P(D: g)
aR
0 . 2 5x 0 . 7x 0 . 2 5+ 0 . 4 5x 0 . 7x 0 . 7 5 + 0 . 5 5x 0 . 3x 0 . 2 5
+ 0.75x 0.3 x 0.75
0.49.
Since P(HD - no) - 1 - P(ttO : yes) : 0.51, the person has a slightly higher
chance of not getting the disease.
5.3 Bayesian Classifiers 245
If the person has high blood pressure)we can make a diagnosis about heart
disease by comparing the posterior probabilities, P(HD : YeslBP : High)
against P(ttO : Nolnt : High). To do this, we must compute P(Be : High):
P (n e:H i g h ) : frl n r
: HighlHD:7) p( HD
:7)
where 7 € {Yes, No}. Therefore, the posterior probability the person has heart
diseaseis
Supposewe are told that the person exercisesregularly and eats a healthy diet.
How does the new information affect our diagnosis? With the new information,
the posterior probability that the person has heart diseaseis
The model therefore suggests that eating healthily and exercising regularly
may reduce a person's risk of getting heart disease.
Characteristics of BBN
3 . Bayesian networks are well suited to dealing with incomplete data. In-
stanceswith missing attributes can be handled by summing or integrat-
ing the probabilities over all possible values of the attribute.
5.4.1 Perceptron
Consider the diagram shown in Figure 5.14. The table on the left shows a data
set containing three boolean variables (*t, ,r, 13) and an output variable, gr,
that takes on the value -1 if at least two of the three inputs arezero, and +1
if at least two of the inputs are greater than zero.
X1 X2 x3 v Input
-1 nodes
1 0 0
1 0 1 1
1 1 0 1
1 1 1 1
0 0 "l -1
0 1 0 -1
0 1 1 1
0 0 0 -1
(a)
(a) Data
Dataset.
set. (b) perceptron.
Figure5.14.Modeling
a boolean usinga perceptron.
function
- t),
0 : s i ' g n ( w d r d+ w d - t . x d - t + . . . + w z r z I w p 1 (5.22)
w h e r eu ) r t l r 2 t . . . , 1 1 )adr.e t h e w e i g h t so f t h e i n p u t l i n k s a n d 1 1 ,r 2 t . . . ) r d a r e
the input attribute values. The sign function, which acts as an activation
function for the output neuron, outputs a value *1 if its argument is positive
and -1 if its argument is negative. The perceptron model can be written in a
more compact form as follows:
where u)0: -t, frl: I, and w'x is the dot product betweenthe weight vector
w and the input attribute vector x.
where tr(k) is the weight parameter associatedwith the i'h input link after the
kth ileration, ) is a parameter known as the learning rate, and rii is the
value of lhe jth attribute of the training example 4. The justification for the
weight update formula is rather intuitive. Equation 5.24 shows that the new
weight ?r(k+l) is a combination of the old weight tr(ft) and a term proportional
5.4 Artificial Neural Network (ANN) 249
to the prediction error, (g - i). If the prediction is correct, then the weight
remains unchanged. Otherwise, it is modified in the following ways:
In the weight update formula, Iinks that contribute the most to the error term
are the ones that require the largest adjustment. However, the weights should
not be changed too drastically becausethe error term is computed only for
the current training example. Otherwise, the adjustments made in earlier
iterations will be undone. The learning rate ), a parameter whose value is
between 0 and 1, can be used to control the amount of adjustments made in
each iteration. If ,\ is close to 0, then the new weight is mostly influenced
by the value of the old weight. On the other hand, if ) is close to 1, then
the new weight is sensitive to the amount of adjustment performed in the
current iteration. In some cases)an adaptive ) value can be used; initially, ,\
is moderately large during the first few iterations and then gradually decreases
in subsequentiterations.
The perceptron model shown in Equation 5.23 is linear in its parameters
w and attributes x. Because of this, the decision boundary of a perceptron,
which is obtained by setting 0 : 0, is a linear hyperplane that separatesthe
data into two classes,-1 and *1. Figure 5.15 shows the decision boundary
25O Chapter 5 Classification: Alternative Techniques
0.5
x1
Figure5.15.Perceptron
decision forthedatagivenin Figure
boundary 5.14,
obtained by applying the perceptron learning algorithm to the data set given in
Figure 5.14. The perceptron learning algorithm is guaranteedto convergeto an
optimal solution (as long as the learning rate is sufficiently small) for linearly
separable classification problems. If the problem is not linearly separable,
the algorithm fails to converge. Figure 5.16 shows an example of nonlinearly
separable data given by the XOR function. Perceptron cannot find the right
solution for this data becausethere is no linear hyperplane that can perfectly
separate the training instances.
1.5
Xe 0.5
-0.5L
-0.5 0.5 1.5
x1
Figure problem.
5.16.XORclassification Nolinear
hyperplane thetwoclasses.
canseparate
5.4 Artificial Neural Network (ANN) 251
1. The network may contain several intermediary layers between its input
and output layers. Such intermediary layers are called hidden layers
and the nodes embedded in these layers are called hidden nodes. The
resulting structure is known as a multilayer neural network (see Fig-
ure 5.17). In a feed-forward neural network, the nodes in one layer
Figure5.17.Example
of a multilayer
feed{onrvard neural
artificial (ANN).
network
are connected only to the nodes in the next layer. The perceptron is a
single-layer, feed-forward neural network because it has only one layer
of nodes-the output layer that performs complex mathematical op-
erations. fn a recurrent neural network, the links may connect nodes
within the same layer or nodes from one layer to the previous layers.
2. The network may use types of activation functions other than the sign
function. Examples of other activation functions include linear, sigmoid
(logistic), and hyperbolic tangent functions, as shown in Figure 5.18.
These activation functions allow the hidden and output nodes to produce
output values that are nonlinear in their input parameters.
Sign function
-1.5
-0.5 0 0.s 1 -1 -05 0 0.5
Figure5,18.Types functions
ofactivation inartificial networks.
neural
ample, consider the XOR problem described in the previous section. The in-
stancescan be classifiedusing two hyperplanes that partition the input space
into their respective classes,as shown in Figure 5.19(a). Because a percep-
tron can create only one hyperplane, it cannot find the optimal solution. This
problem can be addressed using a two-layer, feed-forward neural network, as
shown in Figure 5.19(b). Intuitively, we can think of each hidden node as a
perceptron that tries to construct one of the two hyperplanes, while the out-
put node simply combines the results of the perceptrons to yield the decision
boundary shown in Figure 5.19(a).
To learn the weights of an ANN model, we need an efficient algorithm
that converges to the right solution when a sufficient amount of training data
is provided. One approach is to treat each hidden node or output node in
the network as an independent perceptron unit and to apply the same weight
update formula as Equation 5.24. Obviously, this approach will not work
because we lack a priori, knowledge about the true outputs of the hidden
nodes. This makes it difficult to determine the error term, (gr- f), associated
5.4 Artificial Neural Network (ANN) 253
1.5
X z0 5
0- 0 . 5
0.5
x1
Figure5.19.A two-layer,
feed{orward
neural fortheXORproblem.
network
with each hidden node. A methodology for learning the weights of a neural
network based on the gradient descent approach is presented next.
1 'A{
:
E(w) (5.25)
il,rr,-o)2.
;-l
Note that the sum of squared errors depends on w becausethe predicted class
f is a function of the weights assignedto the hidden and output nodes. Figure
5.20 shows an example of the error surface as a function of its two parameters,
to1 and 'u2. This type of error surface is typically encountered when Qi is a
linear function of its parameters, w. If we replace Q : w 'x into Equation
5.25, then the error function becomesquadratic in its parameters and a global
minimum solution can be easily found.
In most cases)the output of an ANN is a nonlinear function of its param-
eters because of the choice of its activation functions (e.g., sigmoid or tanh
function). As a result, it is no longer straightforward to derive a solution for
w that is guaranteed to be globally optimal. Greedy algorithms such as those
based on the gradient descent method have been developed to efficiently solve
the optimization problem. The weight update formula used by the gradient
254 Chapter 5 Classification: Alternative Techniques
E(w1,w2)
1.8
1.6
1.4
1.2
1
I
0'l
w1
5,20.Enorsudace
Figure E(w1,w2)fora two-parameter
model.
W r; + ' l I ; - .OE(w)
A---^ (5.26)
r
dw.i
where ) is the Iearning rate. The secondterm states that the weight should be
increasedin a direction that reducesthe overall error term. However, because
the error function is nonlinear, it is possible that the gradient descentmethod
may get trapped in a local minimum.
The gradient descent method can be used to learn the weights of the out-
put and hidden nodes ofa neural network. For hidden nodes, the computation
is not trivial becauseit is difficult to assesstheir error Lerm,0Ef 0t17, without
knowing what their output values should be. A technique known as back-
propagation has been developed to address this problem. There are two
phasesin each iteration of the algorithm: the forward phase and the backward
phase. During the forward phase, the weights obtained from the previous iter-
ation are used to compute the output value of each neuron in the network. The
computation progressesin the forward direction; i.e., outputs of the neurons
at level k are computed prior to computing the outputs at level /c + 1. Dur-
ing the backward phase, the weight update formula is applied in the reverse
direction. In other words, the weights at level k + 7 arc updated before the
weights at level k are updated. This back-propagation approach allows us to
use the errors for neurons at layer k + t to estimate the errors for neurons at
Iaver k.
5.4 Artificial Neural Network (ANN) 255
3. The network topology (e.g., the number of hidden layers and hidden
nodes, and feed-forward or recurrent network architecture) must be se-
lected. Note that the target function representation depends on the
weights of the links, the number of hidden nodes and hidden layers, bi-
ases in the nodes, and type of activation function. Finding the right
topology is not an easy task. One way to do this is to start from a fully
connected network with a sufficiently large number of nodes and hid-
den layers, and then repeat the model-building procedure with a smaller
number of nodes. This approach can be very time consuming. Alter-
natively, instead of repeating the model-building procedure, we could
remove some of the nodes and repeat the model evaluation procedure to
select the right model complexity.
1. Multilayer neural networks with at least one hidden layer are univer-
sal approximators; i.e., they can be used to approximate any target
functions. Since an ANN has a very expressivehypothesis space,it is im-
portant to choosethe appropriate network topology for a given problem
to avoid model overfitting.
256 Chapter 5 Classification: Alternative Techniques
.t. Neural networks are quite sensitive to the presenceof noise in the train-
ing data. One approach to handling noise is to use a validation set to
determine the generalization error of the model. Another approach is to
decreasethe weight by some factor at each iteration.
4 . The gradient descent method used for learning the weights of an ANN
often convergesto somelocal minimum. One way to escapefrom the local
minimum is to add a momentum term to the weight update formula.
tr
ir. Training an ANN is a time consuming process,especiallywhen the num-
ber of hidden nodes is large. Nevertheless,test examplescan be classified
rapidly.
Figure 5.21 shows a plot of a data set containing examples that belong to
two different classes,represented as squares and circles. The data set is also
linearly separable; i.e., we can find a hyperplane such that all the squares
reside on one side of the hyperplane and all the circles reside on the other
D.D Support Vector Machine (SVM) 257
oo
II o
o
I
oo
T
oo
T
I
TT ooo
o
T lr OO
T TI oo
I
oo
o
o
Figure5.21.Possible
decision
boundaries
fora linearly dataset.
separable
side. However, as shown in Figure 5.21, there are infinitely many such hyper-
planes possible. Although their training errors are zerol there is no guarantee
that the hyperplaneswill perform equally well on previously unseenexamples.
The classifier must choose one of these hyperplanes to represent its decision
boundary, based on how well they are expected to perform on test examples.
To get a clearer picture of how the different choicesof hyperplanes affect the
generalization errors, consider the two decision boundaries, ,B1and 82, shown
in Figure 5.22. Both decision boundaries can separate the training examples
into their respective classeswithout committing any misclassification errors.
Each decision boundary B; is associatedwith a pair of hyperplanes, denoted
as bi1 and bi2, respectively. b61is obtained by moving a parallel hyperplane
away from the decisionboundary until it touchesthe closestsquare(s),whereas
b;2 is obtained by moving the hyperplane until it touches the closest circle(s).
The distance between these two hyperplanes is known as the margin of the
classifier. From the diagram shown in Figure 5.22,notice that the margin for
.B1 is considerably larger than that for Bz. In this example, 81 turns out to
be the maximum margin hyperplane of the training instances.
+---- - - - - - - - -- - -- t
brr marginfor 81 bp
Figure5.22.Margin
ofa decision
boundary.
any slight perturbations to the decision boundary can have quite a significant
impact on its classification. Classifiersthat produce decision boundaries with
small margins are therefore more susceptible to model overfitting and tend to
generalizepoorly on previously unseen examples.
A more formal explanation relating the margin of a linear classifier to its
generalization error is given by a statistical learning principle known as struc-
tural risk minimization (SRM). This principle provides an upper bound to
the generalization error of a classifier (R) in terms of its training error (,R"),
the number of training examples (l/), and the model complexity otherwise
known as its capacity (h). More specifically,with a probability of 1 - q, the
generalization error of the classifier can be at worst
R1R.+r(*, (5.27)
w.x*b:0, (5.28)
\n/.Xo*b:0,
w'xbfb:0.
w. (xa- xr) : 0,
260 Chapter 5 Classification: Alternative Techniques
Figure5.23.Decision
boundary
andmargin
ofSVM.
where k > 0. Similarly, for any circle x. located below the decision boundary,
we can show that
w.Xc *b:k" (5.30)
where k' < 0. If we label all the squares as class f 1 and all the circles as
class -1, then we can predict the class label gr for any test example z in the
following way:
I l, if w.z*b>0;
(5.31)
':t -t. ifw.z+b<0.
Consider the square and the circle that are closest to the decision boundary.
Since the square is located above the decision boundary, it must satisfy Equa-
tion 5.29 for some positive value k, whereas the circle must satisfy Equation
5.5 Support Vector Machine (SVM) 261
5.30 for some negative value kt. We can rescale the parameters w and b of
the decision boundary so that the two parallel hyperplanes b;1 and bi2 can be
expressed as follows:
b i 1: w . x * b : 1 , (5.32)
bn; w 'x*b--1. (5.33)
The margin of the decision boundary is given by the distance between these
two hyperplanes. To compute the margin, Iet x1 be a data point located on
br1and x2 be a data point on bi2, as shown in Figure 5.23. Upon substituting
these points into Equations 5.32 and 5.33, the margin d can be computed by
subtracting the second equation from the first equation:
w ' ( x r - x z ): 2
l l w lxl d : 2
,.
(5.34)
ll*ll'
Learning a Linear SVM Model
The training phase of SVM involves estimating the parameters w and b of the
decision boundary from the training data. The parameters must be chosenin
such a way that the following two conditions are met:
These conditions impose the requirements that all training instances from
class gr : 1 (i.e., the squares) must be located on or above the hyperplane
w.x* b: L, while those instancesfrom classU: -I (i.e.,the circles)must
be located on or below the hyperplane w .x * b - -1. Both inequalities can
be summarized in a more comoact form as follows:
Although the preceding conditions are also applicable to any linear classi-
fiers (including perceptrons), SVM imposesan additional requirement that the
margin of its decision boundary must be maximal. Maximizing the margin,
however, is equivalent to minimizing the following objective function:
f r * r' 2: l l w l l 2 (5.37)
262 Chapter 5 Classification: Alternative Techniques
Definition 5.1 (Linear SVM: Separable Case). The learning task in SVM
can be formalized as the following constrained optimization problem:
mln
, -Il*ll'
subject
to ,it* i * ,, - ,, ,i: r,2,.. . ,N.
Since the objective function is quadratic and the constraints are linear in
the parameters w and b, this is known as a convex optimization problem,
which can be solved using the standard Lagrange multiplier method. Fol-
lowing is a brief sketch of the main ideas for solving the optimization problem.
A more detailed discussionis given in Appendix E.
First, we must rewrite the objective function in a form that takes into
account the constraints imposed on its solutions. The new objective function
is known as the Lagrangian for the optimization problem:
where the parameters ); are called the Lagrange multipliers. The first term in
the Lagrangian is the same as the original objective function, while the second
term captures the inequality constraints. To understand why the objective
function must be modified, consider the original objective function given in
Equation 5.37. It is easy to show that the function is minimized when w : 0, a
null vector whose components are all zeros. Such a solution, however, violates
the constraints given in Definition 5.1 because there is no feasible solution
for b. The solutions for w and b are infeasible if they violate the inequality
constraints; i.e., if Ailw-xi+b) - 1 < 0. The Lagrangian given in Equation 5.38
incorporates this constraint by subtracting the term from its original objective
function. Assuming that .\; > 0, it is clear that any infeasible solution may
only increasethe value of the Lagrangian.
To minimize the Lagrangian, we must take the derivative of ,Lp with respect
to w and b and set them to zero:
l/
OL, - U^+ w : \-.
) Ai?Jtxi, (5.3e)
0w ^Lt
t-1
1V
oLo - U^+\ -
) A;tt;:U. (5.40)
ab ,Lt
i,:1
5.5 Support Vector Machine (SVM) 263
Because the Lagrange multipliers are unknown, we still cannot solve for w and
b. If Definition 5.1 contains only equality instead of inequality constraints, then
we can use the ly' equations from equality constraints along with Equations
5.39 and 5.40 to find the feasible solutions for w, b, and ).;. Note that the
Lagrange multipliers for equality constraints are free parameters that can take
any values.
One way to handle the inequality constraints is to transform them into a
set of equality constraints. This is possible as long as the Lagrange multipliers
are restricted to be non-negative. Such transformation leads to the following
constraints on the Lagrange multipliers, which are known as the Karush-Kuhn-
T\rcker (KKT) conditions:
);)0, (5.41)
\u[sn(* 'xt * b) - 1] : O. (5.42)
At first glance, it may seem that there are as many Lagrange multipli-
ers as there are training instances. It turns out that many of the Lagrange
multipliers become zero after applying the constraint given in trquation 5.42.
The constraint states that the Lagrange multiplier Aamust be zero unless the
training instance x6 satisfies the equation At(w .xt I b) : t. Such training
instance, with )i ) 0, lies along the hyperplanes bi1 or b.i2and is known as a
support vector. taining instancesthat do not reside along these hyperplanes
have )6:0. Equations 5.39 and5.42 also suggestthat the parametersw and
b, which define the decision boundary, depend only on the support vectors.
Solving the preceding optimization problem is still quite a daunting task
becauseit involves a large number of parameters: w, b, and )a. The problem
can be simplified by transforming the Lagrangian into a function of the La-
grange multipliers only (this is known as the dual problem). To do this, we
first substitute Equations 5.39 and 5.40 into Equation 5.38. This will lead to
the following dual formulation of the optimization problem:
,A|I
The key differences between the dual and primary Lagrangians are as fol-
lows:
1. The dual Lagrangian involves only the Lagrange multipliers and the
training data, while the primary Lagrangian involves the Lagrange mul-
tipliers as well as parameters of the decision boundary. Nevertheless,the
solutions for both optimization problems are equivalent.
264 Chapter 5 Classification: Alternative Techniques
2. The quadratic term in Equation 5.43 has a negative sign, which means
that the original minimization problem involving the primary Lagrangian,
Lp, has turned into a maximization problem involving the dual La-
grangian, ,L2.
For large data sets, the dual optimization problem can be solved using
numerical techniques such as quadratic programming, a topic that is beyond
the scope of this book. Once the );'s are found, we can use Equations 5.39
and 5.42 to obtain the feasible solutions for w and b. The decision boundary
can be expressed as follows:
/N \
(f\yn*t'*)+b:0. (5.44)
\- /
b is obtained by solving Equation 5.42 for the support vectors. Becausethe )1's
are calculated numerically and can have numerical errors, the value computed
for b may not be unique. Instead it depends on the support vector used in
Equation 5.42. In practice, the averagevalue for b is chosento be the parameter
of the decision boundary.
Example 5.5. Consider the two-dimensional data set shown in Figure 5.24,
which contains eight training instances. Using quadratic programming, we can
solve the optimization problem stated in Equation 5.43 to obtain the Lagrange
multiplier .\6for each training instance. The Lagrange multipliers are depicted
in the last column of the table. Notice that only the fi.rst two instances have
non-zero Lagrange multipliers. These instances correspond to the support
vectors for this data set.
Let w : (1q,w2) and b denote the parameters of the decision boundary.
Using Equation 5.39, we can solve for w1 and w2 in the following way:
wr : -1
D \ n r o r o r : 6 5 . 5 6 2 L x 1 x 0 . 3 8 5 8 + 6 5 . 5 6 2x 1 x 0 ' 4 8 7 r : - 6 ' 6 4 .
z
\-, \;Apn:65.562L x 1x
w2 : ) 7 6 5 . 5 6 2 1 x- 1 x 0 . 6 1 1: - 9 ' 3 2 .
0 . 4 6 8+
2
The bias term b can be computed using Equation 5.42 for each support vector:
Lagrange
X1 X2 v Multiplier
0.3858 0.4687 1 65.5261
0.4871 0.611 -1 65.5261
0.9218 0.4103 -1 0
o.7382 0.8936 -1 0
0.1763 0.0579 1 0
o.4057 0.3529 1 0
0.9355 0.8132 -1 0
0.2146 0.0099 1 0
1
0.9
-6.64 x1 - 9.32 x2 + 7.93 = 0 tr
0.8 tr
0.7
0.6 tr
s 0.5
o
0.4 n
0.3
o
o.2
0.1
0
o
0 0.2 o.4 0.6 0.8 1
X1
Figure
5.24.Example
ofa linearly
separable
dataset.
Once the parameters of the decision boundary are found, a test instance z
is classified as follows:
/N \
n
o\,,o
margin
tore2'l o
r oo
r al'', o
r r l'\,, o
llf'. o OO
OO
o
!t.
o
['? o
f; ;;;;i" ro,,
i,--'o',
Figure
5.25,Decision
boundary
ofSVMforthenonseparable
case.
5.5 Support Vector Machine (SVM) 267
w.x+b=0
1.2
trtrtr
tr
t1
LI
0.8
tr
N
X .w.x+b=-1+(
Figure
5,26.Slack fornonseparable
variables data.
While the original objective function given in Equation 5.37 is still appli-
cable, the decision boundary .B1 no longer satisfies all the constraints given
in Equation 5.36. The inequality constraints must therefore be relaxed to ac-
commodate the'nonlinearly separable data. This can be done by introducing
positive-valued slack variables ({) into the constraints of the optimization
problem, as shown in the following equations:
v/'xi+b>7-€n ify6-I,
w.xi+b<-1+€, if ya: -1, (5.45)
where Vz : {6 > 0.
To interpret the meaning of the slack variables {a, consider the diagram
shown in Figure 5.26. The circle P is one of the instances that violates the
constraintsgiven in Equation 5.35. Let w.x* b: -7 *{ denote a line that
is parallel to the decision boundary and passesthrough the point P. It can be
shown that the distance between this line and the hyperplane w'x * b: -L
is {/llwll. Thus, { provides an estimate of the error of the decision boundary
on the training example P.
In principle, we can apply the same objective function as before and impose
the conditions given in Equation 5.45 to find the decision boundary. However,
268 Chapter 5 Classification: Alternative Techniques
T\
,ll \
\
o
a\, o
ll
t.,, I
\,I I
I
I r-\' . r
I ll.
P
T I og\
I o
I
o
Figure5.27.A decision
boundary
thathasa widemargin
butlargetraining
error.
N
.
llwll2
,f(*):#* c(D,to)*,
i,:L
.l/ N ,^/
L p : | l lOw l l 2 +' c* t FL \,1 - S-. .
- r . -) - S-\
(5.46)
rl "ll LAt|at(w.xi +b) 1+€ri \u&,
i:7 i:I i:l
where the first two terms are the objective function to be minimized, the third
term representsthe inequality constraints associatedwith the slack variables,
D.O Support Vector Machine (SVM) 269
and the last term is the result of the non-negativity requirements on the val-
ues of {,;'s. F\rrthermore, the inequality constraints can be transformed into
equality constraints using the following KKT conditions:
Note that the Lagrange multiplier ,\; given in Equation 5.48 is non-vanishing
only if the training instance resides along the lines w'x, * b : il or has
€r > O. On the other hand, the Lagrange multipliers;.ri given in Equation 5.49
arezero for any training instances that are misclassified(i.e., having {z > 0).
Setting the first-order derivative of ,L with respect to w, b, and {; to zero
would result in the following equations:
-^r .lr
AL s-.
: t \&r.ru. (5,50)
'' -
) AiU&ii:u 1uj
A u tr: /-t
i:7
N .lr
AL : - t \ r a r : Q
aI)nr,:0. (551)
0b i:t i:l
AL - (5"52)
C - \t - t-tt- Q 4 \tl l.tt: C.
otr,
Substituting Equations 5.50, 5.51, and 5.52 into the Lagrangian will pro-
duce the following dual Lagrangian:
1.----
Lp : iD,xoxtoiaixi.xi + Cl€t
z-
L,J z
-\ ^o{r,(\^tot*0. xi f b) - 1 + €,}
-\,-\;)€'
Nl
which turns out to be identical to the dual Lagrangian for linearly separable
data (see Equation 5.40 on page 262). Nevertheless, the constraints imposed
27O Chapter 5 Classification: Alternative Techniques
on the Lagrange multipliers )1's are slightly different those in the linearly
separable case. In the linearly separable case, the Lagrange multipliers must
be non-negative, i.e., )e > 0. On the other hand, Equation 5.52 suggeststhat
)z should not exceed C (since both pri and )a are non-negative). Therefore,
the Lagrange multipliers for nonlinearly separable data are restricted to 0 (
\r<C.
The dual problem can then be solved numerically using quadratic pro-
gramming techniques to obtain the Lagrange multipliers .\a. These multipliers
can be replaced into Equation 5.50 and the KKT conditions to obtain the
parameters of the decision boundary.
The SVM formulations described in the previous sections construct a linear de-
cision boundary to separatethe training examplesinto their respectiveclasses.
This section presents a methodology for applying SVM to data sets that have
nonlinear decision boundaries. The trick here is to transform the data from its
original coordinate space in x into a new space O(x) so that a linear decision
boundary can be used to separate the instances in the transformed space. Af-
ter doing the transformation, we can apply the methodology presented in the
previous sections to find a linear decision boundary in the transformed space.
Attribute TYansformation
lfM)0.2,
a ( r t , r z ): otherwise.
(5.54)
{1,
The decision boundary for the data can therefore be written as follows:
M-0.2,
which can be further simplified into the following quadratic equation:
*?-q+"3-rz:-0.46.
o.o Support Vector Machine (SVM) 27L
tr
-{1 d
tr
tr
I -0 15
tr
tr
&\'
x?-x,
Figure5.28.Classifying
datawitha nonlinear
decision
boundary.
In the transformed space, we can find the parameters w : (t10, lrrt ..., w+)
such that:
w4r21t .s*f + uz{2q + wrrtr2t tr.rs: fl.
For illustration purposes, let us plot the graph of r/ - t2 versus rl - q for
the previously given instances. Figure 5.28(b) shows that in the transformed
space,all the circles are located in the lower right-hand side of the diagram. A
Iinear decisionboundary can therefore be constructed to separatethe instances
into their respective classes.
One potential problem with this approach is that it may suffer from the
curse of dimensionality problem often associatedwith high-dimensional data.
We will show how nonlinear SVM avoids this problem (using a method known
as the kernel trick) later in this section.
-,n ll:Yll'
w2
Note the similarity between the learning task of a nonlinear SVM to that
of a linear SVM (seeDefinition 5.1 on page 262). The main difference is that,
instead of using the original attributes x, the learning task is performed on the
transformed attributes O(x). Following the approach taken in Sections 5.5.2
and 5.5.3 for linear SVM, we may derive the following dual Lagrangian for the
constrained optimization problem:
LD :1^, - . a(xr)
),;Aisiyie(xz) (5.56)
I f
zrJ
Once the );'s are found using quadratic programming techniques, the param-
eters w and b can be derived using the following equations:
-: )'iY';Q(x) l o . o/ /
T
+ b)- 1}:0,
r,;{s,,(I\1y1a(x).o(*r) (5.58)
J
5.5 Support Vector Machine (SVM) 273
which are analogousto Equations 5.39 and 5.40 for linear SVM. Finally, a test
instance z canbe classifiedusing the following equation:
Except for Equation 5.57, note that the rest of the computations (Equa-
tions 5.58 and 5.59) involve calculating the dot product (i.e., similarity) be-
tween pairs of vectors in the transformed space,O(*r) 'O("i). Such computa-
tion can be quite cumbersome and may suffer from the curse of dimensionality
problem. A breakthrough solution to this problem comes in the form ,rf a
method known as the kernel trick.
I(ernel TYick
This analysis shows that the dot product in the transformed space can be
expressedin terms of a similarity function in the original space:
K ( u , v ) : O ( u ). O ( " ) : ( u . v + 1 ) 2 (5.61)
rL
. ,\-, .a@) + b)
f (z) : sisn(\\siQ(xi)
t:I
n
: . ,\.-.
sign(\),igiK(xi.z) + b)
;-1
n
.
k A i \ x i ' z + I ) ' + 0" ) ,
z\- ' , .',
: slgn\) (5.62)
1,: I
Mercerts Theorem
The main requirement for the kernel function used in nonlinear SVM is that
there must exist a corresponding transformation such that the kernel function
computed for a pair of vectors is equivalent to the dot product between the
vectors in the transformed space. This requirement can be formally stated in
the form of Mercer's theorem.
1
tr
0.9
tr
tr
0.8
o.7 try
0.6
x u,c
0.4
0.3
0.2
tr
0.1 tr
tr
0
o.7
xl
Figure5.29.Decision produced
boundary SVMwithpolynomial
bya nonlinear kernel.
Kernel functions that satisfy Theorem 5.1 are called positive definite kernel
functions. Examples of such functions are listed below:
f
+ l)ee(x)
s(Y)dxdY
J 8'Y
P /\
"
: / t (l )t*.y)i g (*)g (y)d .xd,y
J 7_o\x/'
:\-\-
LL (,)(-,:, '?"7' s(rt'r2' )d'r1d'"
i:O at,az,... )[ l ]'
4. The SVM formulation presented in this chapter is for binary class prob-
lems. Some of the methods available to extend SVM to multiclass orob-
lems are presented in Section 5.8.
set of base classifiers from training data and performs classificationby taking
a vote on the predictions made by each base classifier. This section explains
why ensemble methods tend to perform better than any single classifier and
presents techniques for constructing the classifier ensemble.
vensemDle
O a 1 -
- - e)25-t: 0'06, (5.66)
which is considerably lower than the error rate of the base classifiers. r
Figure 5.30 shows the error rate of an ensemble of twenty-five binary clas-
sifiers (e".,""-bre) for different base classifier error rates (e). The diagonal line
represents the case in which the base classifiersare identical, while the solid
line representsthe casein which the base classifiersare independent. Observe
that the ensemble classifier performs worse than the base classifiers when e is
larger than 0.5.
The preceding example illustrates two necessary conditions for an ensem-
ble classifier to perform better than a single classifier: (1) the base classifiers
should be independent ofeach other, and (2) the base classifiersshould do bet-
ter than a classifierthat performs random guessing. In practice, it is difficult to
ensure total independenceamong the base classifiers. Nevertheless,improve-
ments in classification accuracieshave been observed in ensemblemethods in
which the base classifiers are slightly correlated.
278 Chapter 5 Classification: Alternative Techniques
0.9
6
o
0.7
o u.o
a
o
o
o
o.4
E
o
@ UJ
c
uJ
0.2
0.1
Base classifiererror
Figure
5.30.Comparison
between
enors
ofbase
classifiers
anderrors
oftheensemble
classifier.
Step 1:
CreateMultiple
Data Sets
Step 2:
BuildMultiple
Classifiers
Step 3:
Combine
Classifiers
Figure5.31.A logicalview
oftheensemble
learning
method.
3 . By manipulating the class labels. This method can be used when the
number of classesis sufficiently large. The training data is transformed
into a binary class problem by randomly partitioning the class la,bels
into two disjoint subsets, Ag and A1. TYaining examples whose class
label belongs to the subset As are assignedto class 0, while those that
belong to the subset Al are assignedto class 1. The relabeled examples
are then used to train a base classifier. By repeating the class-relabeling
and model-building steps multiple times, an ensembleof base classifiers
is obtained. When a test example is presented,each base classifiet Ci is
used to predict its class label. If the test example is predicted as class
0, then all the classesthat belong to As will receive a vote. Conversely'
if it is predicted to be class 1, then all the classesthat belong to A1
will receive a vote. The votes are tallied and the class that receivesthe
highest vote is assignedto the test example. An example of this approach
is the error-correcting output coding method describedon page 307.
The first three approachesare generic methods that are applicable to any
classifiers,whereasthe fourth approach depends on the type of classifierused.
The base classifiersfor most of these approachescan be generated sequentially
(one after another) or in parallel (all at once). Algorithm 5.5 shows the steps
needed to build an ensembleclassifier in a sequential manner. The first step
is to create a training set from the original data D. Depending on the type
of ensemble method used, the training sets are either identical to or slight
modifications of D. The size of the training set is often kept the same as the
original data, but the distribution of examples may not be identicall i.e., some
examples may appear multiple times in the training set, while others may not
appear even once. A base classifier Ci is then constructed from each training
set Da. Ensemble methods work better with unstable classifiers. i.e.. base
classifiersthat are sensitive to minor perturbations in the training set. Ex-
amples of unstable classifiersinclude decision trees, rule-based classifiers,and
artificial neural networks. As will be discussedin Section 5.6.3, the variability
among training examples is one of the primary sourcesof errors in a classifier.
By aggregating the base classifiersbuilt from different training sets, this may
help to reduce such types of errors.
Finally, a test example x is classified by combining the predictions made
by the base classifiersC;(x):
The class can be obtained by taking a majority vote on the individual predic-
tions or by weighting each prediction with the accuracv of the base classifier.
where / refers to the amount of force applied and 0 is the angle of the launcher.
The task of predicting the class label of a given example can be analyzed
using the same apploach. For a given classifier, some predictions may turn out
to be correct, while others may be completely off the mark. We can decompose
the expected error of a classifieras a sum of the three terms given in Equation
5.67, where expected error is the probability that the classifier misclassifiesa
{----} <-->
'Variance' 'Noise'
\_
'Bias'
Figure decomposition.
5.32.Bias-variance
282 Chapter 5 Classification: Alternative Techniques
given example. The remainder of this section examines the meaning of bias,
variance, and noise in the context of classification.
A classifier is usually trained to minimize its training error. However, to
be useful, the classifier must be abie to make an informed guess about the
class labels of examples it has never seen before. This requires the classifier to
generalizeits decision boundary to regions where there are no training exam-
ples available--a decision that depends on the design choice of the classifier.
For example, a key design issue in decision tree induction is the amount of
pruning needed to obtain a tree with low expected error. Figure 5.33 shows
two decision trees, ft and 72, that are generated from the same training data,
but have different complexities. 7z is obtained by pruning ?r until a tree with
maximum depth of two is obtained. Ty, on the other hand, performs very little
pruning on its decision tree. These design choices will introduce a bias into
the classifierthat is analogousto the bias of the projectile launcher described
in the previous example. In general, the stronger the assumptions made by
a classifier about the nature of its decision boundary, the larger the classi-
fier's bias will be. 72 therefore has a larger bias because it makes stronger
assumptions about its decision boundary (which is reflected by the size of the
tree) compared to ?r. other design choicesthat may introduce a bias into a
classifier include the network topology of an artificial neural network and the
number of neighbors consideredby a nearest-neighborclassifier.
The expected error of a classifier is also affected by variability in the train-
ing data becausedifferent compositions of the training set may lead to differ-
ent decision boundaries. This is analogous to the variance in r when different
amounts of force are applied to the projectile. The last component of the ex-
pected error is associatedwith the intrinsic noise in the target class. The target
class for some domains can be non-deterministic; i.e., instanceswith the same
attribute values can have different class labels. Such errors are unavoidable
even when the true decision boundary is known.
The amount of bias and variance contributing to the expected error depend
on the type of classifier used. Figure 5.34 compares the decision boundaries
produced by a decision tree and a 1-nearest neighbor classifier. For each
classifier, we plot the decision boundary obtained by "averaging" the models
induced from 100 training sets, each containing 100 examples. The true deci-
sion boundary from which the data is generated is also plotted using a dashed
line. The difference between the true decision boundary and the "averaged"
decision boundary reflects the bias of the classifier. After averaging the mod-
els, observe that the difference between the true decision boundary and the
decisionboundary produced by the l-nearest neighbor classifieris smaller than
5.6 EnsembleMethods 283
15
d oo oo
o
x1 <-1.24 x1< 11.00 ooo
o oooo 3
o _of,;
)<2<9.25 o t f f i '*+
o o l *+ + +
o
o
-' + * + + *
o ++
*4
o + +*
+ + *****
O+ o
-5 10 15
(a) Decisiontree Tj
15
d o oo o oi
o
ooo
10 o oooo 3
o + ++
8 +
-^ oo + **oo
+ +
x1 <-1.24 x1< 11.00 o
o
+ +
o *a
* tl+*+ * +*
+O o t a
+ J**
o
(b) Decisiontree T2 -5 10 15
treeswithdifferent
Figure5.33.Twodecision complexities fromthesametraining
induced data.
the observed difference for a decision tree classifier. This result suggests that
the bias of a l-nearest neighbor classifier is lower than the bias of a decision
tree classifier.
On the other hand, the l-nearest neighbor classifier is more sensitive to
the composition of its training examples. If we examine the models induced
from different training sets, there is more variability in the decision boundary
of a l-nearest neighbor classifier than a decision tree classifier. Therefore, the
decision boundary of a decision tree classifier has a lower variance than the
l-nearest neighbor classifier.
5.6.4 Bagging
+ .
.,+ + r++
:.. {o
* ***** * #..*
T
' \*
... ** #"3 f ++, ' , ' oo
*H o T+
J+ r.,.
ii* ..
+ ji
o
- - - l )
,/ "":
"o
' ' I
+T
+
'
o
t ".. ,r+ -
?" ooo^
*Ja
o H ^ oo o o-
,-tjf".= .,
+
+ O
' 9O O OO
orifJe"" o".pdg o oo.p d
I
o o^o n o.'
a_'
o ^t o
oo(g ^
-30 L "O orc)
-30 +0L
-10
(a) Decision boundary for decision tree. (b) Decision boundary for l-nearest
neighbor.
Figure
5.34.Biasofdecision
treeand1-nearest
neighbor
classifiers.
mately 63% of the original training data becauseeach sample has a probability
1 - (1 - 1/l/)r' of being selected in each D,i.. If l/ is sufficiently large, this
probability convergesto 1- Ll"- 0.632. The basic procedure for bagging is
summarized in Algorithm 5.6. After training the k classifiers,a test instance
is assignedto the class that receivesthe highest number of votes.
To illustrate how bagging works, consider the data set shown in Table 5.4.
Let r denote a one-dimensionalattribute and y denote the classlabel. Suppose
we apply a classifier that induces only one-level binary decision trees, with a
test condition r ( k, where k is a split point chosen to minimize the entropy
of the leaf nodes. Such a tree is also known as a decision stump.
Without bagging, the best decisionstump we can produce splits the records
at either z < 0.35 or r I 0.75. Either way, the accuracy of the tree is at
5.6 Ensemble Methods 285
most 70%. Suppose we apply the bagging procedure on the data set using
ten bootstrap samples. The examples chosen for training in each bagging
round are shown in Figure 5.35. On the right-hand side of each table, we also
illustrate the decision boundary produced by the classifier.
We classify the entire data set given in Table 5.4 by taking a majority
vote among the predictions made by each base classifier. The results of the
predictions are shown in Figure 5.36. Since the class labels are either -1 or
*1, taking the majority vote is equivalent to summing up the predicted values
of gr and examining the sign of the resulting sum (refer to the second to last
row in Figure 5.36). Notice that the ensembleclassifier perfectly classifiesall
ten examples in the original data.
The preceding example illustrates another advantage of using ensemble
methods in terms of enhancing the representation of the target function. Ilven
though each base classifier is a decision stump, combining the classifierscan
Iead to a decision tree of depth 2.
Bagging improves generalization error by reducing the variance of the base
classifiers. The performance of bagging depends on the stability of the base
classifier. If a base classifier is unstable, bagging helps to reduce the errors
associatedwith random fluctuations in the training data. If a base classifier
is stable, i.e., robust to minor perturbations in the training set, then the
error of the ensemble is primarily caused by bias in the base classifier. In
this situation, bagging may not be able to improve the performance of the
base classifiers significantly. It may even degrade the classifier's performance
becausethe effective size of each training set is about 37% smaller than the
original data.
Finally, since every sample has an equal probability of being selected, bag-
ging does not focus on any particular instance of the training data. It is
therefore less susceptible to model overfitting when applied to noisy data.
5.6.5 Boosting
Boosting is an iterative procedure used to adaptively change the distribution
of training examples so that the base classifierswill focus on examples that
are hard to classify. Unlike bagging, boosting assignsa weight to each training
286 Chapter 5 Classification: Alternative Techniques
Round1:
x 1 0 . 1 o.2 o.2 0.3 0.4 o.4 0.5 0.6 0.9 0.9 x<=0.35-=>y=1
v 1 1 1 1 -1 -1 -l 1 1 1 x>0.35==>y=-1
Round2:
x 1 0 . 1 o.2 0.3 0.4 0.5 0.8 0.9 1 1 1 x < = 0 . 6 5 = = 1y = |
v 1 1 1 -1 -1 1 1 1 1 1 x>0.65-=>y=1
Round3:
x I0.1 o.2 0.3 o.4 o.4 0.5 0.7 o.7 0.8 0.9 x < = 0 . 3 5 = = y y =|
v 1 1 1 -1 -1 -1 1 1 x>0.35==yy=-l
Round4:
x 1 0 . 1 0.1 o.2 0.4 o.4 0.5 0.5 0.7 0.8 0.9 x < = 0 . 3 = = 1y = l
v 1 1 1 -1 -1 1 -1 1 1 1 x v Q . t = = 1y = - 1
Bagging Round 5:
x 0.1 0.1 0.2 0.5 0.6 0.6 0.6 1 1 x<=0.35==>y=l
v 1 1 1 1 -1 I 1 1 1 x>0.35==>y=-1
Round6:
x o.2 0.4 0.5 0.6 0.7 o.7 o.7 0.8 0.9 1 x <= 0.75 ==> y - -1
v 1 1 1 1 1 1 1 1 1 x>0.75==>y=1
Round7:
x 0.1 o.4 o.4 0.6 0.7 0.8 0.9 0.9 0.9 1 x <= 0.75 ==> y = -1
v 1 -1 1 1 1 1 1 1 1 1 x>0.75==>y=1
Round8:
x 0.1 o.2 0.5 0.5 0.5 0.7 o.7 0.8 0.9 1 x <= 0.75 ==> y = -1
v 1 1 1 -1 -1 -t 1 1 1 1 x>0.75==2y=l
Round
x 0.1 0.3 0.4 o.4 0.6 o.7 o.7 0.8 1 1 x <= O.75==> y - -1
v 1 1 1 1 1 1 1 x>0.75==>y=-t
Round10:
x 0.1 0.1 0.1 0.1 0.3 0.3 0.8 x <= 0.05 ==> y = -1
0.8 0.9 0.9
v 1 x>0.05==>y=1
1 1 1 1 1 I 1 1
Figure5.35.Example
ofbagging.
example and may adaptively change the weight at the end of each boosting
round. The weights assigned to the training examples can be used in the
following ways:
2. They can be used by the base classifier to learn a model that is biased
toward higher-weight examples.
5.6 Ensemble Methods 287
4 1 1 1 1 1 1 1 -1 1 -1
5 1 1 1 1 1 -1 1 1 1
-1 -1 -1 -1 ,l
6 1 1 1 1 1
'l -1 -1 1 1 1 1 1 1
I -1 -1 -1 1 1 1 -1 1 1 1
I 1 1 1 1 1 1 -1 1 1 1
'l
10 1 1 1 t
1 1 1 1 1
Sum 2 2 2 -o -6 -6 -6 2 2 2
Sign 1 1 1 1 1 1 1 1 1
TrueClass 1 1 1 1 1 1 1 1 1 1
of combining
Figure5.36.Example classifiers approach.
usingthebagging
constructed
Initially, all the examples are assigned the same weights. However, some ex-
amples may be chosen more than once, e.g., examples 3 and 7, becausethe
sampling is done with replacement. A classifier built from the data is then
used to classify all the examples. Suppose example 4 is difficult to classify.
The weight for this example will be increased in future iterations as it gets
misclassified repeatedly. Meanwhile, examples that were not chosen in the pre-
288 Chapter 5 Classification: Alternative Techniques
vious round, e.g., examples 1 and 5, also have a better chanceof being selected
in the next round since their predictions in the previous round were Iikely to
be wrong. As the boosting rounds proceed, examples that are the hardest to
classify tend to become even more prevalent. The final ensemble is obtained
by aggregating the base classifiersobtained from each boosting round.
Over the years, several implementations of the boosting algorithm have
been developed. These algorithms differ in terms of (1) how the weights of
the training examples are updated at the end of each boosting round, and (2)
how the predictions made by each classifierare combined. An implementation
called AdaBoost is explored in the next section.
AdaBoost
# tf '1r(co61t
+r,)], (5.68)
1, /1- er\
ai:rt"\
* /
Note that a; has a large positive value if the error rate is closeto 0 and a large
negative value if the error rate is close to 1, as shown in Figure 5.37.
The a6 parameter is also used to update the weight of the training ex-
amples. To illustrate,let w[i) denote the weight assignedto example (*t,A)
during the jth boosting round. The weight update mechanism for AdaBoost
is given by the equation:
'[i) If Ci(x) : y,
.U+r1
' : * lexp-".r (5.6e)
z.i lexpo: i f C i @ ) I y i '
el
E-1
-4
o.4
E
€ensemble (5.70)
29O Chapter 5 Classification: Alternative Techniques
where e,;is the error rate of each base classifier i. If the error rate of the base
classifier is less than 50%, we can write e; : 0.5 - li, where l; fir€asur€show
much better the classifieris than random guessing. The bound on the training
error of the ensemblebecomes
€ensemble (
T Uf - +":( exp(_ r."r) ( 5.7r )
If m < 7x for all i's, then the training error of the ensembledecreasesexpo-
nentially, which leads to the fast convergence of the algorithm. Nevertheless,
becauseof its tendency to focus on training examples that are wrongly classi-
fied, the boosting technique can be quite susceptible to overfitting.
Boosting
Round1:
x 0.1 0.4 0.5 0.6 0.6 o.7 0.7 0.7 0.8 1
v 1 1 -1 -1 -1 -1 -1 -1 1 1
Boosting
Round2:
x 0.1 0.1 0.2 0.2 0.2 0.2 0.3 0.3 0.3 0.3
v 1 1 1 1 1 1 1 1 1 1
BoostingRound3:
x o.2 0.2 0.4 0.4 0.4 0.4 0.5 0.6 0.6 0.7
v 1 1 -1 1 -1 -1 -1 -1 -1 -1
(a)Training
recordschosenduringboosting
Round x=0.1 x=0.2 x=0,3 x=0,4 x=0.5 x=0.6 x=0.7 x=0,8 x=0.9 x=1,0
1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
2 0 . 3 1 1 0.3't'l 0 . 3 t1 0 . 0 1 0 . 0 1 0 . 0 1 0.01 0 . 0 1 0.01 0.01
J 0.029 0.029 0.029 0.228 0.228 0.228 0.228 0.009 0.009 0.009
(b)Weightsof trainingrecords
Figure5.38.Example
of boosting.
where p is the average correlation among the trees and s is a quantity that
measuresthe "strength" of the tree classifiers. The strength of a set of classi-
fiers refers to the averageperformance of the classifiers,where performance is
measured probabilistically in terms of the classifier'smargin:
Round x=0.1 x=0.2 x=0.3 x--0.4 x=0.5 x=0.6 x=0.7 x=0,8 x=0.9 x=l.0
1 1 1 1 1 1 -1 1 1 I
2 1 1 1 1 1 I 1 1
.t 1 1 1 1 1 1 1 1 1 1
Sum 5 . 1 6 5 . 1 6 5 . 1 6 -3.08 -3.08 -3.08 -3.08 0.397 0.397 0.397
Sign 1 1 1 1 1 1 1 1 1
(b)
5,39.Example
Figure olcombining
classifiers
constructed theAdaBoost
using approach.
Original
Trainingdata
Step2:
Userandom
vectorto
buildmultiple
ffi
+ +
decisiontrees
(c
Step3:
Combine
decisiontrees
Figure5.40.Random
forests.
Each decision tree uses a random vector that is generated from some fixed
probability distribution. A random vector can be incorporated into the t,ree-
growing process in many ways. The first approach is to randomly select F
input features to split at each node of the decision tree. As a result, instead of
examining all the available features, the decision to split a node is determined
from these selectedf. features. The tree is then grown to its entirety without
any pruning. This may help reduce the bias present in the resulting 1;ree.
Once the trees have been constructed, the predictions are combined using a
majority voting scheme. This approach is known as Forest-Rl, where RI refers
to random input selection. To increaserandomness,bagging can also be used
to generate bootstrap samples for Forest-Rl The strength and correlation of
random forests may depend on the size of F. If F is sufficiently small, then
the trees tend to become less correlated. On the other hand, the strength of
the tree classifier tends to improve with a larger number of features, F. As
a tradeoff, the number of features is commonly chosen to be F - logz d + L,
where d is the number of input features. Since only a subset of the features
needsto be examined at each node, this approach helps to significantly re<luce
the runtime of the algorithm.
If the number of original features d is too small, then it is difficult to choose
an independent set of random features for building the decision trees. One
way to increase the feature space is to create linear combinations of the input
features. Specifically, at each node, a new feature is generated by randomly
selecting .t of the input features. The input features are linearly combined
using coefficients generated from a uniform distribution in the range of [-1,
1]. At each node, F of such randomly combined new features are generated,
and the best of them is subsequentlyselectedto split the node. This approach
is known as Forest-RC.
A third approach for generating the random trees is to randomly select
one of the f' best splits at each node of the decision tree. This approach may
potentially generatetrees that are more correlated than Forest-Rl and Fonest-
RC, unless -F is sufficiently large. It also does not have the runtime savings of
Forest-Rl and Forest-RC because the algorithm must examine all the splitting
features at each node of the decision tree.
It has been shown empirically that the classification accuraciesof random
forests are quite comparable to the AdaBoost algorithm. It is also more robust
to noise and runs much faster than the AdaBoost algorithm. The classification
accuracies of various ensemble algorithms are compared in the next section.
294 Chapter 5 Classification: Alternative Techniques
Table
5.5.Comparing ofa decision
theaccuracy treeclassifier three
against methods.
ensemble
Data Set Number of Decision Bagging Boosting RF
(Attributes, Classes, Tlee (%) (%) (%) (%)
Records)
Anneal ( 3 9 ,6 , 8 9 8 ) 92.09 94.43 95.43 95.43
Australia ( 1 5 ,2 , 6 9 0 ) 85.51 87.10 85.22 85.80
Auto (26, 7, 205) 81.95 85.37 85.37 84.39
Breast ( 1 1 ,2 , 6 9 9 ) 95.r4 96.42 a7 2F, 96.14
Cleve (14,2, 303) 76.24 81.52 82.18 82.18
Credit (16,2, 690) 85.8 86.23 86.09 85.8
Diabetes (9,2,769) 72.40 76.30 73.18 ro.ro
German (21,2, 1000) 70.90 73.40 73.00 74.5
a, <n
Glass (r0, 7, 2L4) 67.29 76.r7 78.04
Heart \14,2,270) 80.00 81.48 80.74 83.33
Hepatitis (20,2, L55) 81.94 81.29 83.87 83.23
Horse (23, 2, 369) 85.33 85.87 8r.25 85.33
Ionosphere (35, 2, 351) 89.L7 92.02 93.73 93.45
Iris (5,3,150) 94.67 94.67 94,00 93.33
Labor (17, 2, 57) 78.95 84.2r 89,47 84.21
LedT (8, 10, 3200) 73.34 73.66 73.34 73.06
Lymphography ( 1 9 ,4 , 1 4 8 ) 77.03 79.05 85.14 82.43
Pima (9,2,769) 74.35 76.69 73,44 77.60
Sonar (6r, 2,208) 78.85 78.85 84.62 db.bd
Tic-tac-toe (10, 2, g5g) 83.72 93.84 98.54 95.82
Vehicle (r9, 4,846) 7r.04 74.rr 78.25 74.94
Waveform (22,3, 5000) 76.44 83.30 83.90 84.04
Wine (14, 3, 178) 94.38 96.07 97.75 97.75
Zoo (r7,7, Lol) 93.07 93.07 95.05 97.03
Table 5.5 shows the empirical results obtained when comparing the perfor-
mance of a decision tree classifier against bagging, boosting, and random for-
est. The base classifiersused in each ensemblemethod consist of fifty decision
trees. The classification accuraciesreported in this table are obtained from
ten-fold cross-validation. Notice that the ensemble cla,ssifi.ersgenerally out-
perform a single decision tree classifier on many of the data sets.
Table matrix
5.6.A confusion fora binary problem
classification inwhich arenotequally
theclasses
imoortant.
Predicted Class
-f
denoted as the negative class. A confusion matrix that summarizes the number
of instancespredicted correctly or incorrectly by a classificationmodel is shown
in Table 5.6.
The following terminology is often used when referring to the counts tab-
ulated in a confusion matrix:
o TYuepositive (TP) or fi1, which correspondsto the number of positive
examples correctly predicted by the classification model.
TPR:TPIQP+r'N).
Finally, the false positive rate (FPR) is the fraction of negative examples
predicted as a positive class, i.e.,
Recall and precision are two widely used metrics employed in applica-
tions where successfuldetection of one of the classesis consideredmore signif-
icant than detection of the other classes.A formal definition of these met,rics
is given below.
TP
Precision,p: (5.74)
TP+FP
TP
Recall, r : (5.75)
TP+FN
,
al -
1 1.
III
i- p
The harmonic mean of two numbers z and grtends to be closer to the smaller
of the two numbers. Hence, a high value of F1-measure ensures that both
298 Chapter 5 Classification: Alternative Techniques
precision and recall are reasonably high. A comparison among harmonic, ge-
ometric, and arithmetic means is given in the next example.
Example 5.8. Consider two positive numbers a,: 1 and b: 5. Their arith-
m e t i c m e a ni s L r o : ( a + b ) 1 2 : 3 a n d t h e i r g e o m e t r i cm e a n i s F g : \ / o b :
2.236. Their harmonic mean is p,h: (2xlx5) 16 : L.667,which is closerto the
smaller value between o and b than the arithmetic and geometric means. r
More generally, the FB measure can be used to examine the tradeoff be-
tween recall and precision:
D
/ ^t
\lt- + tlrp
a\
(P'+r) xTP
,^q
(5.77)
r+p-p @2+t)rp+p2FP+Fr\/
Both precision and recall are special casesof FB by setting 0 :0 and B : 66,
respectively. Low values of B make Fp closer to precision, and high values
make it closer to recall.
A more general metric that captures .F-Bas well as accuracy is the weighted
accuracy measure,which is defined by the following equation:
wtTP -f utTN
Weighted &ccltro,c/: (5.78)
utTP * utzFP + unF N + u)4TN'
0.9 Mz.'
4
o.7
o
(d
E u.o
c) M1
o u.c
o
(L
c)
5 0.4
[,/
I
,/, ,,
,/ .'
0.1
l'
0
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
FalsePositiveRate
Figure
5.41.ROCcurves
fortwodifferent
classifiers.
There are several critical points along an ROC curve that have well-known
interpretations:
(TPR:O, FPR:0): Model predicts every instance to be a negative class.
(TPR:l, FPR:I): Model predicts every instance to be a positive class.
(TPR:l, FPR:O): The ideal model.
than 0.36, while Mz is superior when FPIB is greater than 0.36. Clearly,
neither of these two classifiersdominates the other.
The area under the ROC curve (AUC) provides another approach for eval-
uating which model is better on average. If the model is perfect, then its area
under the ROC curve would equal 1. If the model simply performs random
guessing,then its area under the ROC curve would equal 0.5. A model that
is strictly better than another would have a larger area under the ROC curve.
2 . Select the lowest ranked test record (i.e., the record with lowest output
value). Assign the selected record and those ranked above it to the
positive class. This approach is equivalent to classifying all the test
records as positive class. Because all the positive examples are classified
correctly and the negative examples are misclassified,TPR: FPR: I.
3 . Select the next test record from the sorted list. Classify the selected
record and those ranked above it as positive, while those ranked below it
as negative. Update the counts of TP and FP by examining the actual
class label of the previously selected record. If the previously selected
record is a positive class, the TP count is decremented and the FP
count remains the same as before. If the previously selectedrecord is a
negative class, the FP count is decremented and TP cotnt remains the
same as before.
4. Repeat Step 3 and update theTP and FP counts accordingly until the
highest ranked test record is selected.
Figure 5.42 shows an example of how to compute the ROC curve. There
are five positive examples and five negative examples in the test set. The class
5.7 ClassImbalanceProblem 301-
5 4 4 o J 3 2 2 1 0
'I
5 c 4 4 2 0 0 0
TN 0 0 1 1 J 4 4 5 5
FN 0 1 1 2 2 2 3 3 4 5
TPR I 0.8 0.8 u.o 0.6 0.6 0.6 o.4 o.4 0.2 0
'I
FPR 1 0.8 0.8 06 o.4 o.2 o.2 0 0 0
Figure5.42.
Constructing
anROCcurve.
Figure5,43.BOCcurveforthedatashownin Figure
5.42.
Iabels of the test records are shown in the first row of the table. The second row
corresponds to the sorted output values for each record. For example, they
may correspond to the posterior probabilities P(*lx) generated by a naive
Bayes classifier. The next six rows contain the counts of.TP, FP,TN, and
f.ly', along with their corresponding TPR and FPR. The table is then filled
from left to right. Initially, all the records are predicted to be positive. Thus,
TP : FP :5 and TPR : FPR : 1. Next, we assign the test record with
the lowest output value as the negative class. Becausethe selected record is
actually a positive example, the TP count reduces from 5 to 4 and the FP
count is the same as before. The FPR and TPR are updated accordingly.
This process is repeated until we reach the end of the list, where TPR : 0
and FPR:0. The ROC curve for this example is shown in Figure 5.43.
3O2 Chapter 5 Classification: Alternative Techniques
U n d e rt h e 0 / 1 c o s t m a t r i x , i . e . , C ( + , * ) : C ( - , - ) : 0 and C(+,,-1 :
C(-, +) : 1, it can be shownthat the overallcostis equivalentto the number
of misclassification errors.
C t ( M ) : 1 5 0x ( - 1 ) * 6 0 x 1 + 4 0 x 1 0 0: 3 9 1 0 ,
Ct(Mz) : 250x (-1) * 5 x 1 -f 45 x 100: 4255.
Table5,7.Costmatrix
forExample
5.9.
Predicted Class
Ulass : * Class : -
Actual Class : f -l 100
Class UIaSS : - I (.)
5.7 Class Imbalance Problem 3OB
Table5,8. Confusion
matrix
fortwoclassification
models.
Model M1 Predicted Olass Model M2 Predicted Class
UIASS + UIASS - Ulass + Ulass -
Actual Class + 150 40 Actual Class + 250 45
Class UIaSS - 60 250 Class Class- 200
Notice that despite improving both of its true positive and false positive counts,
model Mz is still inferior since the improvement comes at the expense of in-
creasing the more costly false negative errors. A standard accuracy measure
would have preferred model M2 over M1. I
A cost-sensitiveclassification technique takes the cost matrix into consid-
eration during model building and generatesa model that has the lowest cost.
For example, if false negative errors are the most costly, the learning algorithm
will try to reduce these errors by extending its decision boundary toward the
negative class, as shown in Figure 5.44. In this way, the generated model can
cover more positive examples, although at the expense of generating additional
false alarms.
Figure5.44.Modifying
thedecision (from81 to F2)toreduce
boundary thefalsenegative
errorsofa
classifier.
information can be used to: (1) choosethe best attribute to use for splitting
the data, (2) determine whether a subtree should be pruned, (3) manipulate
the weights ofthe training records so that the learning algorithm convergesto
a decision tree that has the lowest cost, and (4) modify the decision rule at
each leaf node. To illustrate the last approach, let p(ilt) denote the fraction of
training records from class i that belong to the leaf node t. A typical decision
rule for a binary classification problem assignsthe positive class to node t if
the following condition holds.
The preceding decision rule suggeststhat the classlabel of a leaf node depends
on the majority class of the training records that reach the particular node.
Note that this rule assumesthat the misclassification costs are identical for
both positive and negative examples. This decision rule is equivalent to the
expressiongiven in Equation 4.8 on page 165.
Instead of taking a majority vote, a cost-sensitive algorithm assigns the
class label e to node t if it minimizes the following expression:
X1 X
Figute5.45.lllustrating
theeffectofoversampling
oftherareclass.
Sampling is another widely used approach for handling the class imbalance
problem. The idea of sampling is to modify the distribution of instances so
that the rare classis well representedin the training set. Some of the available
techniques for sampling include undersampling, oversampling, and a hybrid
of both approaches. To illustrate these techniques, consider a data set that
contains 100 positive examples and 1000 negative examples.
In the case of undersampling, a random sample of 100 negative examples
is chosen to form the training set along with all the positive examples. One
potential problem with this approach is that some of the useful negative exam-
ples may not be chosenfor training, therefore, resulting in a less than optimal
model. A potential method to overcomethis problem is to perform undersam-
pling multiple times and to induce multiple classifierssimilar to the ensemble
Iearning approach. Focused undersampling methods may also be used, where
the sampling procedure makes an informed choice with regard to the nega-
tive examples that should be eliminated, e.g., those located far away from the
decision boundary.
Oversampling replicates the positive examplesuntil the training set has an
equal number of positive and negative examples. Figure 5.45 illustrates the
effect of oversamplingon the construction of a decisionboundary using a classi-
fier such as a decision tree. Without oversampling, only the positive examples
at the bottom right-hand side of Figure 5.45(a) are classified correctly. The
positive example in the middle of the diagram is misclassifiedbecause there
306 Chapter 5 Classification: Alternative Techniques
are not enough examples to justify the creation of a new decision boundary
to separate the positive and negative instances. Oversampling provides the
additional examples neededto ensure that the decision boundary surrounding
the positive example is not pruned, as illustrated in Figure 5.45(b).
However, for noisy data, oversampling may causemodel overfitting because
some of the noise examples may be replicated many times. In principle, over*
sampling does not add any new information into the training set. Replication
of positive examplesonly prevents the learning algorithm from pruning certain
parts of the model that describe regions that contain very few training exam-
ples (i.e., the small disjuncts). The additional positive examples also tend to
increasethe computation time for model building.
The hybrid approach uses a combination of undersampling the majority
class and oversampling the rare class to achieve uniform class distribution.
Undersampling can be performed using random or focusedsubsampling. Over-
sampling, on the other hand, can be done by replicating the existing positive
examples or generating new positive examples in the neighborhood of the ex-
isting positive examples. In the latter approach, we must first determine the
k-nearest neighbors for each existing positive example. A new positive ex-
ample is then generated at some random point along the line segment that
joins the positive example to one of its k-nearest neighbors. This process is
repeated until the desired number of positive examples is reached. Unlike the
data replication approach, the new examples allow us to extend the decision
boundary for the positive classoutward, similar to the approach shown in Fig'
ure 5.44. Nevertheless,this approach may still be quite susceptible to model
overfitting.
The first two rows in this table correspond to the pair of classes(AtAi) chosen
to build the classifierand the last row representsthe predicted classfor the test
instance. After combining the predictions, 91 and 94 each receive two votes,
while 92 and gr3each receives only one vote. The test instance is therefore
classifiedas either At or A+, depending on the tie-breaking procedure. I
Class Codeword
At 1 1 1 1 1 1 1
Ut 0 0 0 0 1 1 1
UI 0 0 1 1 0 0 I
U+ 0 1 0 1 0 I 0
Each bit of the codeword is used to train a binary classifier. If a test instance
is classifiedas (0,1,1,1,1,1,1)by the binary classifiers,then the Hamming dis-
tance between the codeword and gr1is 1, while the Hamming distance to the
remaining classesis 3. The test instance is therefore classifiedas 91. I
binary classifiers. If there is more than one classifier that makes a mistake,
then the ensemblemay not be able to compensatefor the error.
An important issue is how to design the appropriate set of codewords for
different classes. FYom coding theory, a vast number of algorithms have been
developed for generating n-bit codewords with bounded Hamming distance.
However, the discussionof these algorithms is beyond the scope of this book.
It is worthwhile mentioning that there is a significant difference between the
design of error-correcting codes for communication tasks compared to those
used for multiclass learning. For communication, the codewords should max-
imize the Hamming distance between the rows so that error correction can
be performed. Multiclass learning, however, requires that the row-wise and
column-wise distances of the codewords must be well separated. A larger
column-wise distance ensuresthat the binary classifiersare mutually indepen-
dent, which is an important requirement for ensemblelearning methods.
Table ofvarious
5,9.Comparison rule-based
classifiers,
RIPPER u1\ z L]N2 AQR
(unordered) (ordered)
ttule-growlng Generai-to- L;eneral-to- General-tG. General-to-specific
strategy specific specific specific (seeded by a
oositive examole)
Evaluation FOIL's Infb gain Laplace Itntropy ancl Number of
Metric likelihood ratio true positives
Stopping All examples No performance No perfbrmance Kules cover only
condition for belong to the galn galn positive class
rule-erowinq same class
Rule Pruning Keducect None None None
error Drunlnq
lnstance Positive and Positive only Positive only Positive and
Elimination negative negatlve
btopprng tlrlor > bUTo oI I\o perlormance No perlormance All positive
condition for based on MDL garn garn examples are
adding rules covered
Kule uet tfeplace or :itatrstrcal None None
Pruning modifv rules tests
Search stratesv Greedv Beam search Beam search Beam sea,rch
[213]. There are several survey articles on SVM, including those written by
Burges [164],Bennet et al. [158],Hearst 1193],and Mangasarian[205].
A survey of ensemble methods in machine learning was given by Diet-
terich [174]. The bagging method was proposed by Breiman [161]. Reund
and Schapire [186] developed the AdaBoost algorithm. Arcing, which stands
for adaptive resampling and combining, is a variant of the boosting algorithm
proposed by Breiman [162]. It usesthe non-uniform weights assignedto train-
ing examples to resample the data for building an ensembleof training sets.
Unlike AdaBoost, the votes of the base classifiersare not weighted when de-
termining the class label of test examples. The random forest method was
introduced by Breiman in [163].
Related work on mining rare and imbalanced data sets can be found in the
survey papers written by Chawla et al. [166] and Weiss 1220].Sampling-based
methods for mining imbalanced data sets have been investigated by many au-
thors, such as Kubat and Matwin 1202),Japkowitz [196], and Drummond and
Holte [179]. Joshi et al. [199] discussedthe limitations of boosting algorithms
for rare class modeling. Other algorithms developed for mining rare classes
include SMOTE [165],PNrule [198],and CREDOS [200].
Various alternative metrics that are well-suited for class imbalanced prob-
lems are available. The precision, recall, and F1-measureare widely used met-
rics in information retrieval 1216].ROC analysis was originally used in signal
detection theory. Bradley [160] investigated the use of area under the ROC
curve as a performance metric for machine learning algorithms. A method
for comparing classifier performance using the convex hull of ROC curves was
suggested by Provost and Fawcett in [210]. Ferri et al. lf85] developed a
methodology for performing ROC analysis on decision tree classifiers. They
had also proposed a methodology for incorporating area under the ROC curve
(AUC) as the splitting criterion during the tree-growing process. Joshi [197]
examined the performance of these measuresfrom the perspectiveof analyzing
rare classes.
A vast amount of literature on cost-sensitive learning can be found in
the online proceedings of the ICML'2000 Workshop on cost-sensitive learn-
ittg. The properties of a cost matrix had been studied by Elkan in [182].
Margineantu and Dietterich [206] examined various methods for incorporating
cost information into the C4.5 learning algorithm, including wrapper meth-
ods, class distribution-based methods, and loss-basedmethods. Other cost-
sensitive learning methods that are algorithm-independent include AdaCost
[t83], Metacost [177],and costing [222].
3L2 Chapter 5 Classification: Alternative Techniques
Bibliography
[155] D. W. Aha. A studg of instance-based algorithms for superuised learning tasks: mathe-
rnatical, empirical, and, psgchological eualuat'ions. PhD thesis, University of California,
Irvine, 1990.
[156] E. L. Allwein, R. E. Schapire, and Y. Singer. Reducing Multiclass to Binary: A
Unifying Approach to Margin Classifiers. Journal of Machine Learn'ing Research, I:
113-141, 2000.
[157] R, Andrews, J. Diederich, and A. Tickle. A Survey and Critique of Techniques For
Extracting Rules Flom Tbained Artificial Neural Networks. Knowledge Based, Sgstems,
8(6):373-389, 1995.
[158] K. Bennett and C. Campbell. Support Vector Machines: Hype or Hallelujah. SIGKDD
Erp lorat'i,on s, 2 (2) : L-13, 2000.
[159] C. M. Bishop. Neural Networks for Pattern Recognit'ion. Oxford University Press,
Oxford. U.K.. 1995.
[160] A. P. Bradley. The use of the area under the ROC curve in the Evaluation of Machine
Learning Algorithms. P attern Recogni,tion,30(7) : 1145-1 1 49, 1997.
[161] L. Breiman. Bagging Predictors. Mach,ine Lear"ning,24(.2):123 140, 1996.
[162] L. Breiman. Bias, Variance, and Arcing Classifiers. Technical Report 486, University
of California, Berkeley, CA, 1996.
f163] L. Breiman. Random Forests. Mach'ine Learn'ing, 45(I):5-32,2001.
[164] C. J. C. Burges. A Ttrtorial on Support Vector Machines for Pattern Recognition.
D ata Mining and, Knowled,ge Discox erg, 2(2) :t21-167, 1998.
[165] N. V. Chawla, K. W. Bowyer, L. O. Hall, and W. P. Kegelmeyer. SMOTE: Synthetic
Minority Over-sampling Technique. Journal of Artifi,cial Intelli,gence Research, 16:321-
357, 2002.
[166] N. V. Chawla, N. Japkowicz, and A. Kolcz. Editorial: Special Issue on Learning from
Imbalanced Data Sets. SIGKDD Erplorat'ions, 6(1):1-6, 2004.
[167] V. Cherkassky and F. Mulier. Learn'ing frorn Data: Concepts, Theory, and Method,s.
Wiley Interscience, 1998.
[168] P. Clark and R. Boswell. Rule Induction with CN2: Some Recent Improvements. In
Machine Lear"ning: Proc. of the Sth European Conf. (EWSL-97/, pages 151-163, 1991.
[169] P. Clark and T. Niblett. The CN2 Induction Algorithm. Machine Learning, 3(4):
26L-283, 1989.
[170] W. W. Cohen. Fast Effective Rule Induction. In Proc. of the 12th Intl. Conf. on
Mach'ine Leamting, pages 115-123, Tahoe City, CA, July 1995.
[171] S. Cost and S. Salzberg. A Weighted Nearest Neighbor Algorithm for Learning with
Symbolic Features. Mach'ine Learn'ing, 10:57-78, 1993.
ll72l T. M. Cover and P. E. Hart. Nearest Neighbor Pattern Classification. Knowleilge
Baseil Sgstems, 8(6):373-389, 1995.
Bibliography 313
[194] D. Heckerman. Bayesian Networks for Data Mining. Data Mi,ni,ng and Knouledge
Discouerg,1(1):79 LI9, L997.
1195] R. C. Holte. Very Simple Classification Rules Perform Well on Most Commonly Used
Data sets. Machine Learn'ing, 11:63-91, 1993.
[196] N. Japkowicz. The Class Imbalance Problem: Significance and Strategies. In Proc.
of the 2000 Intl. Conf. on Arti,ficial Intelli,gence: Special Tracle on Ind,uct'iue Learning,
volume 1, pages lll-117, Las Vegas, NV, June 2000.
[197] M. V. Joshi. On Evaluating Performance of Classifiers for Rare Classes. In Proc. of
the 2002 IEEE IntI. Conf. on Data Mining, Maebashi City, Japan, December 2002.
1198] M. V. Joshi, R. C. Agarwal, and V. Kumar. Mining Needles in a Haystack: Classifying
Rare Classes via Two-Phase Rule Induction. In Proc. of 2001 ACM-SIGMOD IntI. Conf.
on Managernent of Data, pages 91-102, Santa Barbara, CA, June 2001.
[199] M. V. Joshi, R. C. Agarwal, and V. Kumar. Predicting rare classes: can boosting
make any weak learner strcing? In Proc. of the 8th IntI. Conf. on Knowledge Discouery
and Data Mining, pages 297 306, Edmonton, Canada, JuIy 2002.
1200] M. V. Joshi and V. Kumar. CREDOS: Classification Using Ripple Down Structure
(A Case for Rare Classes). ln Proc. of the SIAM IntI. Conf. on Data Min'ing, pages
32L-332, Orlando, FL, April 2004.
[201] E. B. Kong and T. G. Dietterich. Error-Correcting Output Coding Corrects Bias and
Variance. In Proc. of the 12th IntI. Conf. on Machine Lear"ning, pages 313 321, Tahoe
City, CA, July 1995.
[202] M. Kubat and S. Matwin. Addressing the Curse of Imbalanced Ttaining Sets: One
Sided Selection. In Proc. of the l/+th IntI. Conf. on Machine Lear"n'ing,pages 179-186,
Nashville, TN, July 1997.
[203] P. Langley, W. Iba, and K. Thompson. An analysis of Bayesian classifiers. In Proc. oJ
the 10th National Conf. on Artif,cial Intelligence, pages 223-228, 1992.
[204] D. D. Lewis. Naive Bayes at Forty: The Independence Assumption in Information
Retrieval. In Proc. of the 10th European Conf. on Mach'i,ne Learning (ECML 1998),
pages 4-15, 1998.
[205] O. Mangasarian. Data Mining via Support Vector Machines. Technical Report Tech-
nical Report 01-05, Data Mining Institute, May 2001.
[206] D. D. Margineantu and T. G. Dietterich. Learning Decision Tlees for Loss Minimization
in Multi-Class Problems. Technical Report 99-30-03, Oregon State University, 1999.
1207] R. S. Michalski, I. Mozetic, J. Hong, and N. Lavrac. The Multi-Purpose Incremental
Learning System AQ15 and Its Testing Application to Three Medical Domains. In Proc.
of sth National Conf. on Arti,fici,al Intell'igence, Orlando, August 1986.
[208] T. Mitchell. Machine Learning. McGraw-Hill, Boston, MA, 1997.
f209] S. Muggleton. Found,ati,ons of Inducti,ue Log,ic Programm'ing. Prentice Hall, Englewood
Cliffs. NJ, 1995.
[210] F. J. Provost and T. Fawcett. Analysis and Visualization of Classifier Performance:
Comparison under Imprecise Class and Cost Distributions. In Proc. of the Srd, Intl.
Conf. on Knowled,ge D'iscouery and Data M'in'ing, pages 43-48, Newport Beach, CA,
August 1997.
[211] J. R. Quinlan. CI.S: Programs for Machi,ne Learn'ing. Morgan-Kaufmann Publishers,
San Mateo. CA. 1993.
l2L2l M. Ramoni and P. Sebastiani. Robust Bayes classifierc. Arti.fi,cial Intelligence, I25:
209-226,200r.
5.10 Exercises 31-5
f213] B. Scholkopf and A. J. Smola. Learning with Kernels: Support Vector Machines,
Regularizati,on, Opt'i,mizat'ion, and, Begond. MIT Press, 2001.
[2I4) P. Smyth and R. M. Goodman. An Information Theoretic Approach to Rule Induction
from Databases. IEEE Trans. on Knowled,geand"Data Engi'neering,4(4):301-316, 1992.
[215] D. M. J. Tax and R. P. W. Duin. Using Two-Class Classifiers for Multiclass Classi-
fication. In Proc. of the 16th IntI. Conf. on Pattern Recogn'ition (ICPR 2002), pages
124-127, Quebec, Canada, August 2002.
f216] C. J. van Rijsbergen. Inforrnat'ion Retrieual. Butterworth-Heinemann, Newton, MA,
1978.
[217] V. Vapnik. The Nature of Statistical Learn'ing Theorg. Springer Verlag, New York,
1995.
[218] V. Vapnik. Statistical Learn'ing Theorg. John Wiley & Sons, New York, 1998.
[219] A. R. Webb. Statistical Pattern Recogni.tion.John Wiley & Sons, 2nd edition, 2002.
1220] G. M. Weiss. Mining with Rarity: A Unifying Flamework. SIGKDD Erplorations,6
(l):7-L9,2004.
l22l] I. H. Witten and E. FYank. Data Mining: Pract'ical Machine Learning Tools and
Techn'iqueswith Jaua Implementations. Morgan Kaufmann, 1999.
[222) B. Zadrozny, J. C. Langford, and N. Abe. Cost-Sensitive Learning by Cost-
Proportionate Example Weighting. In Proc. of the 2003 IEEE IntI. Conf. on Data
M'i,n'ing,pages 435-442, Melbourne, FL, August 2003.
5.10 Exercises
1. Consider a binary classification problem with the following set of attributes and
attribute values:
Rt: A ----- C
Rz: AnB------+C
-R2is obtained by adding a new conjunct, B, to the left-hand side of R1. For
this question, you will be asked to determine whether -R2 is preferred over fi1
from the perspectives of rule-growing and rule-pruning. To determine whether
a rule should be pruned, IREP computes the following measure:
urREp:-_fr1,, ,
n-L(N -n)
where P is the total number of positive examples in the validation set, Iy' is
the total number of negative examples in the validation set, p is the number of
positive examples in the validation set covered by the rule, and n is the number
of negative examples in the validation set covered by the rtIe. ulppp is actually
similar to classification accuracy for the validation set. IREP favors rules that
have higher values of u1pBp. On the other hand, RIPPER applies the following
measure to determine whether a rule should be pruned:
u n t p p n n- : ' - =
p+n
(a) Suppose -R1 is covered by 350 positive examples and 150 negative ex-
amples, while R2 is covered by 300 positive examples and 50 negative
examples. Compute the FOIL's information gain for the rule Rz with
respectto R1.
(b) Consider a validation set that contains 500 positive examples and 500
negative examples. For R1, suppose the number of positive examples
covered by the rule is 200, and the number of negative examples covered
by the rule is 50. For rR2,suppose the number of positive examples covered
by the rule is 100 and the number of negative examples is 5. Compute
urREp for both rules. Which rule does IREP prefer?
(c) Compute uRrppEn for the previous problem. Which rule does RIPPER
prefer?
5.10 Exercises 3L7
4. Consider a training set that contains 100 positive examples and 400 negative
examples. For each of the following candidate rules,
determine which is the best and worst candidate rule according to:
5 . Figure 5.4 illustrates the coverage of the classification rules R1, ,R2, and R3.
Determine which is the best and worst rule according to:
6. (a) Suppose the fraction of undergraduate students who smoke is 15% and
the fraction of graduate students who smoke is 23%. If one-fifth of the
college students are graduate students and the rest are undergraduates,
what is the probability that a student who smokes is a graduate student?
318 Chapter 5 Classification: Alternative Techniques
(b) Given the information in part (a), is a randomly chosen college student
more likely to be a graduate or undergraduate student?
(c) Repeat part (b) assuming that the student is a smoker.
(d) Suppose 30% of the graduate students live in a dorm but only l0% of
the undergraduate students live in a dorm. If a student smokes and lives
in the dorm, is he or she more likely to be a graduate or undergraduate
student? You can assume independence between students who live in a
dorm and those who smoke.
Table
5.10.DatasetforExercise
7.
Record A B C Class
1 0 0 0 +
2 0 0 1
e 0 I 1
t
0 1 I
0 0 1 +
o 1 0 1 +
7 1 0 1
8 1 0 I
9 1 1 1 +
10 I 0 1 +
(a) Estimate the conditional probabilities for P(A : 1l+), P(B : 11a),
P(C : 1l+), P(.4 : 1l-), P(B : 1l-), and P(C : 1l-) using the
same approach as in the previous problem.
5.10 Exercises 319
5.11.DatasetforExercise
Table 8.
lnstance A B C Olass
I 0 0 1
2 1 0 1 +
J 0 1 0
4 1 0 0
5 1 0 I +
t 0 0 1 +
7 1 I 0
8 0 0 0
q
0 1 0 +
10 1 1 I +
(b) Use the conditional probabilities in part (a) to predict the class label for
a test sample (A : l, B : l,C :1) using the naive Bayes approach.
( c ) C o m p a r eP ( A : 1 ) , P(B: 1), and P(A: !,8 :1). Statethe relation-
ships between A and B.
(d) Repeat the analysis in part (c) using P(A : l), P(B : 0), and P(A:
1 , , B: 0 ) .
( e ) C o m p a r eP ( A : I , B : I l C l a s s : * ) a g a i n s tP ( A : l l C l a s s : * ) a n d
P(B : llClass: 1). Are the variables conditionally independent given
the class?
9. (a) Explain how naive Bayes performs on the data set shown in Figure 5.46.
(b) If each class is further divided such that there are four classes (AI, 42,
,B1, and B2), will naive Bayes perform better?
(c) How will a decision tree perform on this data set (for the two-class prob-
lem)? What if there are four classes?
10. Repeat the analysis shown in Example 5.3 for finding the location of a decision
boundary using the following information:
11. Figure 5.47 illustrates the Bayesian belief network for the data set shown in
Table 5.12. (Assume that all the attributes are binary).
(a) Draw the probability table for each node in the network.
32O Chapter 5 Classification: Alternative Techniques
Attributes
Figure
5.46,DatasetforExercise
9.
Figure
5.47,Bayesian
belief
network.
(b) Use the Bayesian network to compute P(Engine : Bad, Air Conditioner
: Broken).
12. Given the Bayesian network shown in Figure 5.48, compute the following prob-
abilities:
5,12.DatasetforExercise
Table 11.
Mileage Engine Air Conditioncr Number of Records Number of Records
with Car Value:Hi with Car Value:Lo
H Good Working J 4
Hi Good Broken 1 z
Hi Bad Working 1 K
Hi Bad Broken 0 A
Lo Good Working I 0
Lo Good Broken 1
Lo Bad Working I 2
Lo Bad Broken 0 z
P(B=bad)=0.1 P ( F = e m p t y=)0 . 2
Figure
5.48,Bayesian network
belief 12.
forExercise
(u) Classify the data point r : 5.0 according to its 1-, 3-, 5-, and 9-nearest
neighbors (using majority vote).
(b) Repeat the previous analysis using the distance-weighted voting approach
describedin Section 5.2.1.
Table
5.13.DatasetforExercise
13.
(t
x U.D 3.0 4.O 4.6 4.9 5 . 2 5 . 3 7.0 9.5
v + + -t- +
where nii is the number of examples from class i with attribute value Vi and
n, is the number of examples with attribute value [.
Consider the training set for the loan classification problem shown in Figure
5.9. Use the MVDM measure to compute the distance between every pair of
attribute values for the Home 0wner and Marital Status attributes.
1 5 . For each of the Boolean functions given below, state whether the problem is
linearly separable.
lo. (a) Demonstrate how the perceptron model can be used to representthe AND
and OR functions between a pair of Boolean variables.
(b) Comment on the disadvantage of using linear functions as activation func-
tions for multilayer neural networks.
1 7 . You are asked to evaluate the performance of two classification models, M1 and
M2. The test set you have chosen contains 26 binary attributes, labeled as ,4
throtgh Z.
Table 5.14 shows the posterior probabilities obtained by applying the models
to the test set. (Only the posterior probabilities for the positive class are
shown). As this is a two-classproblem, P(-) : 1- P(+) and P(-lA, . . . , Z) :
I - P(+lA, . . . , Z). Assume that we are mostly interested in detecting instances
from the positive class.
(a) PIot the ROC curve for both M1 and M2. (You should plot them on the
same graph.) Which model do you think is better? Explain your reasons.
(b) For model M1, suppose you choosethe cutoffthreshold to be f :0.5. In
other words, any test instances whose posterior probability is greater than
C will be classified as a positive example. Compute the precision, recall,
and F-measure for the model at this threshold value.
5.1-0 Exercises 323
Table5.14.Posterior
orobabilities 17.
forExercise
Instance Tlue Class P ( + \ A , . . , Z ,M r ) P ( + 1 , 4 , . . . , 2 , M 2 )
1 + 0. 0.61
2 + 0.69 0.03
3 0.44 0.68
4 0.55 0.31
5 + 0.67 0.45
6 + 0.47 0.09
7 0.08 0.38
8 0.15 0.05
q
+ 0.45 0.01
10 0.35 0.04
(c) Repeat the analysis for part (c) using the same cutoff threshold on model
M2. Compare the F-measure results for both models. Which model is
better? Are the results consistent with what you expect from the ROC
curve?
(d) Repeat part (c) for model M1 using the threshold t : 0.1. Which thresh-
old do you prefer, t : 0.5 or f : 0.1? Are the results consistent with what
you expect from the ROC curve?
18. Following is a data set that contains two attributes, X and Y, and two class
labels. "+" and "-". Each attribute can take three different values: 0' 1, or 2.
Number of
X Y Instances
+
0 0 0 100
1 0 0 U
2 0 0 100
0 1 10 100
I 1 10 0
2 I 10 100
0 2 0 100
1 2 0 0
2 2 0 100
The concept for the "+" class is Y : 1 and the concept for the "-" class is
X:0YX:2.
((1"
(a) Build a decision tree on the data set. Does the tree capture ffts 3,nd
tt-tt concepts?
324 Chapter 5 Classification: Alternative Techniques
(b) What are the accuracy, precision, recall, and F1-measure of the decision
tree? (Note that precision, recall, and F1-measureare defined with respect
to the "+" class.)
(") Build a new decision tree with the following cost function:
f 0, if i:i;
c(i,j):11, ifi:*,j:-:
, ir'i: -, j : +.
l ,*N'#B:ifii+fi#*tr
(Hint: only the leaves of the old decision tree need to be changed.) Does
the decision tree capture the "+" concept?
(d) What are the accuracy) precision, recall, and f'1-measure of the new deci-
sion tree?
19. (a) Consider the cost matrix for a two-classproblem. Let C(*, *) : C(-, -) :
p, C(+,-): C(-,1): q, and q ) p. Show that minimizingthe cost
function is equivalent to maximizing the classifier's accuracy.
(b) Show that a cost matrix is scale-invariant. For example, if the cost matrix
is rescaled from C(i, j) ------PC(i,j), where B is the scaling factor, the
decision threshold (Equation 5.82) will remain unchanged.
(c) Show that a cost matrix is translation-invariant. In other words, adding a
constant factor to all entries in the cost matrix will not affect the decision
threshold (Equation 5.82).
20. Consider the task of building a classifier from random data, where the attribute
values are generated randomly irrespective of the class labels. Assume the data
set contains records from two classes,"+" and "-." Half of the data set is used
for training while the remaining half is used for testing.
(a) Suppose there are an equal number of positive and negative records in
the data and the decision tree classifier predicts every test record to be
positive. What is the expected error rate of the classifieron the test data?
(b) Repeat the previous analysis assuming that the classifier predicts each
test record to be positive class with probability 0.8 and negative class
with probability 0.2.
(c) Suppose two-thirds of the data belong to the positive class and the re-
maining one-third belong to the negative class. What is the expected
error of a classifier that predicts every test record to be positive?
(d) Repeat the previous analysis assuming that the classifier predicts each
test record to be positive class with probabllity 213 and negative class
with orobabilitv 1/3.
5.10 Exercises 325
21. Derive the dual Lagrangian for the linear SVM with nonseparable data where
the objective function is
22. Consider the XOR problem where there are four training points:
( 1 ,1 ,- ) , ( 1 , 0+, ) ,( 0 ,1 ,+ ) , ( 0 , 0-,) .
23. Given the data sets shown in Figures 5.49, explain how the decision tree, naive
Bayes, and k-nearest neighbor classifiers would perform on these data sets.
326 Chapter 5 Classification: Alternative Techniques
Attrlbub Afrribuie6
Distinguishing
Anribule6 Noise Aflributes Anributes
Dislinguishing NoiseAtribut€s
lrl
tl
1l
I ClassA i:iii;:i;iii ClassA
lrrl
"'i
tt
ii '
ll
'' tr
,,
I Clss B
rrii' ClassB
llll I
,,i,':'il
rl
Attributes
Oistinguishing Oislinguishing
Attribute ret 1 Attributeset 2 Noise Attribules
ClassA ClassB ClassA ClassB ClassA
Figure
5.49.DatasetforExercise
23.
AssociationAnalysis:
BasicConceptsand
Algorithms
Many businessenterprisesaccumulate large quantities of data from their day-
to-day operations. For example, huge amounts of customer purchase data are
collected daily at the checkout counters of grocery stores. Table 6.1 illustrates
an example of such data, commonly known as market basket transactions.
Each row in this table correspondsto a transaction, which contains a unique
identifier labeled TID and a set of items bought by a given customer. Retail-
ers are interested in analyzing the data to learn about the purchasing behavior
of their customers. Such valuable information can be used to support a vari-
ety of business-related applications such as marketing promotions, inventory
management, and customer relationship management.
This chapter presents a methodology known as association analysis,
which is useful for discovering interesting relationships hidden in large data
sets. The uncovered relationships can be representedin the form of associa-
Table6.1. Anexample
of market transactions.
basket
TID Items
1 {Bread, Milk}
2 {Bread, Diapers, Beer, Eggs}
3 {Milk, Diapers, Beer, Cola}
4 {Bread, Milk, Diapers, Beer}
tr
{Bread, Milk, Diapers, Cola}
328 Chapter 6 Association Analvsis
tion rules or sets of frequent items. For example, the following rule can be
extracted from the data set shown in Table 6.1:
--'
{liapers} {eeer}.
The rule suggeststhat a strong relationship exists between the sale of diapers
and beer becausemany customers who buy diapers also buy beer. Retailers
can use this type of rules to help them identify new opportunities for cross-
selling their products to the customers.
Besidesmarket basket data, association analysis is also applicable to other
application domains such as bioinformatics, medical diagnosis, Web mining,
and scientific data analysis. In the analysis of Earth sciencedata, for example,
the association patterns may reveal interesting connections among the ocean,
land, and atmospheric processes.Such information may help Earth scientists
develop a better understanding of how the different elements of the Earth
system interact with each other. Even though the techniques presented here
are generally applicable to a wider variety of data sets,for illustrative purposes)
our discussionwill focus mainly on market basket data.
There are two key issuesthat need to be addressedwhen applying associ-
ation analysis to market basket data. First, discovering patterns from a large
transaction data set can be computationally expensive. Second, some of the
discoveredpatterns are potentially spurious becausethey may happen simply
by chance. The remainder of this chapter is organized around these two is-
sues. The first part of the chapter is devoted to explaining the basic concepts
of association analysis and the algorithms used to efficiently mine such pat-
terns. The second part of the chapter deals with the issue of evaluating the
discoveredpatterns in order to prevent the generation of spurious results.
ofmarket
0/1 representation
Table6.2.A binary data,
basket
TID Bread Milk Diapers Beer Eggs Cola
-l
I 1 0 0 0 0
2 1 0 1 I 1 0
3 0 1 1 1 0 1
4 1 1 1 I 0 0
5 1 1 1 0 0 I
This representationis perhaps a very simplistic view of real market basket data
becauseit ignores certain important aspects of the data such as the quantity
of items sold or the price paid to purchase them. Methods for handling such
non-binary data will be explained in Chapter 7.
Itemset and Support Count Let I : {h,i2,...,i'a} be the set of all items
in a market basket data and T : {h,t2,..-,t1"} be the set of all transactions'
Each transaction ti contains a subset of items chosen from 1. In association
analysis, a collection of zero or more items is termed an itemset. If an itemset
contains /c items, it is called a k-itemset. For instance, {Beer, Diapers, Mj-Ik}
is an example of a 3-itemset. The null (or empty) set is an itemset that does
not contain any items.
The transaction width is defined as the number of items present in a trans-
action. A transaction fy is said to contain an itemset X if X is a subset of
t7. For example, the secondtransaction shown in Table 6.2 contains the item-
set {Bread, Diapers} but not {Bread, Milk}. An important property of an
itemset is its support count, which refers to the number of transactions that
contain a particular itemset. Mathematically, the support count, o(X), for an
itemset X can be stated as follows:
where the symbol | . I denote the number of elements in a set. In the data set
shown in Table 6.2, the support count for {Beer, Diapers, Milk} is equal to
two because there are only two transactions that contain all three items.
o(XuY) .
Support, s(X ------+
I/) : 1 (6.1)
.Atr
o(X uY)
Confidence, c(X --+ Y) : (6.2)
"(x)
Example 6.1. Consider the rule {Uitt, Diapers} -----*{eeer}. Since the
support count for {ltitt<, Diapers, Beer} is 2 and the total number of trans-
actions is 5, the rule's support is 2f 5 :0.4. The rule's confidenceis obtained
by dividing the support count for {ttitt<, Diapers, Beer} by the support count
for {Uitt<, Diapers}. Since there are 3 transactions that contain milk and di-
apers,the confidencefor this rule is 213: 0.67. I
The proof for this equation is left as an exerciseto the readers (seeExercise 5
on page 405). Even for the small data set shown in Table 6.1, this approach
requires us to compute the support and confidencefor 36 - 27 * 1 : 602 rules.
More than 80% of the rules are discarded after applying mi,nsup : 20Vo and
minconf : 5070,thus making most of the computations become wasted. To
avoid performing needlesscomputations, it would be useful to prune the rules
early without having to compute their support and confidencevalues.
An initial step toward improving the performance of association rule min-
ing algorithms is to decouple the support and confidencerequirements. From
Equation 6.2, notice that the support of a rule X -----+Y depends only on
the support of its corresponding itemset, X U Y. For example, the following
rules have identical support because they involve items from the same itemset,
{Beer, Diapers, MiIk}:
----* ------
{Beer, Diapers} {t'li.ft}, {Beer, Milk} {Diapers},
-----r ----*
{Diapers, Milk} {eeer}, {eeer} {Diapers, Milk},
------ ------+
{uirt} {Beer,Diapers}, {oiapers} {Beer,Milk}.
If the itemset is infrequent, then all six candidate rules can be pruned imme-
diately without our having to compute their confidencevalues.
Therefore, a common strategy adopted by many association rule mining
algorithms is to decomposethe problem into two major subtasks:
1. FYequent Itemset Generation, whose objective is to find all the item-
sets that satisfy Lhemi,nsup threshold. These itemsets are called frequent
itemsets.
Figure
6.1.Anitemset
lattice.
t
N
M
thesupport
Figure6.2. Counting itemsets.
ofcandidate
To illustrate the idea behind the Apri,ore principle, consider the itemset
Iattice shown in Figure 6.3. Suppose {c, d, e} is a frequent itemset. Clearly,
any transaction that contains {c,d,e} must also contain its subsets, {",d},
{","}, {d,e}, {"}, {d}, and {e}. As a result, if {c,d,e} is frequent, then
all subsets of {c, d,e} (i.e., the shaded itemsets in this figure) must also be
frequent.
/
334 Chapter 6 Association Analysis
Figure6,3. An illustration
ol lhe Aprioriprinciple.
lt {c,d,e} is frequent,
thenall subsets
of this
itemset
arefrequent.
\r
Pruned
\\--_
Supersets
Figure6.4.Anillustration pruning.
ofsupport-based lt {a,b} isinfrequent, of {a,b}
thenallsupersets
areinfrequent.
Apri,ori, is the first association rule mining algorithm that pioneered the use
of support-based pruning to systematically control the exponential growth of
candidate itemsets. Figure 6.5 provides a high-level illustration of the frequent
itemset generation part of the Apriori algorithm for the transactions shown in
336 Chapter 6 Association Analysis
Candidate
1-ltemsets
Minimum count= 3
support
Itemsetsremoved
becauseof low
support
Candidate
3-ltemsets
Itemset Count
{Bread,Diapers,Milk} 3
Figure6.5. llluskation
of frequent generation
itemset usingtheApriorialgorithm.
(l).(i).1:6*6*1:13
candidates, which represents a 68% reduction in the number of candidate
itemsets even in this simple example.
The pseudocode for the frequent itemset generation part of the Apri,ori,
algorithm is shown in Algorithm 6.1. Let Cp denote the set of candidate
k-itemsets and Fr denote the set of frequent k-itemsets:
o The algorithm initially makes a single passover the data set to determine
the support of each item. Upon completion of this step, the set of all
frequent 1-itemsets, f'r, will be known (steps 1 and 2).
The algorithm terminates when there are no new frequent itemsets gen-
erated,i.e., Fp: 0 (step 13).
The frequent itemset generation part of the Apri,orz algorithm has two im-
portant characteristics. First, it is a level-wise algorithm; i.e., it traversesthe
itemset lattice one level at a time, from frequent 1-itemsets to the maximum
size of frequent itemsets. Second, it employs a generate-and-test strategy
for finding frequent itemsets. At each iteration, new candidate itemsets are
generated from the frequent itemsets found in the previous iteration. The
support for each candidate is then counted and tested against the minsup
threshold. The total number of iterations neededby the algorithm is k-.* a 1,
where k-r* is the maximum size of the frequent itemsets.
In principle, there are many ways to generate candidate itemsets. The fol-
Iowing is a list of requirements for an effectivecandidate generation procedure:
2. It must ensure that the candidate set is complete, i.e., no frequent item-
sets are left out by the candidate generation procedure. To ensure com-
pleteness,the set of candidate itemsets must subsume the set of all fre-
quent itemsets, i.e., Vk : fi, C Cp.
3. It should not generate the same candidate itemset more than once. For
example, the candidate itemset {a,b,c,d} can be generated in many
ways-by merging {a,b, c} with {d}, {b, d} with {o, {c} with {a,b, d},
"},
etc. Generation of duplicate candidates leads to wasted computations
and thus should be avoided for efficiency reasons.
CandidateGeneration
Itemset
Itreer, trreao, uora
iBeer,Bread,Diapers)
{Beer,Bread,Milk}
{Beer,Bread,Eqqs}
{Beer,Cola,Diapers}
{Beer,Cola,Milk}
itseer, uola, Eggs'
{Beer,Diaoers.Milk}
{Beer,Diapers,Eggs}
{Beer, Milk, Eqqs}
{Bread,Cola,Diapers}
{Bread, Cola, Milk}
{Dreao, uora, trqqsl
{Bread,Diapers,Milk}
{Breao,Drapers,
Eqqsl
{Bread, Milk, Eqqs}
lola, Diapers, Milk)
{Cola,Diapers,Eqqs)
{Cola,Milk,Eggs}
{Diapers,Milk,Eqqs)
Freouent
2-itemset
Candidate
CandidateGeneration
Pruning
Itemset
Itemset
{Beer,Diapers.Bread)
{Bread,Diapers,
Milk}
Frequent {Beer, Diapers.Milk}
1-itemset {Bread. Diapers,Milk}
{Bread, Milk, Beer}
Figure6,7.Generatingandpruning
candidate
k-itemsets
bymerging
a frequent(k - l)-itemsetwitha
item.Notethatsomeofthecandidates
frequent because
areunnecessary theirsubsets are infrequent,
This approach, howevet, does not prevent the same candidate itemset from
being generated more than once. For instance, {Bread, Diapers, Mitk} can
be generatedby merging {Bread, Diapers} with {Milk}, {Bread, MiIk} with
{niapers}, or {Diapers, MiIk} with {Bread}. One way to avoid generating
6.2 Requent Itemset Generation 34L
duplicate candidates is by ensuring that the items in each frequent itemset are
kept sorted in their lexicographic order. Each frequent (/c-l)-itemset X is then
extended with frequent items that are lexicographically larger than the items in
X. For example, the itemset {Bread, Diapers} can be augmented with {Milk}
since Mil-k is lexicographically larger than Bread and Diapers. However, we
should not augment {Diapers, MiIk} with {Bread} nor {Bread, Milk} with
{Oi-apers} becausethey violate the lexicographic ordering condition.
While this procedure is a substantial improvement over the brute-force
method, it can still produce a large number of unnecessarycandidates. For
example, the candidate itemset obtained by merging {Beer, Diapers} with
{Ui-ft} is unnecessarybecauseone of its subsets, {Beer, Milk}, is infrequent.
There are several heuristics available to reduce the number of unnecessary
candidates. For example, note that, for every candidate k-itemset that survives
the pruning step, every item in the candidate must be contained in at least
k - L of the frequent (k - 1)-itemsets. Otherwise, the candidate is guaranteed
to be infrequent. For example, {Beer, Diapers, Milk} is a viable candidate
3-itemset only if every item in the candidate, including Beer, is contained in
at least two frequent 2-itemsets. Since there is only one frequent 2-itemset
containing Beer, all candidate itemsets involving Beer must be infrequent.
ai: b i ( f o r z : 1 , 2 , . . . , k - 2 ) a n d a 7 r - 1I b n - t .
In Figure 6.8, the frequent itemsets {Bread, Diapers} and {Bread, Milk} are
merged to form a candidate 3-itemset {Bread, Diapers, Milk}. The algorithm
does not have to merge {Beer, Di-apers} with {Diapers, Milk} becausethe
first item in both itemsets is different. Indeed, if {Beer, Diapers, Milk} is a
viable candidate, it would have been obtained by merging {Beer, Diapers}
with {Beer, MiIk} instead. This example illustrates both the completenessof
the candidate generation procedure and the advantagesof using lexicographic
ordering to prevent duplicate candidates. However, becauseeach candidate is
obtained by merging a pair of frequent (k-1)-itemsets, an additional candidate
pruning step is needed to ensure that the remaining k - 2 subsets of the
candidate are frequent.
342 Chapter 6 Association Analysis
Frequent
2-itemset
Candidate Candidate
Generation Pruning
Frequent
2-itemsel
andpruning
Figure6.8,Generating candidate
k-itemsets pairsoffrequent
bymerging (k- l)-itemsets.
Transaction,
t
12356
Level 2
12
Figure6.9. Enumerating
subsets
ofthreeitemsfroma transaction
r.
items in f whose labels are greater than or equal to 5. The number of ways to
specify the first item of a 3-itemset contained in t is illustrated by the Level
1 prefix structures depicted in Figure 6.9. For instance, 1 [2J 5 6 I represents
a 3-itemset that begins with item 1, followed by two more items chosen from
t h e s e t{ 2 , 3 , 5 , 6 } .
After fixing the first item, the prefix structures at Level 2 represent the
number of ways to select the seconditem. For example, 1 2 F 5 6l corresponds
to itemsets that begin with prefix (1 2) and are followed by items 3, 5, or 6.
Finally, the prefix structures at Level 3 representthe complete set of 3-itemsets
contained in t. For example, the 3-itemsets that begin with prefix {1 2} are
{1,2,3}, {7,2,5}, and {1,2,6}, while those that begin with prefix {2 3} are
{2,3,5} and {2,3,6}.
The prefix structures shown in Figure 6.9 demonstrate how itemsets con-
tained in a transaction can be systematically enumerated, i.e., by specifying
their items one by one, from the leftmost item to the rightmost item. We
still have to determine whether each enumerated 3-itemset correspondsto an
existing candidate itemset. If it matches one of the candidates, then the sup-
port count of the corresponding candidate is incremented. In the next section,
we illustrate how this matching operation can be performed efficiently using a
hash tree structure.
344 Chapter 6 Association Analysis
Leaf nodes
containing
candidate
2-itemsets
Transactions
Bread,Milk,Diapers,Cola
Figure6.10.Counting
thesupport
of itemsets
usinghashstructure.
Hash Function
-'-:,@
Transaction
F,*;]
,-.w
item listed in the Level 2 structures shown in Figure 6.9. For example, after
hashing on item 1 at the root node, items 2, 3, and 5 of the transaction are
hashed. Items 2 and 5 are hashed to the middle child, while item 3 is hashed
to the right child, as shown in Figure 6.12. This process continues until the
leaf nodes of the hash tree are reached. The candidate itemsets stored at the
visited leaf nodes are compared against the transaction. If a candidate is a
subset of the transaction, its support count is incremented. In this example, 5
out of the 9 leaf nodes are visited and 9 out of the 15 itemsets are compared
against the transaction.
1+ l23s6l
---
Transaction
t;;;-:-:r
lrzrcol
z+
-@
3+
Figure6.12.Subset ontheleftmost
operation oftherootof a candidate
subtree hashtree.
x105
4
3.5
f;3
E
I zs
a
6
E r.s
3
E
z1 iil
0.5
\:, Y
il
0 It=--**-*-
10
Size of ltemsel
, x105
E
o
E
;
d
E
z
-+J-f-+-+-+
0
0 10
Size of ltemsel
9 v
t
8 il
il
o_ il
o il .F.
o6 il vv
6
il
il
() il
YI
6 ill v
E3 t:
z
A\y
1
'+#t*.
0
10 15
Size ol ltemset
x105
10
E
o
o
v
I
I
o4
z
2 \b
1 ;
4*+-. v
0
10 15
Size of ltemset
Figure6.14.Effect
of average
transaction
widthonthenumber
ofcandidate itemsets.
andfrequent
are contained in the transaction. This will increase the number of hash tree
traversals performed during support counting.
A detailed analysis of the time complexity for the Apri,ori, algorithm is
presented next.
6.3 Rule Generation 349
- z)lcnl( costormerging
.irr - 2)lLn-r12.
iU
k:2 k:2
A hash tree is also constructed during candidate generation to store the can-
didate itemsets. Because the maximum depth of the tree is k, the cost for
populating the hash tree with candidate itemsets rs O(l[:2klcrl). During
candidate pruning, we need to verify that the ,k- 2 subsetsof every candidate
k-itemset are frequent. Since the cost for looking up a candidate in a hash
tree is O(k), the candidate pruning step require" O(D|:rk(k - z)lckl) time.
Example 6.2. Let X : {I,2,3} be a frequent itemset. There are six candi-
date associationrules that can be generatedfrom X: {1,2} - i3}, {1,3} -
.----* ----- ._--> ----*
{2}, {2,3} {1}, {U {2,3}, {2} {1,3}, and {3} {1,2}. As
each of their support is identical to the support for X, the rules must satisfy
the support threshold. r
Computing the confidenceof an associationrule does not require additional
scansof the transaction data set. Consider the rule {1,2} - {3}, which is
generatedfrom the frequent itemset X : {1,2,3}. The confi.dencefor this rule
is o({1, 2,3}) lo({1, 2}). Because{1, 2, 3} is frequent,the anti-monotoneprop-
erty of support ensuresthat {1,2} must be frequent, too. Since the support
counts for both itemsets were already found during frequent itemset genera-
tion, there is no need to read the entire data set again.
Unlike the support measure) confidence does not have any monotone property.
For example, the confidence for X ------. Y can be larger, smaller, or equal to the
c o n f i d e n c e f o r a n o t h erru l e * ,t,where *gX andf e Y (seeExercise
3 on page 405). Nevertheless,if we compare rules generated from the same
frequent itemset Y, the following theorem holds for the confidencemeasure.
To prove this theorem, consider the following two rules: Xt ---', Y - Xt and
X +Y-X,where
- XtcX. T h e c o n f i d e n c e otfh e r u l e sa r e o ( Y ) l o ( X / ) a n d
o(V) lo(X), respectively.SinceX/ is a subsetof X , o(Xt) > Therefore,
"(X).
the former rule cannot have a higher confidencethan the latter rule.
I
I
\
\
\
\
aa Pruned
'..- --.'
Rules
Figure6.15,Pruning
ofassociation
rulesusingtheconfidence
measure.
Table6.3.Listofbinaryattributes
fromthe1984United Congressional
States Voting
Records.
Source:
TheUCImachine learningrepository.
Table
6.4.Association
rules
extracted
fromthe1984
United
States Voting
Congressional Records.
Association Rule Confidence
{budget resolution : no, Mx-missile:no, aid to El Salvador : yes } 9r.0%
------+
{Republican}
{budget resolution : y€s, MX-missile:yes, aid to El Salvador : no } 97.5%
-----+{Democrat}
{crime: y€s, right-to-sue : y€s, physician fee freeze : yes} 93.5To
------+
{Republican}
{crime : no, right-to-sue : no, physician fee freeze : no} l00Yo
------+
{Democrat}
Figure6.16,Maximal
frequent
itemset.
which all frequerrt itemsets can be derived. For example, the frequent itemsets
shown in Figure 6.16 can be divided into two groups:
o Frequent il;emsetsthat begin with item a and that may contain items c,
d, or e. This group includes itemsets such as {o), {o.,c), {a,d}, {a,e},
and{a,c,e}.
Requent itemsel;sthat belong in the first group are subsets of either {a,c,e}
or {4, d}, while those that belong in the secondgroup are subsetsof {b, c, d, e}.
Hence, the maximal frequent itemsets {a, c, e}, {o, d}, and {b, c, d, e} provide
a compact representation of the frequent itemsets shown in Figure 6.16.
Maximal frequent itemsets provide a valuable representation for data sets
that can produce very long, frequent itemsets, as there are exponentially many
frequent itemsets in such data. Nevertheless,this approach is practical only
if an efficient algorithm exists to explicitly find the maximal frequent itemsets
without havingto enumerate all their subsets. We briefly describe one such
approach in Secl;ion6.5.
Despite providing a compact representation, maximal frequent itemsets do
not contain the support information of their subsets. For example, the support
of the maximal fiequent itemsets {a,c,e}, {o,d}, and {b,c,d,e} do not provide
any hint about the support of their subsets. An additional pass over the data
set is therefore needed to determine the support counts of the non-maximal
frequent itemsets. In some cases, it might be desirable to have a minimal
representation of frequent itemsets that preservesthe support information.
We illustrate such a representation in the next section.
1 aoc
abcd
oce
1,2,4
4 acde
de
Figure6.17.Anexample
oftheclosed
frequent (withminimum
itemsets countequalto40%).
support
transaction IDs. For example, since the node {b, c} is associatedwith transac-
tion IDs 1,2, and 3, its support count is equal to three. Flom the transactions
given in this diagram, notice that every transaction that contains b also con-
tains c. Consequently,the support for {b} is identical to {b, c} and {b} should
not be considered a closed itemset. Similarly, since c occurs in every transac-
tion that contains both a and d, the itemset {o,d} is not closed. On the other
hand, {b, c} is a closed itemset because it does not have the same support
count as any of its supersets.
Definition 6.5 (Closed Flequent Itemset). An itemset is a closed fre-
quent itemset if it is closedand its support is greater than or equal to m'insup.
In the previous example, assumingthat the support threshold is 40%, {b,c}
is a closed frequent itemset becauseits support is 60%. The rest of the closed
frequent itemsets are indicated by the shaded nodes.
Algorithms are available to explicitly extract closed frequent itemsets from
a given data set. Interested readers may refer to the bibliographic notes at the
end of this chapter for further discussionsof these algorithms. We can use the
closed frequent itemsets to determine the support counts for the non-closed
6.4 Compact Representation of Requent Itemsets 357
frequent itemsets. For example, consider the frequent itemset {o,d} shown
in Figure 6.17. Becausethe itemset is not closed, its support count must be
identical to one of its immediate supersets. The key is to determine which
superset(amon6;{a,b,d}, {a,c,d}, or {a,d,e}) has exactly the same support
count as {a, d}. The Apri,ori,principle states that any transaction that contains
the superset of .l-a,d) must also contain {o,d}. However, any transaction that
contains {o,d} does not have to contain the supersets of {a,d}. For this
reason, the support for {a, d} must be equal to the largest support among its
supersets.Since {a, c, d} has a larger support than both {a,b,d} and {a,d,e},
the support for .[a,d] must be identical to the support for {4, c, d}. Using this
methodology, an algorithm can be developed to compute the support for the
non-closed frequent itemsets. The pseudocode for this algorithm is shown in
Algorithm 6.4. The algorithm proceeds in a specific-to-generalfashion, i.e.,
from the largest to the smallest frequent itemsets. This is because,in order
to find the support for a non-closedfrequent itemset; the support for all of its
supersetsmust be known.
To illustrate the advairtageof using closed frequent itemsets, consider the
data set shown in Table 6.5, which contains ten transactions and fifteen items.
The items can be divided into three groups: (1) Group -4, which contains
items ar through as; Q) Group B, which contains items b1 through b5i and
(3) Group C, which contains items c1 through c5. Note that items within each
group are perfectly associatedwith each other and they do not appear with
items from another group. Assuming the support threshold is 20To,the total
number of frequent itemsets is 3 x (25- 1) : 93. However, there are only three
closedfrequentitemsetsin the data: ({41,a2tayta4lab},{bt,bz,bz,b+,b5},and
{"t,"z,cs,ca,c5}). It is often sufficient to present only the closed frequent
itemsets to the analysts instead of the entire set of frequent itemsets.
358 Chapter 6 Association Analysis
Table
6.5.Atransaction
datasetforminino itemsets.
closed
TID A7 A2 AJ A4 As O1 bz bs ba b5 C1 C2 ca C4 Cb
I I 1 I I 1 0 0 0 0 0 0 U U 0 0
2 I 1 1_ 1_ 1 0 0 0 0 0 0 0 0 0 0
J 1 I 1. l. I 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 I 1 1 1 1 0 0 0 0 0
( 0 0 0 0 0 I 1 1 1 1 0 0 0 0 0
t) 0 0 0 0 0 I 1 1 1 1 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
e 0 0 0 0 0 0 0 0 0 0 1 L I 1 1
rl 0 0 0 0 0 0 0 0 0 0 1 1 1 I I
10 0 0 0 0 0 0 0 0 0 0 1 1 I 1 1
Figure6.18.Relationships frequent,
among maximal
frequent,
andclosed itemsets.
frequent
Closed frequent itemsets are useful for removing some of the redundant
association rules. An association rule X ------Y is redundant if there exists
another rule X/ ------Y' , where X is a subset of X/ and Y is a subset of Y/, such
that the support and confidence for both rules are identical. In the example
shown in Figure 6.L7, {b} is not a closedfrequent itemset while {b, c} is closed.
The association rule {b} - {d, e} is therefore redundant becauseit has the
sarne support and confidence as {b, c} - {d,"}. Such redundant rules are
not generated if closed frequent itemsets are used for rule generation.
Finally, note that all maximal frequent itemsets are closed because none
of the maximal frequent itemsets can have the same support count as their
immediate supersets. The relationships among frequent, maximal frequent,
and closed frequent itemsets are shown in Figure 6.18.
6.5 Alternative Methods for Generating Frequent Itemsets 359
Frequent
Itemset Frequent
Border null Itemset null
\
{a1,a2,...,an} {a1,a2,...,an} ltemsel
Border
(a) General-to-specific (b) Specific-to-general (c) Bidirectional
Figure6.19.General-to-specific,
specific{o-general,
andbidirectional
search.
store the candidate itemsets, but it can help to rapidly identify the fre-
quent itemset border, given the configuration shown in Figure 6.19(c).
\.--/
(a) Prefixtree.
Figure
6,20"Equivalence
classes ontheprefix
based andsuffix
labels
ofitemsets.
Figure
6,21.Breadth{irst
anddepth-first
traversals.
I \
I o )l
I I- t,
I
I I
I
qc I
I de I
\
tt
)r bcd
ade bce bde cde r/
//
--------t'
abce abde
abcde
Figure6.22.Generating
candidate
itemsets
usingthedepth{irst
approach.
performed on its subsets. For example, if the node bcde shown in Figure
6.22 is maximal frequent, then the algorithm does not have to visit the
subtrees rooted at bd,,be, c, d, and e becausethey will not contain any
maximal frequent itemsets. However, if abcis maximal frequent, only the
nodes such as ac and bc arc not maximal frequent (but the subtrees of
ac and bc may still contain maximal frequent itemsets). The depth-first
approach also allows a different kind of pruning based on the support
of itemsets. For example, suppose the support for {a,b,c} is identical
to the support for {a, b}. The subtrees rooted at abd and abe can be
skipped because they are guaranteed not to have any maximal frequent
itemsets. The oroof of this is left as an exerciseto the readers.
Horizontal
Data Layout VerticalData Layout
'l 2 1
1 2
4 2 3 4 3
5 5 4 5 o
6 7 8 I
7 I I
8 10
9
dataformat.
andvertical
Figure6.23,Horizontal
sized itemsets. [fowever, one problem with this approach is that the initial
set of TlD-lists may be too large to fit into main memory, thus requiring
more sophisticated techniquesto compressthe TlD-lists. We describe another
effective approach to represent the data in the next section.
Transaction
DataSet
b:1
(iv)Afterreading
TID=10
Figure6.24,Construction
of anFP-tree.
Figure 6.24 shows a data set that contains ten transactions and five items.
The structures ofthe FP-tree after reading the first three transactions are also
depicted in the diagram. Each node in the tree contains the label of an item
along with a counter that shows the number of transactions mapped onto the
given path. Initially, the FP-tree contains only the root node representedby
the nulf symbol. The FP-tree is subsequently extended in the following way:
1. The data set is scanned once to determine the support count of each
item. Infrequent items are discarded, while the frequent items are sorted
in decreasingsupport counts. For the data set shown in Figure 6.24, a
is the most frequent item, followed by b, c, d, and e.
6.6 FP-GrowthAlgorithm 365
2. The algoril;hm makes a second pass over the data to construct the FP-
tree. After reading the first transaction, {o,b), the nodes labeled as a
and b are created. A path is then formed from nulI --+a '--+b to encode
the transaction. Every node along the path has a frequency count of 1.
3. After reading the second transaction, {b,cd}, a new set of nodes is cre-
ated for items b, c, arrd d. A path is then formed to represent the
transaction by connecting the nodes null ---+b ---+c -* d. Every node
along this path also has a frequency count equal to one. Although the
first two transactions have an item in common, which is b, their paths
are disjoint becausethe transactions do not share a common prefix.
5. This processcontinues until every transaction has been mapped onto one
of the paths given in the FP-tree. The resulting FP-tree after reading
all the transactions is shown at the bottom of Figure 6.24.
The sizeof an FP-tree is typically smaller than the sizeof the uncompressed
data because ma,ny transactions in market basket data often share a few items
in common. In the best-case scenario, where all the transactions have the
same set of iterns, the FP-tree contains only a single branch of nodes. The
worst-casescenario happens when every transaction has a unique set of items.
As none of the transactions have any items in common, the size of the FP-tree
is effectively the same as the size of the original data. However, the physical
storage requirement for the FP-tree is higher because it requires additional
space to store pointers between nodes and counters for each item.
The size of an FP-tree also depends on how the items are ordered. If
the ordering scheme in the preceding example is reversed, i.e., from lowest
to highest support item, the resulting FP-tree is shown in Figure 6.25. The
tree appears to be denser because the branching factor at the root node has
increased from 2 to 5 and the number of nodes containing the high support
items such as a and b has increased from 3 to 12. Nevertheless, ordering
by decreasing support counts does not always lead to the smallest tree. For
exanlple, suppose we augment the data set given in Figure 6.24 with 100
transactions that contain {e}, 80 transactions that contain {d}, 60 transactions
366 Chapter 6 Association Analysis
..-. c:2
d:2
b:1
"'it
"-a:l
Figure6.25. An FP-treerepresentation
for thedataset shownin Figure6.24witha different
item
ordering
scheme.
that contain {"}, and 40 transactions that contain {b}. Item e is now most
frequent, followed by d, c, b, and a. With the augmented transactions, ordering
by decreasingsupport counts will result in an FP-tree similar to Figure 6.25,
while a schemebased on increasing support counts produces a smaller FP-tree
similar to Figure 6.2a$v).
An FP-tree also contains a list of pointers connecting between nodes that
have the same items. These pointers, represented as dashed lines in Figures
6.24 and 6.25, help to facilitate the rapid accessof individual items in the tree.
We explain how to use the FP-tree and its corresponding pointers for frequent
itemset generation in the next section.
c:3
d:1
Figure6.26.Decomposing
thefrequent generation
itemset problemintomultiple where
subproblems,
eachsubproblem
involves
findingfrequent
itemsets ine,d,c,b,anda.
ending
Table6.6.Thelistoffrequent
itemsets
ordered suffixes.
bytheircorresponding
Suffix FbequentItemsets
e {e}, {d,e}, {a,d,e}, {c,e},{a,e}
d {d}, {c,d}, {b,c,d}, {a,c,d}, {b,d}, {a,b,d}, {a,d}
c {c}, { b , c } , { a , b , c } ,{ a , c }
b {b}, {a,b}
a {a}
d:1 d:1
(b) ConditionalFP-treefor e
n u l l .)
I
d
c:1 c:1 a:2
(e) Prefixpathsendingin ce (f) Prefixpathsending
in ae
Figure6.27.Example
ofapplying
theFP-growth tofindfrequent
algorithm itemsets ine.
ending
1. The first step is to gather all the paths containing node e. These initial
paths are called prefix paths and are shown in Figure 6.27(a).
2. Fbom the prefix paths shown in Figure 6.27(a), the support count for e is
obtained by adding the support counts associatedwith node e. Assuming
that the minimum support count is 2, {e} is declared a frequent itemset
becauseits support count is 3.
6.6 FP-GrowthAlgorithm 369
(a) First, the support counts along the prefix paths must be updated
becausesome ofthe counts include transactions that do not contain
item e. For example, the rightmost path shown in Figure 6.27(a),
nufl ------+
b:2 -------+
c:2 ------+
e:1, includes a transaction {b,c} that
does not contain item e. The counts along the prefix path must
therefore be adjusted to 1 to reflect the actual number of transac-
tions containing {b, c, e}.
(b) The prefix paths are truncated by removing the nodes for e. These
nodes can be removed becausethe support counts along the prefix
pathsrhave been updated to reflect only transactions that contain e
and the subproblems of finding frequent itemsets ending in de, ce,
be, anrdae no longer need information about node e.
(c) After updating the support counts along the prefix paths, some
of the items may no longer be frequent. For example, the node b
appears only once and has a support count equal to 1, which means
that there is only one transaction that contains both b and e. Item b
can be safely ignored from subsequent analysis because all itemsets
ending in be must be infrequent.
The conditional FP-tree for e is shown in Figure 6.27(b). The tree looks
different than the original prefix paths becausethe frequency counts have
been updated and the nodes b and e have been eliminated.
A FP-growth usesthe conditional FP-tree for e to solve the subproblems of
finding frequent itemsets ending in de, ce, and ae. To find the frequent
itemsets ending in de, the prefix paths for d are gathered from the con-
ditional FP-tree for e (Figure 6.27(c)). By adding the frequency counts
associatedwith node d, we obtain the support count for {d,e}. Since
the support count is equal to 2, {d,e} is declared a frequent itemset.
Next, the algorithm constructs the conditional FP-tree for de using the
approach described in step 3. After updating the support counts and
removing the infrequent item c, the conditional FP-tree for de is shown
in Figure 6.27(d). Since the conditional FP-tree contains only one item,
37O Chapter 6 Association Analysis
Tabfe6.7.A 2-way
contingency
tableforvariables
A andB.
B B
A Jtl JLO fr+
T
A J01 ./ 00 fo+
J+O t/
preferences
Table6.8.Beverage a group
among of1000people.
Cof f ee Cof f ee
Tea 150 50 200
Tea 650 150 800
800 200 1000
6.7 Evaluation of Association Patterns 373
The information given in this table can be used to evaluate the association
rule {?ea,} ------,
{Cof f ee}. At fi.rstglance,it may appear that people who drink
tea also tend to drink coffee becausethe rule's support (15%) and confidence
(75%) values are reasonably high. This argument would have been acceptable
except that the fraction of people who drink coffee, regardless of whether they
drink tea, is 80%, while the fraction of tea drinkers who drink coffee is only
75%. Thus knowing that a person is a tea drinker actually decreasesher
probability of being a coffee drinker from 80% to 75Tol The rule {Tea) -,
{Cof f ee} is therefore misleading despite its high confidencevalue. r
The pitfall of confidence can be traced to the fact that the measure ignores
the support of the itemset in the rule consequent. Indeed, if the support of
coffee drinkers is taken into account, we would not be surprised to find that
many of the people who drink tea also drink coffee. What is more surprising is
that the fraction of tea drinkers who drink coffee is actually less than the overall
fraction of people who drink coffee, which points to an inverse relationship
between tea drinkers and coffeedrinkers.
Because of rbhelimitations in the support-confidence framework, various
objective measures have been used to evaluate the quality of association pat-
terns. Below, we provide a brief description of these measures and explain
some of their strengths and limitations.
(6.4)
which computes the ratio between the rule's confidence and the support of
the itemset in the rule consequent. For binary variables, Iift is equivalent to
another objective measure called interest factor, which is defined as follows:
I(4, B) :
s ( A ,B ) _ N"frr (6.5)
s(,4)x s(B) f+f +t
Interest factor compares the frequency of a pattern against a baseline fre-
quency computed under the statistical independence assumption. The baseline
frequency for a pair of mutually independent variables is
fn :1fr
f+ h+f+t
t?,f+t ir
or equivalently,"fn:t:;:: (6.6)
f
Chapter Association Analysis
Table
6.9.Contingency forthewordpairs
tables ({p,q}and{r,s}.
p p r r
q 880 bt, 930 s 20 50 70
q 50 20 70 5 CU 880 930
930 70 1000 70 930 r000
This equation follows from the standard approach of using simple fractions
as estimates for probabilities. The fraction fnlN is an estimate for the joint
probability P(A,B), while fia/,n/ and fyf N are the estimates for P(A) and
P(B), respectively.lt A and B are statistically independent,then P(A,B):
P(A) x P(B), thus leading to the formula shown in Equation 6.6. Using
Equations 6.5 and 6.6, we can interpret the measure as follows:
For the tea-coffeeexample shown in Table 6.8, 1: O.H3_8- :0.9375, thus sug-
gesting a slight negative correlation between tea drinkers and coffee drinkers.
IS Measure .I^9is an alternative measure that has been proposed for han-
dling asymmetric binary variables. The measure is defined as follows:
rs(A,B) : (6.e)
Note that .LS is large when the interest factor and support of the pattern
are large. For example, the value of 1^9for the word pairs {p, q} and {r, s}
shown in Table 6.9 are 0.946 and 0.286, respectively. Contrary to the results
given by interest factor and the @-coefficient, the 15 measure suggests that
the association between {p, q} i. stronger than {r, s}, which agreeswith what
we expect from word associationsin documents.
It is possible to show that 15 is mathematically equivalent to the cosine
measurefor binary variables (seeEquation2.T on page 75). In this regard, we
376 Chapter 6 Association Analysis
q q
I-S\ (- Ar,-s' : - $ : ,
-a l' : cosi,ne(A,B). (6.10)
J4A) AB) l a l x "I*n,l
The 1,S measurecan also be expressedas the geometric mean between the
confidenceof association rules extracted from a pair of binary variables:
Because the geometric mean between any two numbers is always closer to the
smaller number, the 1^9value of an itemset {p, q} is low whenever one of its
rules, p ---+ Q or e + p, has low confidence.
s ( A ,B ) s(A) x s(B)
B) :
IS1"a"o(,4, s(.4)x
s(A) x s(B)
since the value depends on s(A) and s(B), IS shares a similar problem as
the confidence measure-that the value of the measure can be quite large,
even for uncorrelated and negatively correlated patterns. For example, despite
the large 1^9 value between items p and q given in Table 6.10 (0.889), it is
still less than the expected value when the items are statistically independent
(ISi'auo : 0.9).
6.7 Evaluation of Association Patterns 377
Besides the measureswe have described so far, there are other alternative mea-
sures proposed for analyzing relationships between pairs of binary variables.
These measurescan be divided into two categories, symmetric and asym-
metric measures. A measureM is symmetric if M(A --'- B): M(B ------A).
For example, interest factor is a symmetric measure becauseits value is iden-
tical for the rules A ------+
B and B ---- A. In contrast, confidence is an
asymmetric measure since the confidence for A ---. B and B -'----+,4. may not
be the same. Symmetric measuresare generally used for evaluating itemsets,
while asymmetric measures are more suitable for analyzing association rules.
Tables 6.11 and 6.12 provide the definitions for some of these measures in
terms of the frequency counts of a 2 x 2 contingency table.
Tabfe
6.11.Examples objective
ofsymmetric fortheitemset
measures {A, B}.
Measure(Symbol) Definition
N"frr -"fr+f+r
Correlation (@) t;_-i--
v Jr+J+1J0+J+o
/ . ? \ l l o a \
Odds ratio (a) \IttIoo) / (,1'to"rot/
N"frr +Nloq lrr.ffl:/ot_lt_q
--Nt=1+
Kappa (rc)
f-+r=j;+j+"
/^rr \ llr r \
Interest (1) \1\ Jtl)/ U1+J+1/
/ r \ l/ /-.-.a'-- r-\
Cosine (1S) \Irt) / \t/ It+J+r)
Piatetsky-Shapiro (P,9) .flt - --T-
JL+J+1
M
Collective strength (S)
Jaccard (o fu f( fr + + f+t
All-confidence (h) -i"[#,#]
378 Chapter 6 Association Analysis
Tabfe6.12.Examples
ofasymmetric
objective fortheruleA ------+
measures B.
Measure (Symbol) Definition
Table
6.13.Example
ofcontingency
tables.
Example . t1 7 .t10 J01 foo
E1 8 123 83 424 1370
E2 8330 2 622 r046
Es 3954 3080 5 296r
Ea 2886 1363 1320 4431
E5 1500 2000 500 6000
E6 4000 2000 1000 3000
R. 9481 298 \27 94
Es 4000 2000 2000 2000
Es 7450 2483 4 63
Erc 61 2483 /l 7452
Table6.14.Rankings tablesusingthesymmetric
of contingency giveninTable
measures 6.11.
o a K I IS PS ^9 C h
n1 1 3 I tt 2 2 1 2 2
r 2 3 3
E2 2 1 2 7 3
E3 3 2 A ^ 5 1 3 o 8
F7
Ea i
8 3 3 I 3 4 7 5
n q q
E5 5 I 0 2 6 6 9
E6 6 9 5 5 o 4 E
J l) 7
,7 ,7
E7 6. I 1 8 7 1 1
F7
E8 8 10 8 8 8 8 8 1
I
q
Es 9 4 I 10 4 I 4 4
Erc 10 5 10 1 10 10 10 10 10
Table6.15.Rankings tablesusingtheasymmetric
ofcontingency giveninTable
measures 6.12.
) M J G L V F AV
r
E1 I 1
r 1 1 4 2 2 J
tr
E2 2 2 2 .) J 1 I 6
tr r 4
E3 3 2 2 6 o
q I
Ea 4 o 3 4 3 3
q F7
4 8 tr
2
E5 6 D d
r F7 n
3
E6 3 8 6 4
.7 q
E7 7 5 9 8 3 7
,7
Eg 8 9 7 10 8 8 7
'| q
Es 6 4 10 I I 10
Eto 10 10 8 10 h 1 0 10 8
factor and odds ratio. Furthermore, a contingency table such as -E1sis ranked
lowest according to the @-coefficient,but highest according to interest factor.
The results shown in Table 6.14 suggestthat a significant number of the mea-
sures provide conflicting information about the quality of a pattern. To under-
stand their differences,we need to examine the properties of these measures.
Inversion Property Consider the bit vectors shown in Figure 6.28. The
0/1 bit in each column vector indicates whether a transaction (row) contains
a particular item (column). For example, the vector A indicates that item a
380 Chapter 6 Association Analysis
A B CD EF
( ) (b) (c)
Figure6,28. Effectof theinversionoperation.
ThevectorsC andE areinversions
of vectorA, while
thevectorD is aninversion of vectors
B andF.
belongs to the first and last transactions, whereas the vector B indicates that
item b is contained only in the fifth transaction. The vectors C and E are in
fact related to the vector A-their bits have been inverted from 0's (absence)
to l's (presence),and vice versa. Similarly, D is related to vectors B and F by
inverting their bits. The process of flipping a bit vector is called inversion.
If a measure is invariant under the inversion operation, then its value for the
vector pair (C, D) should be identical to its value for (A, B). The inversion
property of a measure can be tested as follows.
Scaling Property Table 6.16 shows the contingency tables for gender and
the grades achieved by students enrolled in a particular course in 1993 and
2004. The data in these tables showed that the number of male students has
doubled since 1993, while the number of female students has increased by a
factor of 3. However, the male students in 2004 are not performing any better
than those in 1993 because the ratio of male students who achieve a high
grade to those who achieve a low grade is still the same, i.e., 3:4. Similarly,
the female students in 2004 are performing no better than those in 1993. The
associationbetween grade and gender is expected to remain unchangeddespite
changesin the sampling distribution.
6.16.Thegrade-gender
Table example.
Male Female
High High 60 60 720
Low Low 80 30 t1
740 90 230
(a) Sample data from 1993. (b) Sample data from 2004.
382 Chapter 6 Association Anal.ysis
Table
6.17.Properties
ofsymmetric
measures.
Svmbol Measure Inversion Null Addition Scaling
0 @-coefficient Yes No L\O
a odds ratio Yes No Yes
K Cohen's Yes No No
r Interest No No No
IS Cosine No Yes No
PS Piatetsky-Shapiro's Yes No No
,9 Collective strength Yes No No
e Jaccard No Yes No
h All-confidence No No No
Support No No No
From Table 6.17, notice that only the odds ratio (a) is invariant under
the row and column scaling operations. All other measures such as the f
coefficient, n, IS, interest factor, and collective strength (,9) change their val-
ues when the rows and columns of the contingency table are rescaled. Although
we do not discussthe properties of asymmetric measures(such as confidence,
J-measure, Gini index, and conviction), it is clear that such measuresdo not
preservetheir values under inversion and row/column scaling operations, but
are invariant under the null addition oneration.
Table6.18.Example
of a three-dimensional table.
contingency
t. -
f o . r + . . . +fx+ b . . . +x ' . . x f + + . . . t o (6.12)
J L\t2...Itc
AIk-1
With this definition, we can extend objective measures such as interest factor
and P,S, which are based on deviations from statistical independence'to more
than two variables:
Iy'ft-1 x ftrb...tr
T_
f , . r + . . . +fx+ b . . . +x . . . x f + + . . t u
ps : I+-- lvrlt
Table
6.19.A two-way
contingency
tablebetween
thesaleofhigh-definition
television
andexercise
machine.
Buy Buv Exercise Machine
HDTV Yes No
YES 99 81 180
No o4 66 t20
153 L47 300
Table6,20.Example
ofa three-way
contingency
table.
Customer lJuy Buy Exercise Machine Total
Group HDTV YCS No
College Students Yes I 9 10
No A 30 34
Working Adult YES 98 72 770
No 50 36 86
than college students who buy these items. For college students:
---' Ill0:10To,
c({UOfV:Yes} {Exercise machine:Yes})
-----* 4134: 7I.8To,
c({HOtV:No} {Exercise machine:Yes})
The rules suggest that, for each group, customers who do not buy high-
definition televisions are more likely to buy exercise machines, which contradict
the previous conclusion when data from the two customer groups are pooled
together. Even if alternative measures such as correlation, odds ratio' or
interest are applied, we still find that the sale of HDTV and exercise machine
is positively correlated in the combined data but is negatively correlated in
the stratified data (seeExercise 20 on page 414). The reversal in the direction
of association is known as Simpson's paradox.
The paradox can be explained in the following way. Notice that most
customers who buy HDTVs are working adults. Working adults are also the
largest group of customers who buy exercise machines. Because nearly 85% of
the customers are working adults, the observed relationship between HDTV
and exercise machine turns out to be stronger in the combined data than
what it would have been if the data is stratified. This can also be illustrated
mathematically as follows. Suppose
where afb andplqmay represent the confidence of the rule A ---, B in two
different strata, while cld and rf s may represent the confidence of the rule
A ------+
B in the two strata. When the data is pooled together' the confidence
valuesof the rules in the combineddata are (a+dl@+q) and (c+r)l@+s),
respectively. Simpson's paradox occurs when
a*P clr
b+q> d+r'
thus leading to the wrong conclusion about the relationship between the vari-
ables. The lesson here is that proper stratification is needed to avoid generat-
ing spurious patterns resulting from Simpson's paradox. For example, market
386 Chapter 6 Association Analysis
1000 1500
Itemssortedby support
Figure6.29.Support
distribution
of itemsinthecensus
dataset.
Table6.21.Grouping
theitemsinthecensus values.
datasetbasedontheirsupport
Group G1 G2 Gs
Support <t% r % - 9 0 % > gUYa
1-Dr
Number of Items I'dU 358 20
(6.13)
m i n [ 0 . 7 , 0 . 1 , 0 . 0 0 0 4 ]0.0004
: 0.00058
< 0.01.
m a x 1 0 . 7 , 0 . 1 , 0 . 0 0 0 4 10 . 7
I
Figure6.30.A transaction
datasetcontaining p, q,?fidr, where
threeitems, p isa highsupport
item
andq andr arelowsupportitems.
{ii} - { i r , i , r , .. . , i i - r , i i + r , . . . , i n }
s({i,1,i.2,...,i,n))
'
m a x [ s ( i 1 ) ,s ( i z ) , . . . , s ( i r ) ]
ty),'' 't!':ll
< gt" l,-t!'.tl'
h-confidence(x)
m a x i s ( e 1) , s \ z z ) , .. . , s \ L k ) )
and thus can be incorporated directly into the mining algorithm. Furthermore,
h-confidenceensuresthat the items contained in an itemset are strongly asso-
ciated with each other. For example, suppose the h-confidenceof an itemset
X is 80%. If one of the items in X is present in a transaction, there is at least
an 80% chance that the rest of the items in X also belong to the same trans-
action. Such strongly associatedpatterns are called hyperclique patterns.
Conceptual Issues
al. [315] to extend the traditional notion of support to more general patterns
and attribute types.
6.9 Bibliographic Notes 393
o
(t)
(tt
c
(u
o
(E
C)
o
U'
.Jt
(E
ct) E
'c= o o
U)
9"0 o< <D
=g
'-G
c -v= x
Yd
.=
(J
C'
' = K E e -. g=:
f/'tL .c
o- id
C)
CE
.:..;,+-FF< (D
6.9, =v xA
,*F st-+A"x^
E = =? aJ>
<D
-(E i?f?i?-iY
.l)
EB o
::
FE
6< oo
(5
o
o -c
E -o
o
oo
(o
E
E
5
C"
-a?
(o
o
5
.9
IJ-
,9.9 a
S :EB :
gE€
'EecEgE
394 Chapter 6 Association Analysis
Implementation Issues
Researchactivities in this area revolve around (1) integrating the mining ca-
pability into existing databasetechnology, (2) developing efficient and scalable
mining algorithms, (3) handling user-specifiedor domain-specific constraints,
and ( ) post-processingthe extracted patterns.
There are several advantages to integrating association analysis into ex-
isting database technology. First, it can make use of the indexing and query
processingcapabilities of the database system. Second,it can also exploit the
DBMS support for scalability, check-pointing, and parallelization [301]. The
SETM algorithm developed by Houtsma et al. [265] was one of the earliest
algorithms to support association rule discovery via SQL queries. Since then,
numerous methods have been developedto provide capabilities for mining as-
sociation rules in databasesystems. For example, the DMQL [258]and M-SQL
[267] query languagesextend the basic SQL with new operators for mining as-
sociation rules. The Mine Rule operator [283] is an expressiveSQL operator
that can handle both clustered attributes and item hierarchies. Tsur et al.
[322] developed a generate-and-testapproach called query flocks for mining
associationrules. A distributed OLAP-based infrastructure was developed by
Chen et al. l2aL] for mining multilevel association rules.
Dunkel and Soparkar l2a8] investigated the time and storage complexity
of the Apri,ori algorithm. The FP-growth algorithm was developedby Han et
al. in [259]. Other algorithms for mining frequent itemsets include the DHP
(dynamic hashing and pruning) algorithm proposed by Park et al. [292] and
the Partition algorithm developed by Savasereet al [303]. A sampling-based
frequent itemset generation algorithm was proposed by Toivonen [320]. The
algorithm requires only a single pass over the data, but it can produce more
candidate itemsets than necessary. The Dynamic Itemset Counting (DIC)
algorithm [239] makes only 1.5 passesover the data and generatesless candi-
date itemsets than the sampling-based algorithm. Other notable algorithms
include the tree-projection algorithm [223] and H-Mine [295]. Survey articles
on frequent itemset generation algorithms can be found in 1226,262]. A repos-
itory of data sets and algorithms is available at the Frequent Itemset Mining
Implementations (FIMI) repository (http:llfirni.cs.helsinki.fi). Parallel algo-
rithms for mining association patterns have been developed by various authors
[224,256,287,306,337]. A survey of such algorithms can be found in [333].
Online and incremental versionsof associationrule mining algorithms had also
been proposed by Hidber [260] and Cheung et aL. 12421.
Srikant et al. [313] have consideredthe problem of mining associationrules
in the presenceof boolean constraints such as the following:
6.9 Bibliographic Notes 395
Given such a constraint, the algorithm looks for rules that contain both cook-
ies and milk, or rules that contain the descendent items of cookies but not
ancestor items of wheat bread. Singh et al. [310] and Ng et al. [288] had also
developed alternative techniques for constrained-based association rule min-
ing. Constraints can also be imposed on the support for different itemsets.
This problem was investigated by Wang et al. [324], Liu et al. in [279], and
Seno et al. [305].
One potential problem with association analysis is the large number of
patterns that can be generated by current algorithms. To overcomethis prob-
lem, methods to rank, summarize, and filter patterns have been developed.
Toivonen et al. [321] proposed the idea of eliminating redundant rules using
structural rule covers and to group the remaining rules using clustering.
Liu et al. [280]applied the statistical chi-squaretest to prune spurious patterns
and summarized the remaining patterns using a subset of the patterns called
direction setting rules. The use of objective measures to filter patterns
has been investigated by many authors, including Brin et al. [238], Bayardo
and Agrawal [235], Aggarwal and Yu 12271,and DuMouchel and Pregibon[2a7].
The properties for many of these measureswere analyzed by Piatetsky-Shapiro
[297], Kamber and Singhal [270], Hilderman and Hamilton [261], and Tan et
al. [318]. The grade-genderexample used to highlight the importance of the
row and column scaling invariance property was heavily influenced by the
discussion given in [286] by Mosteller. Meanwhile, the tea-coffeeexample il-
lustrating the limitation of confidence was motivated by an example given in
[238] by Brin et al. Becauseof the limitation of confidence,Brin et al. [238]
had proposed the idea of using interest factor as a measure of interesting-
ness. The all-confidence measure was proposed by Omiecinski [289]. Xiong
et al. [330] introduced the cross-support property and showed that the all-
confi.dencemeasure can be used to eliminate cross-support patterns. A key
difficulty in using alternative objective measuresbesidessupport is their lack
of a monotonicity property, which makes it difficult to incorporate the mea-
sures directly into the mining algorithms. Xiong et al. [328] have proposed
an efficient method for mining correlations by introducing an upper bound
function to the fcoefficient. Although the measure is non-monotone, it has
an upper bound expressign that can be exploited for the efficient mining of
strongly correlated itempairs.
Fabris and Fleitas [249] have proposed a method for discovering inter-
esting associationsby detecting the occurrencesof Simpson's paradox [309].
Megiddo and Srikant [282] described an approach for validating the extracted
396 Chapter 6 Association Analysis
Application fssues
Bibliography
[223] R. C. Agarwal, C. C. Aggarwal, and V. V. V. Prasad. A Ttee Projection Algorithm
for Generation of Flequent ltemsets. Journal of Parallel and Distri,buted Computing
(Speci,alIssue on Hi,gh Performance Data Mining),61(3):350-371, 2001.
12241 R. C. Agarwal and J. C. Shafer. Parallel Mining of Association Rules. IEEE Transac-
t'ions on Knowledge and, Data Eng'ineering,8(6):962-969, March 1998.
12251C. C. Aggarwal, Z. Sun, and P. S. Yu. Online Generation of Profile Association Rules.
In Proc. of the lth IntI. Conf. on Knowled,ge D'iscouerg and, Data Mining, pages 129-
133, New York, NY, August 1996.
[226] C. C. Aggarwal and P. S. Yu. Mining Large Itemsets for Association Rules. Dafa
Engineering B ullet'in, 2l (l) :23-31, March 1998.
12271 C. C. Aggarwal and P. S. Yu. Mining Associations with the Collective Strength
Approach. IEEE Tfans. on Knowled,ge and Data Eng,ineer'ing,13(6):863-873, Jan-
uary/February 2001.
[228] R. Agrawal, T. Imielinski, and A. Swami. Database mining: A performance perspec-
tive. IEEE Transactions on Knowledge and Data Eng'ineering, S:9L4 925, 1993.
1229] R. Agrawal, T. Imielinski, and A. Swami. Mining association rules between sets of
items in large databases. In Proc. ACM SIGMOD IntI. Conf. Management of Data,
pages 207-216, Washington, DC, 1993.
f230] R. Agrawal and R. Srikant. Mining Sequential Patterns. ln Proc. of Intl. Conf. on
Data Engineering, pages 3-14, Taipei, Taiwan, 1995.
1231] K. Ali, S. Manganaris, and R. Srikant. Partial Classification using Association Rules.
In Proc. of the ?rd Intl. Conf. on Knowledge Discouery and, Data M'ining, pages 115
118, Newport Beach, CA, August 1997.
12321 D. Barbarii, J. Couto, S. Jajodia, and N. Wu. ADAM: A Testbed for Exploring the
Use of Data Mining in Intrusion Detection. SIGMOD Record,,30(4):15 24,2001.
[233] S. D. Bay and M. Pazzani. Detecting Group Differences: Mining Contrast Sets. Dota
Min'ing and Know ledge Dis couery, 5 (3) :2L3-246, 200I.
[234] R. Bayardo. Efficiently Mining Long Patterns from Databases. In Proc. of 1998 ACM-
SIGMOD Intl. Conf. on Management of Data, pages 85-93, Seattle, WA, June 1998.
[235] R. Bayardo and R. Agrawal. Mining the Most Interesting Rules. In Proc. of the Sth
Intl. Conf. on Knowledge Discouerg and Data Min'ing, pages 145-153, San Diego, CA,
August 1999.
[236] Y. Benjamini and Y. Hochberg. Controlling the False Discovery Rate: A Practical
and Powerful Approach to Multiple Testing. Journal Rogal Statistical Society 8,57
(1):289-300, 1995.
1237] R. J. Bolton, D. J. Hand, and N. M. Adams. Determining Hit Rate in Pattern Search.
In Proc. of the ESF Etploratory Workshop on Pattern Detect'i,on and Discouery in
Data Mini,ng, pages 36-48, London, UK, September 2002.
[238] S. Brin, R. Motwani, and C. Silverstein. Beyond market baskets: Generalizing associ-
ation rules to correlations. In Proc. ACM SIGMOD IntI. Conf. Management of Data,
pages265-276, Tucson, AZ, 1997.
[239] S. Brin, R. Motwani, J. Ullman, and S. Tsur. Dynamic Itemset Counting and Impli-
cation Rules for market basket data. In Proc. of 1997 ACM-SIGMOD IntI. Conf. on
Management of Data, pages 255 264, T\rcson, AZ, J:lrre L997.
1240] C. H. Cai, A. tr\r, C. H. Cheng, and W. W. Kwong. Mining Association Rules with
Weighted Items. In Proc. of IEEE Intl. Database Eng'ineering and Appli,cations Sgmp.,
pages 68-77, Cardiff, Wales, 1998.
398 Chapter 6 Association Analysis
[241] Q. Chen, U. Dayal, and M. Hsu. A Distributed OLAP infrastructure for E-Commerce.
In Proc. of the lth IFCIS IntI. Conf. on Cooperatiue Information Systems, pages 209-
220, Edinburgh, Scotland, 1999.
12421 D. C. Cheung, S. D. Lee, and B. Kao. A General Incremental Technique for Maintaining
Discovered Association Rules. In Proc. of the Sth IntI. Conf. on Database Systems for
Aduanced Appl'ications, pages 185-194, Melbourne, Australia, 1997.
[243] R. Cooley, P. N. Tan, and J. Srivastava. Discovery of Interesting Usage Patterns
from Web Data. In M. Spiliopoulou and B. Masand, editors, Aduances in Web Usage
AnalEsis and User ProfiIing, volume 1836, pages 163-182. Lecture Notes in Computer
Science, 2000.
12441P. Dokas, L.Ertoz, V. Kumar, A. Lazarevic, J. Srivastava, and P. N. Tan. Data Mining
for Network Intrusion Detection. In Proc. NSF Workshop on Nert Generation Data
M'ini,ng, Baltimore, MD, 2002.
1245] G. Dong and J. Li. Interestingness of discovered association rules in terms of
neighborhood-based unexpectedness. In Proc. of the 2nd, Paci,fi,c-Asia Conf. on Knowl-
ed,geDiscouery and Data Min'i,ng, pages 72-86, Melbourne, Australia, April 1998.
[246] G. Dong and J. Li. Efficient Mining of Emerging Patterns: Discovering Tbends and
Differences. In Proc. of the 5th Intl. Conf. on Knowledge Discouery and Data M'ining,
pages 43-52, San Diego, CA, August 1999.
12471 W. DuMouchel and D. Pregibon. Empirical Bayes Screening for Multi-Item Associa-
tions. In Proc. of the 7th IntI. Conf. on Knowledge D'iscouerg and, Data Mining, pages
67-76, San Flancisco, CA, August 2001.
[248] B. Dunkel and N. Soparkar. Data Organization and Access for Efficient Data Mining.
In Proc. of the 15th Intl. Conf. on Data Engineering, pages 522-529, Sydney, Australia,
March 1999.
12491 C. C. Fabris and A. A. Fleitas. Discovering surprising patterns by detecting occurrences
of Simpson's paradox. In Proc. of the 19th SGES Intl. Conf. on Knowledge-Based,
Systems and"Applied Artificial Intelligence), pages 1,48-160, Cambridge, UK, December
1999.
[250] L. Feng, H. J. Lu, J. X. Yu, and J. Han. Mining inter-transaction associations with
templates. In Proc, of the 8th IntI. Conf. on Inforrnation and Knowled,ge Managemept,
pages 225-233, Kansas City Missouri, Nov 1999.
[251] A. A. Freitas. Understanding the crucial differences between classification and discov-
ery of association rules a position paper. SIGKDD Erplorations,2(l):6549, 2000.
12521 J. H. Friedman and N. L Fisher. Bump hunting in high-dimensional data. Statisti.cs
aniL Computing, 9(2):123-143, April 1999.
[253] T. Fukuda, Y. Morimoto, S. Morishita, and T. Tokuyama. Mining Optimized Asso-
ciation Rules for Numeric Attributes. In Proc. of the 15th Symp. on Principles of
Database Systems, pages 182 191, Montreal, Canada, June 1996.
12541D. Gunopulos, R. Khardon, H. Mannila, and H. Toivonen. Data Mining, Hypergraph
TYansversals, and Machine Learning. In Proc. of the 16th Sgmp. on Princi,ples of
Database Sgstems, pages 209-216, T\rcson, AZ,May 1997.
[255] E.-H. Han, G. Karypis, and V. Kumar. Min-Apriori: An Algorithm for Finding As-
sociation Rules in Data with Continuous Attributes. http://www.cs.umn.edu/-han,
L997.
[256] E.-H. Han, G. Karypis, and V. Kumar. Scalable Parallel Data Mining for Association
Rules. In Proc. of 1997 ACM-SIGMOD IntI. Conf. on Management of Data, pages
277-288. T\rcson. AZ.Mav 1997.
Bibliography 399
1274] M. Kuramochi and G. Karypis. Frequent Subgraph Discovery. In Proc. of the 2001
IEEE Intl. Conf. on Data Mi,ning, pages 313-320, San Jose, CA, November 2001.
1275] W. Lee, S. J. Stolfo, and K. W. Mok. Adaptive Intrusion Detection: A Data Mining
Approach. Artificial Intelligence Reu'iew,14(6) :533-567, 2000.
1276] W. Li, J. Han, and J. Pei. CMAR: Accurate and Efficient Classification Based on
Multiple Class-association Rules. In Proc. of the 2001 IEEE IntI. Conf. on Data
M'ining, pages 369 376, San Jose, CA, 2001.
12771B. Liu, W. Hsu, and S. Chen. Using General Impressions to Analyze Discovered
Classification Rules. In Proc. of the Srd Intl. Conf. on Knowledge Discouery and Data
Mining, pages 31-36, Newport Beach, CA, August 1997.
12781B. Liu, W. Hsu, and Y. Ma. Integrating Classification and Association Rule Mining.
In Proc. of the lth IntI. Conf. on Knowledge D'iscouery and, Data M'ini,ng, pages 80-86,
New York, NY, August 1998.
1279] B. Liu, W. Hsu, and Y. Ma. Mining association rules with multiple minimum supports.
In Proc. of the Sth Intl. Conf. on Knowledge Discouerg and Data Mining, pages 125
134, San Diego, CA, August 1999.
1280] B. Liu, W. Hsu, and Y. Ma. Pruning and Summarizing the Discovered Associations. In
Proc. of theSthIntI. Conf. onKnowledgeDiscoueryandDataMining, pages125 134,
San Diego, CA, August 1999.
1281] A. Marcus, J. L Maletic, and K.-I. Lin. Ordinal association rules for error identifi-
cation in data sets. In Proc. of the 10th Intl. Conf. on Inforrnation and, Knowledge
Management, pages 589-591, Atlanta, GA, October 2001.
[282] N. Megiddo and R. Srikant. Discovering Predictive Association Rules. In Proc. of the
Ith Intl. Conf. on Knowled,ge Discouery and Data Min'ing, pages 274-278, New York,
August 1998.
[283] R. Meo, G. Psaila, and S. Ceri. A New SQL-like Operator for Mining Association
Rules. In Proc. of the 22nd VLDB Conf., pages I22 133, Bombay, India, 1-996.
[284j R. J. Miller and Y. Yang. Association Rules over Interval Data. In Proc. of 1997
ACM-SIGMOD Intl. Conf. on Management of Data, pages 452-461, T\rcson, LZ,May
1997.
[285] Y. Morimoto, T. Fukuda, H. Matsuzawa, T. Tokuyama, and K. Yoda. Algorithms for
mining association rules for binary segmentations of huge categorical databases. In
Proc. of the 2lth VLDB Conf., pages 380-391, New York, August 1998.
[286] F. Mosteller. Association and Estimation in Contingency Tables. Journal of the Amer-
ican Statistical Association 63:1-28. 1968,
12871 A. Mueller. Fast sequential and parallel algorithms for association rule mining: A
comparison. Technical Report CS-TR-3515, University of Maryland, August 1995.
[288] R. T. Ng, L. V. S. Lakshmanan, J. Han, and A. Pang. Exploratory Mining and Pruning
Optimizations of Constrained Association Rules. In Proc. of 1998 ACM-SIGMOD IntI.
Conf. on Management of Data, pages 13-24, Seattle, WA, June 1998.
1289] E. Omiecinski. Alternative Interest Measures for Mining Associations in Databases.
IEEE Ttans. on Knowledge and" Data Engineering, 15(1):57-69, January/February
2003.
[290] B. Ozden, S. Ramaswamy, and A. Silberschatz. Cyclic Association Rules. In Proc. of
the llth IntI. Conf. on Data Eng., pages 412 42I, Orlando, FL, February 1998.
[291] A. Ozgur, P. N. Tan, and V. Kumar. RBA: An Integrated Framework for Regression
based on Association Rules. In Proc. of the SIAM IntI. Conf. on Data M'ining, pages
2 M 2 7 , O r l a n d o ,F L , A p r i l 2 0 0 4 .
Bibliography 4OL
1292] J. S. Park, M.-S. Chen, and P. S. Yu. An efiective hash-based algorithm for mining
association rrles. SIGMOD Record,25(2):175 186, 1995.
[293] S. Parthasarathy and M. Coatney. Efficient Discovery of Common Substructures in
Macromolecules. In Proc. of the 2002 IEEE IntI. Conf. on Data M'ining, pages 362-369,
Maebashi City, Japan, December 2002.
[294] N. Pasquier, Y. Bastide, R. Taouil, and L. Lakhal. Discovering frequent closed itemsets
for association rules. In Proc. of the 7th Intl. Conf. on Database Theory 0CDT'99),
pages 398 416, Jerusalem, Israel, January 1999.
[295] J. Pei, J. Han, H. J. Lu, S. Nishio, and S. Tang. H-Mine: Hyper-Structure Mining of
Frequent Patterns in Large Databases. In Proc. of the 2001 IEEE Intl. Conf. on Data
M'ining, pages 441-448, San Jose, CA, November 2001.
[296] J. Pei, J. Han, B. Mortazavi-Asl, and H. Zhtt. Mining Access Patterns Efficiently from
Web Logs. In Proc. of the lth Pacific-Asia Conf. on Knowledge Discouery and" Data
Mining, pages 396-407, Kyoto, Japan, April 2000.
1297] G. Piatetsky-Shapiro. Discovery, Analysis and Presentation of Strong Rules. In
G. Piatetsky-Shapiro and W. Frawley, editors, Knowledge Discouery in Databases,
pages 229-248. MIT Press, Cambridge, MA, 1991.
[298] C. Potter, S. Klooster, M. Steinbach, P. N. Tan, V. Kumar, S. Shekhar, and C. Car-
valho. Understanding Global Teleconnections of Climate to Regional Model Estimates
of Amazon Ecosystem Carbon Fluxes. Global Change Biology, 70(5):693-703, 20A4.
[299] C. Potter, S. Klooster, M. Steinbach, P. N. Tan, V. Kumar, S. Shekhar, R. Myneni,
and R. Nemani. Global Teleconnections of Ocean Climate to Terrestrial Carbon Flux.
J. Geophysical Research, 108(D17), 2003.
1300] G. D. Ramkumar, S. Ranka, and S. Tsur. Weighted Association Rules: Model and
Algorithm. http: //www.cs.ucla.edu/ "c zdemof tsw f , 1997.
13o1lS . Sarawagi, S. Thomas, and R. Agrawal. Integrating Mining with Relational Database
Systems: Alternatives and Implications. In Proc. of 1998 ACM-SIGMOD IntI. Conf.
on Management of Data, pages 343-354, Seattle, WA, 1998.
[302] K. Satou, G. Shibayama, T, Ono, Y. Yamamura, E. Furuichi, S. Kuhara, and T. Takagi.
Finding Association Rules on Heterogeneous Genome Data. In Proc. of the Pacific
Symp. on Biocomputing, pages 397-408, Hawaii, January 1997.
[303] A. Savasere, E. Omiecinski, and S. Navathe. An efficient algorithm for mining associ-
ation rules in large databases. In Proc. of the 21st Int. Conf. on Very Large Databases
(VLDB'gs), pages 432-444, Z:uicln, Switzerland, September 1995.
1304] A. Savasere, E. Omiecinski, and S. Navathe. Mining for Strong Negative Associations
in a Large Database of Customer Tbansactions. In Proc. of the llth Intl. Conf. on
Data Engineering, pages 494 502, Orlando, Florida, February 1998.
[305] M. Seno and G. Karypis. LPMiner: An Algorithm for Finding FYequent Itemsets Using
Length-Decreasing Support Constraint. In Proc. of the 2001 IEEE Intl. Conf. on Data
Min'ing, pages 505-512, San Jose, CA, November 2001.
[306] T. Shintani and M. Kitsuregawa. Hash based parallel algorithms for mining association
rules. In Proc of the lth IntI. Conf . on Parallel and, Di;stributed, Info. Sgstems, pages
19-30, Miami Beach, FL, December 1996.
[307] A. Silberschatz and A. Tirzhilin. What makes patterns interesting in knowledge discov-
ery systems. IEEE Trans. on Knowledge and Data Engineering,8(6):970-974, 1996.
[308] C. Silverstein, S. Brin, and R. Motwani. Beyond market baskets: Generalizing associ-
ation rules to dependence rules. Data Mining and Knowledge D'iscouery, 2(1):39-68,
1998.
4O2 Chapter 6 Association Analysis
[325] K. Wang, S. H. Tay, and B. Liu. Interestingness-Based Interval Merger for Numeric
Association Rules. In Proc. of the lth IntL Conf. on Knowledge Discouerg and Data
Min'ing, pages 121-128, New York, NY, August 1998.
[326] G. I. Webb. Preliminary investigations into statistically valid exploratory rule dis-
covery. In Proc. of the Australasian Data Mi,ni,ng Workshop (AusDM1?), Canberra,
Australia, December 2003.
[327] H. Xiong, X. He, C. Ding, Y.Zhang, V. Kumar, and S. R. Holbrook. Identification
of Functional Modules in Protein Complexes via Hyperclique Pattern Discovery. In
Proc. of the Pacif,c Sgmposium on Biocomputing, (PSB 2005),Mad, January 2005.
13281H. Xiong, S. Shekhar, P. N. Tan, and V. Kumar. Exploiting a Support-based Upper
Bound of Pearson's Correlation Coefficient for Efficiently Identifying Strongly Corre-
lated Pairs. In Proc. of the 10th IntI. Conf. on Knowled,ge Di,scouery and Data Mining,
pages 334 343, Seattle, WA, August 2004.
[329] H. Xiong, M. Steinbach, P. N. Tan, and V. Kumar. HICAP: Hierarchial Clustering
with Pattern Preservation. In Proc. of the SIAM Intl. Conf. on Data Mining, pages
279 290, Orlando, FL, April 2004.
[330] H. Xiong, P. N. Tan, and V. Kumar. Mining Strong Affinity Association Patterns in
Data Sets with Skewed Support Distribution. In Proc. of the 2003 IEEE IntI. Conf.
on Data M'in'ing, pages 387 394, Melbourne, FL,2OO3.
[331] X. Yan and J. Han. gSpan: Graph-based Substructure Pattern Mining. ln Proc. of
the 2002 IEEE Intl. Conf. on Data Mining, pages 72I 724, Maebashi City, Japan,
December 2002.
1332] C. Yang, U. M. Fayyad, and P. S. Bradley. Efficient discovery of error-tolerant frequent
itemsets in high dimensions. In Proc. of the 7th Intl. Conf. on Knowled,ge Discouery
and, Data M'in'ing, pages 194 203, San Francisco, CA, August 2001.
f333] M. J. Zaki. Parallel and Distributed Association Mining: A Survey. IEEE Concurrency,
special issue on Parallel Mechanisrns for Data Min'ing,7(4):14-25, December 1999.
[334] M. J. Zaki. Generating Non-Redundant Association Rules. In Proc. of the 6th IntI.
Conf. on Knowledge Discouery and Data Min'ing, pages 34-43, Boston, MA, August
2000.
[335] M. J. Zaki. Efficiently mining frequent trees in a forest. In Proc. of the 8th IntI.
Conf. on Knowledge Di,scouery and Data Mining, pages 71-80, Edmonton, Canada,
July 2002.
f336] M. J. Zaki and M. Orihara. Theoretical foundations of association rules. In Proc. of
the 1998 ACM SIGMOD Workshop on Research Issues in Data Mining and, Knowledge
Discouery, Seattle, WA, June 1998.
[337] M. J. Zaki, S. Parthasarathy, M. Ogihara, and W. Li. New Algorithms for Fast
Discovery of Association Rules. In Proc. of the Srd Intl. Conf . on Knowled,ge Discouery
and"Data Mining, pages 283-286, Newport Beach, CA, August 1997.
[338] H. Zhang, B. Padmanabhan, and A. T\rzhilin. On the Discovery of Significant Statis-
tical Quantitative Rules. In Proc. of the 10th IntL Conf. on Knowled,ge D'iscouery and
Data Mi.ning, pages 374-383, Seattle, WA, August 2004.
13391 Z. Zhang, Y. Lu, and B. Zhang. An Effective Partioning-Combining Algorithm for
Discovering Quantitative Association Rules. In Proc. of the 1st Paci,fic-Asia Conf. on
Knowled"geDiscouery and, Data Mi,ning, Singapore, 1997.
[340] N. Zhong, Y. Y. Yao, and S. Ohsuga. Peculiarity Oriented Multi-database Mining. In
Proc. of the ?rd European Conf. of Principles and Practice of Knowledge Discouery in
Databases,pages 136-146, Prague, Czech Republic, 1999.
4O4 Chapter 6 Association Analysis
6.10 Exercises
1. For each of the following questions, provide an example of an association rule
from the market basket domain that satisfies the following conditions. Also,
describe whether such rules are subjectively interesting.
6.22.Example
Table ofmarket transactions.
basket
CustomerID Tlansaction ID Items ljouqht
I {a,d,e}
1 0024 {a,b,c,e}
2 0012 {a,b,d,e}
2 0031 {a, c, d, e}
3 0015 {b,c,e}
3 0022 {b,d,e}
4 0029 {",d}
4 0040 {a,b,c}
5 0033 {a, d,e}
tr
0038 { a , b ,e }
(a) Compute the support for itemsets {e}, {b,d}, and {b,d,e} by treating
each transaction ID as a market basket.
(b) Use the results in part (a) to compute the confidence for the associa-
tion rules {b,d} ---, {e} and {"} ------+
{b,d}. Is confidence a symmetric
measure?
(") Repeat part (a) by treating each customer ID as a market basket. Each
item should be treated as a binary variable (1 if an item appears in at
Ieast one transaction bought by the customer, and 0 otherwise.)
(d) Use the results in part (c) to compute the confidence for the association
rules {b, d} - {e} and {"}------ {b,d,}.
( e ) Suppose s1 and c1 are the support and confidence values ofan association
rule r when treating each transd,ction ID as a market basket. Also, let s2
and c2 be the support and confidence values of r when treating each cus-
tomer ID as a market basket. Discuss whether there are any relationships
between sr and s2 or c1 and,c2.
6.10 Exercises 4O5
3. (a) What is the confidence for the rules A ------A and A ---- A?
(b) Let crt c2t and ca be the confidence values of the rules {p} ------+ {q},
{p} - {q,r}, and {p, r} - {g}, respectively. If we assume that c1, c2,
and ca have different values, what are the possible relationships that may
exist among cI, c2, and ca? Which rule has the lowest confidence?
(c) Repeat the analysis in part (b) assuming that the rules have identical
support. Which rule has the highest confidence?
(d) Tiansitivity: Suppose the confidence of the rules A - B and B -------,
C
are larger than some threshold, m'inconf . Is it possible that A -----*C has
a confidence less than mi,nconf?
(a) A characteristic rule is a rule of the form {p) - {qt,qr,. . . , g,}, where
the rule antecedent contains only a single item. An itemset of size k can
produce up to k characteristic rules. Let ( be the minimum confidence of
all characteristic rules generated from a given itemset:
C ( { p r , p z ,.. . , p k } ) m i n I c ( { p 1 }- { p z , p s , .. . , p k } ) , - - -
'({Pn} ' {Pr'Ps" ' 'Pl"-1}) ]
5. Prove Equation 6.3. (Hint: First, count the number of ways to create an itemset
that forms the left hand side of the rule. Next, for each size k itemset selected
for the left-hand side, count the number of ways to choosethe remainin1d-k
items to form the right-hand side of the rule.)
4OG Chapter 6 Association Analysis
6.23.Market
Table basket
transactions,
Tlansaction ID Items Boueht
1 tMilk, Beer, Diapers]
2 {Bread, Butter, Milk}
3 {Milk, Diapers, Cookies}
4 {Bread, Butter, Cookies}
{Beer, Cookies, Diapers}
o {Milk, Diapers, Bread, Butter}
7 {Bread, Butter, Diapers}
8 {Beer, Diapers}
9 {Milk, Diapers, Bread, Butter}
10 {Beer, Cookies}
(a) What is the maximum number of association rules that can be extracted
from this data (including rules that have zero support)?
(b) What is the maximum size of frequent itemsets that can be extracted
(assuming minsup > 0)?
(c) Write an expression for the maximum number of size-3 itemsets that can
be derived from this data set.
(d) Find an itemset (of size 2 or larger) that has the largest support.
(e) Find a pair of items, a and b, such that the rules {o} -, {b} and {b} -----+
{a} have the same confidence.
{ 1 , 2 , 3 } , { 1 , 2 , 4 ) , { r , 2 , 5 } , { r , 3 , 4 } , { 1 ,3 , 5 } , { 2 , 3 , 4 } , { 2 , 3 , 5 } , { 3 , 4 , 5 } .
Assume that there are only five items in the data set.
Table6.24.Example
of market
basket
transactions.
Tlansaction ID Items Bought
1 { a , b ,d , e }
2 {b,c,d}
3 {a,b,d,e}
4 {a, c, d, e}
r
J
{b, c, d, e}
0 {b,d,e}
7 {", d}
8 { a , b ,c }
I {a, d,e}
10 {b, d}
data set shown in Table 6.24 with m'insup : 30yo, i.e., any itemset occurring
in less than 3 transactions is considered to be infrequent.
(a) Draw an itemset lattice representing the data set given in Table 6.24.
Label each node in the Iattice with the following letter(s):
o N: If the itemset is not considered to be a candidate itemset by
the Apriori. algorithm. The-re are two reasons for an itemset not to
be considered as a candidate itemset: (1) it is not generated at all
during the candidate generation step, or (2) it is generated during
the candidate generation step but is subsequently removed during
the candidate pruning step becauseone of its subsets is found to be
infrequent.
o F: If the candidate itemset is found to be frequent by the Apri'ori
algorithm.
o I: If the candidate itemset is found to be infrequent after support
counting.
(b) What is the percentage of frequent itemsets (with respect to all itemsets
in the lattice)?
(c) What is the pruning ratio of the Apri,ori algorithm on this data set?
(Pruning ratio is defined as the percentage of itemsets not considered
to be a candidate because (1) they are not generated during candidate
generation or (2) they are pruned during the candidate pruning step.)
(d) What is the false alarm rate (i.e, percentage of candidate itemsets that
are found to be infrequent after performing support counting)?
9. The Apriori algorithm uses a hash tree data structure to effrciently count the
support of candidate itemsets. Consider the hash tree for candidate 3-itemsets
shown in Figure 6.32.
408 Chapter 6 Association Analysis
Figure6,32,Anexample
ofa hashtreestructure.
(a) Given a transaction that contains items {1,3,4,5,8}, which of the hash
tree leaf nodes will be visited when fi.nding the candidates of the transac-
tion?
(b) Use the visited leaf nodes in part (b) to determine the candidate itemsets
that are contained in the transaction {1,3,4,5,8}.
{ t , 2 , 3 } , { r , 2 , 6 } , { 1 , 3 , 4 } ,{ 2 , 3 , 4 ) ,{ 2 , 4 , 5 } ,{ 3 , 4 , 6 } ,{ 4 , 5 , 6 }
(a) Construct a hash tree for the above candidate 3-itemsets. Assume the
tree uses a hash function where all odd-numbered items are hashed to
the left child of a node, while the even-numbered items are hashed to the
right child. A candidate k-itemset is inserted into the tree by hashing on
each successiveitem in the candidate and then following the appropriate
branch of the tree according to the hash value. Once a leaf node is reached,
the candidate is inserted based on one of the following conditions:
Condition 1: If the depth of the leaf node is equal to k (the root is
assumed to be at depth 0), then the candidate is inserted regardless
of the number of itemsets already stored at the node.
Condition 2: If the depth of the leaf node is less than k, then the candi-
date can be inserted as long as the number of itemsets stored at the
node is less than mars'ize. Assume mars'ize:2 for this question.
Condition 3: If the depth of the leaf node is less than k and the number
of itemsets stored at the node is equal to mars'ize, then the leaf
node is converted into an internal node. New leaf nodes are created
as children of the old leaf node. Candidate itemsets previouslv stored
6.10 Exercises 4Og
Figure
6.33.Anitemset
lattice
in the old leaf node are distributed to the children based on their hash
values. The new candidate is also hashed to its appropriate leafnode.
(b) How many leaf nodes are there in the candidate hash tree? How many
internal nodes are there?
(c) Consider a transaction that contains the following items: {1,2,3,5,6}.
Using the hash tree constructed in part (a), which leaf nodes will be
checked against the transaction? What are the candidate 3-itemsets con-
tained in the transaction?
11. Given the lattice structure shown in Figure 6.33 and the transactions given in
Table 6.24,label each node with the following letter(s):
12. The original association rule mining formulation uses the support and confi-
dence measures to prune uninteresting rules.
ALO Chapter 6 Association Analysis
(a) Draw a contingency table for each of the following rules using the trans-
actions shown in Table 6.25.
Table6,25.Example
ofmarket transactions.
basket
Tlansaction ID Items Bought
I { a , b ,d , e }
2 {b,c,d}
3 { a , b ,d , e }
4 {a, c, d, e}
E
{b,c,d,e}
6 {b,d,e}
7 {",d}
8 {a,b,c}
I {a,d,e}
10 {b,d}
Rules: {b} * {"}, {r} - {d,}, {b} - {d}, {"} - {"}, {c}------ ia}.
(b) Use the contingency tables in part (a) to compute and rank the rules in
decreasing order according to the following measures.
i. Support.
ii. Confidence.
iii. Interest(X----+Y): t##PV).
iv. IS(X ------Y) --
X ------+
v. Klosgen( Y) : \IF@fi x (P(Y lX) - P (Y)), whereP(Y lX) :
P(X\
Y)t -:1+++EF).
vi. Oddsratio(X------ e6.Y1e1X.v1'
13. Given the rankings you had obtained in Exercise 12, compute the correlation
between the rankings of confidence and the other five measures. Which measure
is most highly correlated with confidence? Which measure is least correlated
with confidence?
14. Answer the following questions using the data sets shown in Figure 6.34. Note
that each data set contains 1000 items and 10,000 transactions. Dark cells
indicate the presence of items and white cells indicate the absence of items. We
will apply l}ae Apriori, algorithm to extract frequent itemsets with m'insup :
I0% (i.e., itemsets must be contained in at least 1000 transactions)?
(a) Which data set(s) will produce the most number of frequent itemsets?
6.L0 Exercises 4LL
(b) Which data set(s) will produce the fewest number of frequent itemsets?
(c) Which data set(s) will produce the longest frequent itemset?
(d) Which data set(s) will produce frequent itemsets with highest maximum
support?
(e) Which data set(s) will produce frequent itemsets containing items with
wide-va,rying support levels (i.e., items with mixed support, ranging from
less than 20% to more than 70%).
15. (u) Prove that the / coefficientis equal to 1 if and only if fn : fr+ : f +r.
(b) Showthat if A andB areindependent, thenP(A, B)xP(A, B) : P(A, B)x
P(A, B).
(") Showthat Yule's Q and Y coefficients
-
n
\4 : f/rrloo /ro/otl
L/,r/00T /./rl
r, lrfitrf*- tfit;I'1
t'ff 'J* + 'If.of")
are normalized versions of the odds ratio.
(d) Write a simplified expression for the value of each measure shown in Tables
6.11 and 6.12 when the variables are statistically independent.
(a) What is the range of this measure? When does the measure attain its
maximum and minimum values?
(b) How does M behave when P(,4, B) is increased while P(,a) and P(B)
remain unchanged?
(c) How does M behave when P(A) is increased while P(,4, B) and P(B)
remain unchanged?
(d) How does M behave when P(B) is increased while P(A, B) and P(A)
remain unchanged?
(e) Is the measure symmetric under variable permutation?
(f) What is the value of the measure when A and B are statistically indepen-
dent?
(g) Is the measure null-invariant?
(h) Does the measure remain inva.riant under row or column scaling opera-
tions?
(i) How does the measure behave under the inversion operation?
412 Chapter 6 Association Analysis
Items
I
rr
2000 2000
o
-t I
4000 () 4000
(U T
o
6000 $u I
6000
F
8000
l. It
I
8000
Items
l-
I
I
2000 2000
I
o o
4000 - I 4000
I
o
qt I
U'
6000 rr 6000
F
C'
lI r - tr
I rl
I. 8000 8000
-
II
Items Items
2000 2000
o o
4000 o 1 0 %a r e 1 s 4000
o o
(U (U 90% are 0s
at, at,
(I' 6000 (U
(uniformlydistributed) 6000
F F
8000 8000
Figute
6.34.Figures
forExercise
14.
6.10 Exercises 4Lg
t7. Suppose we have market basket data consisting of 100 transactions and 20
items. If the support for item ais25To, the support for item bis90% and the
support for itemset {a, b} is 20%. Let the support and confidence thresholds
be L0% and 60%, respectively.
(a) Compute the confidence of the association rule {o} * {b}. Is the rule
interesting according to the confidence measure?
(b) Compute the interest measure for the association pattern {4, b}. Describe
the nature of the relationship between item a and item b in terms of the
interest measure.
(c) What conclusions can you draw from the results of parts (a) and (b)?
(d) Prove that if the confidence of the rule {o} * {b} is less than the support
of {b}, then:
i. c({a}------'
{bi) > c({di------{bi),
ii. c({a} ---' {b}) > .s({b}),
where c(.) denote the rule confidence and s(') denote the support of an
itemset.
18. Table 6.26 shows a 2 x 2 x 2 contingency table for the binary variables A and
B at different values of the control variable C.
Table.
Table6.26.A Contingency
A
1 0
1 0 15
C=0 B 0 15 30
1 5 0
C=1 B
0 0 15
(a) For table I, compute support, the interest measure, and the / correla-
tion coeffi.cient for the association pattern {A, B}. Also, compute the
confidence of rules A -- B and B --- A.
4L4 Chapter 6 AssociationAnalysis
Table6.27.Contingency 19,
forExercise
tables
A A
A A
(b) For table II, compute support, the interest measure, and the @ correla-
tion coefficient for the association pattern {A, B}. Also, compute the
confidence of rules A ---, B and,B - A.
(c) What conclusions can you draw from the results of (a) and (b)?
20. Consider the relationship between customers who buy high-definition televisions
and exercise machines as shown in Tables 6.19 and 6.20.
For each of the measures given above, describe how the direction of association
changes when data is pooled together instead of being stratified.
AssociationAnalysis:
AdvancedConcepts
The association rule mining formulation described in the previous chapter
assumes that the input data consists of binary attributes called items. The
presenceof an item in a transaction is also assumed to be more important than
its absence. As a result, an item is treated as an asymmetric binary attribute
and only frequent patterns are considered interesting.
This chapter extends the formulation to data sets with symmetric binary,
categorical, and continuous attributes. The formulation will also be extended
to incorporate more complex entities such as sequencesand graphs. Although
the overall structure of association analysis algorithms remains unchanged, cer-
tain aspects of the algorithms must be modified to handle the non-traditional
entities.
This rule suggests that most Internet users who shop online are concerned
about their personal privacy.
4LG Chapter 7 Association Analysis: Advanced Concepts
Table7.1.Internet
survey
datawithcategorical
attributes.
Gender Level o t State Computer Uhat Shop Privacy
Education at l{ome Online Online Concerns
Female Graduate Illinois Yes Yes Yes Yes
Male College California No No No No
Male Graduate Michigan Yes Yes Yes Yes
Female College Virginia No No Yes Yes
Female Graduate California Yes No No Yes
Male College Minnesota Yes Yes Yes Yes
Male College Alaska Yes Yes Yes No
Male High School Oregon Yes No No No
Female *: No
Graduate Texas
l:: ):
Table7.2.Internet
survey
dataafterbinarizing
categorical
andsymmetric
binary
attributes.
Male Female Education Education Privacy Privacy
: Graduate : College : Yes :NO
0 t 1 0 I 0
I 0 0 1 0 1
I 0 I 0 1 0
0 I 0 1
I I 0
0 1 L 0 1 0
I 0 0 I 1 0
1 0 0 I 0 1
1 0 0 0 0 1
0 1 0 0 I
i
7.L HandlingCategoricalAttributes 41,7
NewYork
Michigan
California
Minnesota
Massachusetts
Table7.3. Internet
survey attributes.
datawithcontinuous
Gender Age Annual No. of Hours Spent No. of Email Privacy
Income Online per Week Accounts Concern
Female 26 90K 20 4 Yes
Male 51 135K 10 2 No
Male 29 80K 10 3 Yes
Female 45 120K 15 3 Yes
Female 31 95K 20 D Yes
Male 25 55K 25 D Yes
Male 37 100K 10 I No
2 No
Male
t"i1"
47
26 *1
65K 8
12 I
I:
following intervals:
A g e € [ 1 2 , 1 6 ) ,A g e € [ 1 6 , 2 0 ) ,A g e e 1 2 0 , 2 4 ) , . . . , A g e€ [ 5 6 , 6 0 ) ,
Table7.4. Internet
survey
dataafterbinarizing andcontinuous
categorical attributes.
Male Female Age Age Age Privacy Privacy
< 1 3 € [13,21) € [21,30) : Yes :NO
0 1 0 0 1 I U
1 0 0 0 0 0 I
1 0 0 0 1 I 0
0 1 0 0 0 1 0
0 I U 0 0 1 0
1 0 0 0 I 1 0
1 0 0 0 0 0 1
1 0 0 0 0 0 I
0 I I
: i : :
42O Chapter 7 AssociationAnalysis: AdvancedConcepts
These rules suggest that most of the users from the age group of 16-24 often
participate in online chatting, while those from the age group of. 44-60 are less
likely to chat online. In this example, we consider a rule to be interesting only
if its support (s) exceeds5% and its confidence (c) exceeds65%. One of the
problems encountered when discretizing the Age attribute is how to determine
the interval width.
1. If the interval is too wide, then we may lose some patterns because of
their lack of confidence. For example, when the interval width is 24
years, .Rr and R2 arc replaced by the following rules:
R ' r , A g e € [ 1 2 , 3 6 )- - + C h a t O n l i n e : Y e s ( s : 3 0 % , c : 5 7 . 7 V o ) .
RL, Age € [36,60) ---+ Chat Online : No (s : 28y0,c: 58.3Vo).
7.2 Handling Continuous Attributes 42I
Despite their higher supports, the wider intervals have caused the con-
fidence for both rules to drop below the minimum confidence threshold.
As a result, both patterns are lost after discretization.
If the interval is too narrow, then we may lose some patterns because of
their lack of support. For example, if the interval width is 4 years, then
.Rr is broken up into the following two subrules:
Since the supports for the subrules are less than the minimum support
threshold, -R1is lost after discretization. Similarly, the rule -Bz, which
is broken up into four subrules, will also be lost because the support of
each subrule is less than the minimum support threshold.
3 . If the interval width is 8 years, then the rule R2 is broken up into the
following two subrules:
Rt?,Age € 144,52)------+
Chat Online : No (s:8.4To,c:70To).
Rf), Age € [52,60) ------+ :
Chat Online No (s:8.4To,c:70T0).
Since El!) and ,t?l| have sufficient support and confidence,R2 can be
recoveredby aggregatingboth subrules. Meanwhile, E1 is broken up
into the following two subrules:
{Amual Incone > $100K, Shop Online = Yes} ----+Age: Mear : 38.
The rule states that the average age of Internet users whose annual income
exceeds $100K and who shop online regularly is 38 years old.
Rule Generation
Rule Validation
l-t'- t-t- L
^2 ^2
(7.1)
rlt n2
that support A, and s2 is the standard deviation for t among transactions that
do not support A. Under the null hypothesis, Z has a standard normal distri-
bution with mean 0 and variance 1. The value of Z comptfted using Equation
7.1 is then compared against a critical value, Zo, which is a threshold that
depends on the desired confidence level. If / ) Za, then the null hypothesis
is rejected and we may conclude that the quantitative association rule is in-
teresting. Otherwise, there is not enough evidence in the data to show that
the difference in mean is statistically significant.
Example 7.1-. Consider the quantitative association rule
------
Age:F:38.
{Income > 100K, Shop Online:Yes}
Supposethere are 50 Internet users who supported the rule antecedent. The
standard deviation of their agesis 3.5. On the other hand, the averageage of
the 200 users who do not support the rule antecedent is 30 and their standard
deviation is 6.5. Assume that a quantitative association rule is considered
interesting only if the difference between p and ;.1/is more than 5 years. Using
Equation 7.1 we obtain
38-30-5
:4.4414.
For a one-sided hypothesis test at a g5% confidence level, the critical value
for rejecting the null hypothesis is 1.64. Since Z > 1.64, the null hypothesis
can be rejected. We therefore conclude that the quantitative association rule
is interesting because the difference between the average ages of users who
support and do not support the rule antecedent is more than 5 years. t
important reason is to ensure that the data is on the same scale so that sets
of words that vary in the same way have similar support values.
In text mining, analysts are more interested in finding associations between
words (e.g., data and nining) instead of associationsbetween ranges of word
frequencies(e.g., data € [1,4] and mining € [2,3]). One way to do this is
to transform the data into a 0/1 matrix, where the entry is 1 if the normal-
ized frequency count exceeds some threshold t, and 0 otherwise. While this
approach allows analysts to apply existing frequent itemset generation algo-
rithms to the binarized data set, finding the right threshold for binarization
can be quite tricky. If the threshold is set too high, it is possible to miss some
interesting associations. Conversely,if the threshold is set too low, there is a
potential for generating a large number of spurious associations.
This section presents another methodology for finding word associations
known as min-Apri,ora. Analogous to traditional association analysis, an item-
set is considered to be a collection of words, while its support measuresthe
degree of association among the words. The support of an itemset can be
computed based on the normalized frequency of its corresponding words. For
example, consider the document d1 shown in Table 7.6. The normalized fre-
quencies for uordl and word2 in this document are 0.3 and 0.6, respectively.
One might think that a reasonableapproach to compute the association be-
tween both words is to take the average value of their normalized frequencies,
i.e., (0.3+0.6)12:0.45. The support of an itemset can then be computed by
summing up the averaged normalized frequencies across all the documents:
q=!f *gry
s({word,1,word,2}): *y# *W#:t.
This result is by no means an accident. Because every word frequency is
normalized to 1, averaging the normalized frequencies makes the support for
every itemset equal to 1. All itemsets are therefore frequent using this ap-
proach, making it uselessfor identifying interesting patterns.
426 Chapter 7 Association Analysis: Advanced Concepts
The support measure defined in min-Apriori has the following desired prop-
erties, which makes it suitable for finding word associationsin documents:
Food Electronics
??"ff:
"olSto,
Figure7.2. Example
of anitemtaxonomy.
nilk is the parent of skin milk because there is a directed edge from the
node milk to the node skim milk. * is called an ancestor of X (and X a
descendent of *) if there is a path from node * to node X in the directed
acyclic graph. In the diagram shown in Figure 7.2, f ood is an ancestor of skim
rnil-k and AC adaptor is a descendentof electronics.
The main advantages of incorporating concept hierarchies into association
analysis are as follows:
1. Items at the lower levels of a hierarchy may not have enough support to
appear in any frequent itemsets. For example, although the sale of AC
adaptors and docking stations may be low, the sale of laptop accessories,
which is their parent node in the concept hierarchy, may be high. Unless
the concept hierarchy is used, there is a potential to miss interesting
patterns involving the laptop accessories.
Timeline
l rbt tlt bt l z r ' a r ' S s b
rttl
Sequencefor ttlltl
ObjectA: tttrrtl
rt,rtl
? i 61i i i
3i1irl
Sequencefor
ObjectB:
Sequencefor
ObjectC:
1
7
8
Figure
7.3.Example
ofa sequence
database,
for object A. By sorting all the events associated with object A in increasing
order of their timestamps, a sequence for object A is obtained, as shown on
the right-hand side of Figure 7.3.
Generally speaking, a sequenceis an ordered list of elements. A sequence
can be denoted as s : (ep2es . . .en),, where each element e3 is a collection of
one or more events,i.e., ej : {h,'i2, . . . ,26}. The following is a list of examples
of sequences:
Subsequences
OrdinalAttribute
Figure7.4. Examples
of elements
andeventsin sequence
datasets,
pafterns
Figure7.5. Sequential derived fivedatasequences.
froma datasetthatcontains
distinct sequences.
7.4 Sequential Patterns 433
l-sequences:1ir ), f i2 ), . . ., 1 xn )
2-sequences:< {h,iz} >, < {rir,ze}), . . ., 1 {in_t,'in} },
< {zr}{ir} >, < {it}{iz} ),..., < {i-_t}{i-} >
3-sequences:I {i1,'i2,is}>, < {ir,,iz,iq}}, ..., 1 {,h,iz}{ir} ), ...,
< { i t } { z r ,i z } > , . . . , < { z t } { i r } { r t } > , . . . , < { i " } { i . } { i ^ } >
1. An item can appear at most once in an itemset, but an event can appear
more than once in a sequence.Given a pair of items, ir and i2, only one
candidate 2-itemset, {h,iz}, can be generated. On the other hand, there
are many candidate 2-sequences, such as ( {i1,iz} >, < {it}{iz} >,
< {iz}{it} ), and 1{h,it} >, that can be generated.
2. Order matters in sequences,but not for itemsets. For example, {1, 2} and
{2,1} refersto the sameitemset,whereas< {it}{iz} ) and < {iz}{i} >
correspond to different sequences,and thus must be generated separately.
The Apriori principle holds for sequential data becauseany data sequence
that contains a particular k-sequencemust also contain all of its (k - 1)-
subsequences.An Apri,ori,-Iike algorithm can be developed to extract sequen-
tial patterns from a sequencedata set. The basic structure of the algorithm
is shown in Algorithm 7.1.
Notice that the structure of the algorithm is almost identical to Algorithm
6.1 presented in the previous chapter. The algorithm would iteratively gen-
erate new candidate k-sequences,prune candidates whose (k - l)-sequences
are infrequent, and then count the supports of the remaining candidates to
identify the sequential patterns. The detailed aspects of these steps are given
next.
for sequences.The criteria for merging sequencesare stated in the form of the
following procedure.
A sequence s(1) is merged with another sequence s(2) only if the subsequence
obtained by dropping the first event in s(1) is identical to the subsequence
obtained by dropping the last event in s(2). The resulting candidate is the
sequence5(1), concatenated with the last event from s(2). The last event from
s(2) can either be merged into the same element as the last event in s(1) or
different elements depending on the following conditions:
1. If the last two events in s(2) belong to the same element, then the last event
in s(2) is part of the last element in s(1) in the merged sequence.
2. If.the last two events in s(2) belong to different elements, then the last event
in s(2) becomes a separate element appended to the end of s(1) in the
merged sequence.
Frequent
3-sequences
Figure7,6, Example
of thecandidate andpruning
generation pattern
stepsof a sequential mining
algorithm.
since events 3 and 4 belong to the same element of the second sequence,they
are combined into the same element in the merged sequence.Finally, the se-
quences({1}{2}{3}) and ({t}{2,5}) do not have to be mergedbecauseremov-
ing the fi.rst event from the first sequencedoes not give the same subsequence
as removing the last event from the secondsequence.Although ({1}{2,5}t3})
is a viable candidate, it is generated by merging a different pair of sequences,
({1}{2,5}) and ({2,5}{3}). This example shows that the sequencemerging
procedure is complete; i.e., it will not miss any viable candidate, while at the
same time, it avoids generating duplicate candidate sequences.
u(s;*r)-l(s;)<= maxgap
l(s;+r)-u(b;)>mingap windowsize
WS
e
Sequence:
Figure7.7.Timing
constraints pattern.
of a sequential
The marspan constraint specifies the maximum allowed time difference be-
tween the latest and the earliest occurrencesof events in the entire sequence.
For example, suppose the following data sequences contain events that oc-
cur at consecutive time stamps (1, 2, 3, . ..). Assuming that marspan : 3,
the following table contains sequential patterns that are supported and not
supported by a given data sequence.
In general, the longer the marspan, the more likely it is to detect a pattern
in a data sequence.However, a longer marspan can also capture spurious pat-
terns becauseit increasesthe chancefor two unrelated events to be temporally
related. In addition, the pattern may involve events that are already obsolete.
The marspan constraint affects the support counting step of sequential
pattern discovery algorithms. As shown in the preceding examples,some data
sequencesno longer support a candidate pattern when the marspan constraint
is imposed. If we simply apply Algorithm 7.7., the support counts for some
patterns may be overestimated. To avoid this problem, the algorithm must be
modified to ignore cases where the interval between the first and last occur-
rences of events in a given pattern is greater t'han marspan.
Timing constraints can also be specified to restrict the time difference be-
tween two consecutive elements of a sequence. If the maximum time difference
(margap) is one week, then events in one element must occur within a week's
time of the events occurring in the previous element. If the minimum time dif-
ference (mi,ngap) is zero, then events in one element must occur immediately
after the events occurring in the previous element. The following table shows
examples of patterns that pass or fail the margap and mingap constraints,
assuming that margap: 3 and mi,ngap: t.
As with marspan) these constraints will affect the support counting step
of sequential pattern discovery algorithms because some data sequencesno
longer support a candidate pattern when mingap and rnargap constraints are
present. These algorithms must be modified to ensure that the timing con-
straints are not violated when counting the support of a pattern. Otherwise,
some infrequent sequencesmay mistakenly be declared as frequent patterns.
A side effect of using the margap constraint is that the Apri,ori principle
might be violated. To illustrate this, consider the data set shown in Figure
7.5. Without mingap or rnargap constraints, the support for ({Z}{S}) and
({2}{3}{5}) are both equal to 60%. However,if mi,ngap: 0 and margap: L,
then the support for ({Z}{5}) reducesto 40To,while the support for ({Z}{a}{S})
is still 60%. In other words, support has increasedwhen the number of events
in a sequenceincreases-which contradicts the Apri,ori, principle. The viola-
tion occurs becausethe object D does not support the pattern ({2}{5}) since
the time gap between events 2 and 5 is greater than rnargap. This problem
can be avoided by using the concept of a contiguous subsequence.
Definition 7.2 (Corftiguous Subsequence). A sequences is a contiguous
subsequenceof w - \e1e2...ek) if any one of the following conditions hold:
Finally, events within an element s7 do not have to occur at the same time. A
window size threshold (tr.'s)can be defined to specify the maximum allowed
time difference between the latest and earliest occurrences of events in any
element of a sequential pattern. A window size of 0 means all events in the
same element of a pattern must occur simultaneously.
The following example uses u)s : 2 to determine whether a data se-
quence supports a given sequence(assuming mingap : 0, margap : 3, and
marspan: -).
In the last example, although the pattern ({1,3,4} {6,7,8}) satisfiesthe win-
dow size constraint, it violates the margap constraint becausethe maximum
time difference between events in the two elements is 5 units. The window
size constraint also affects the support counting step of sequential pattern dis-
covery algorithms. If Algorithm 7.I is applied without imposing the window
size constraint, the support counts for some of the candidate patterns might
be underestimated, and thus some interesting patterns may be lost.
There are several methods available for counting the support of a candidate
k-sequencefrom a database of sequences.For illustrative purposes, consider
the problem of counting the support for sequenc" ({p}{q}), as shown in Figure
7.8. Assume that ?rs : 0, mingap : 0, margap: 1, and marspan :2.
44O Chapter 7 Association Analysis: Advanced Concepts
Object'sTimeline
ppp (p)(q)
Sequence:
ppqqqqq
t_-_t-_______.1__ ]_
, ---'i---------'t-- (Method,Count)
i1 i2 i3 i4 i5 i6 i7
#iiii COBJ
J cwlN
Hi
itH | "r'**'*
CDISTO 8
CDIST 5
Figure7.8. Comparing
different
support methods.
counting
window is the time interval such that the sequenceoccurs in that time
interval, but it does not occur in any of the proper subintervals of it. This
definition can be considered as a restrictive version of CWIN, because
its effect is to shrink and collapsesome of the windows that are counted
by CWIN. For example, sequenc" ({p}{q}) has four minimal window
-- 3, q:
occurrences:(1) the pair (p: t :2, q'. t :3)' (2) the pair (p'. t
t:4), (3) the pair (p: t:5, Q:t:6), and (a) the pair (p: t:6, q:
t:7). The occurrenceof eventp at t:1 and event q at t :3 is not a
minimal window occurrence because it contains a smaller window with
(p: t:2, g: t: 3), which is indeed a minimal window of occurrence'
One final point regarding the counting methods is the need to determine the
baselinefor computing the support measufe. For frequent itemset mining, the
baseline is given by the total number of transactions. For sequential pattern
mining, the baseline depends on the counting method used. For the COBJ
method, the total number of objects in the input data can be used as the
baseline. For the CWIN and CMINWIN methods, the baselineis given by the
sum of the number of time windows possible in all objects. For methods such
as CDIST and CDIST_O, the baseline is given by the sum of the number of
distinct timestamps present in the input data of each object.
442 Chapter 7 Association Analysis: Advanced Concepts
Table
7.7.Graph
representation
ofentities
invarious
application
domains.
Figure
7.9,Example
ofa subgraph.
Subgraph9.,
aO'-{'e
= 80%
support
Subgraphg,
af,J___ad
/t
Oe
= 60%
support
Figure7.10.Computing
thesupport froma setofgraphs.
of a subgraph
Example 7.2. Consider the five graphs, G1 through Gr, shown in Figure
7.10. The graph pr shown on the top right-hand diagram is a subgraph of G1,
Gs, G+, and Gs. Therefore, s(gr) : 415 : 80%. Similarly, we can show that
s(gz) :60% because92 is a subgraph of G1, G2, and G3, while s(gs) : lO%
because93 is a subgraph of G1 and G3. I
This section presentsa formal definition of the frequent subgraph mining prob-
Iem and illustrates the complexity of this task.
Definition 7.6 (Flequent Subgraph Mining). Given a set of graphs f
and a support threshold, m'insup, the goal of frequent subgraph mining is to
find all subgraphs g such that s(9) > rnxnsup.
While this formulation is generally applicable to any type of graph, the
discussion presented in this chapter focuses primarily on undirected, con-
nected graphs. The definitions of these graphs are given below:
1. A graph is connected ifthere exists a path between every pair ofvertices
in the graph, in which a path is a sequenceof vertic€s 1u1u2...ute )
7.5 Subgraph Patterns 445
I(;) x 2i(i-r)/2 )
where (f) is tne number of ways to choose i vertices to form a subgraph and
2i(i-L)12is the maximum number of edgesbetween vertices. Table 7.8 compares
the number of itemsets and subgraphs for different values of d.
G1 G2 G4
k=1 @ @
Dn Q^
€_fi9 €H9
D^ o^
€HD €H9
o^ o^
QHD (9HU
k=3
c+.4
\I' €J
Figure7.'11,Brute{orce
method
formining
frequent
subgraphs.
2. The same pair of vertex labels can have multiple choicesof edge labels.
G1 G2 G3 G4
Figure
7,12,Mapping ofgraph
acollection intomarket
structures basket
transactions.
Data Tlansformation
The specificdetails of these steps are discussedin the remainder of this section.
t----__--_----l
+
G3 = merge(G1,G2)
opp q0
por 00
MGg= pr0 Or
900 0?
00r ?0
strategy.
Figure7.13. Vertex-growing
An adjacency matrix 141G)i" merged with another matrix llit\z) il the submatrices
identical
obtained by removing the last row and last column of MG) and MQ) are
with the Iast
to each other. The resulting matrix is the matrix ry'(l), appended
matrix are
row and last column of matrix M(2). T]he remaining entries of the new
vertices'
either zero or replaced by all valid edge labels connecting the pair of
The resulting graph contains one or two edges more than the original
graphs. In Figure 7.13, both G1 and G2 contain four vertices and four edges'
Aft", -"rging, the resulting graph G3 has flve vertices. The number of edges
e
in G3 depends on whether the vertices d and € are connected. If d and
are disconnected,then G3 has five edgesand the corresponding matrix entry
(d, e)
for (d, e) \s zero. Otherwise, G3 has six edges and the matrix entry for
is
corresponds to the label for the newly created edge. since the edge label
unknown, we need to consid.erall possibleedge labels fot (d,e), thus increasing
the number of candidate subgraphs substantially'
,/
G 3 = m e r g e( G l , G 2 )
Figure7.14.Edge-growing
strategy.
A frequent subgraph 9(1) is merged with another frequent subgraph g(2) only if
the subgraph obtained by removing an edge from 9(r) is topologically equivalent
to the subgraph obtained by removing an edge from gQ). After merging, the
resulting candidate is the subgraph 9(r), appended with the extra edge from gQ)
The graphs to be merged may contain several vertices that are topolog-
ically equivalent to each other. To illustrate the concept of topologically
equivalent vertices, consider the graphs shown in Figure 7.15. The graph G1
contains four vertices with identical vertex labels, "a." lf a new edge is at-
7.5 Subgraph Patterns 451
G1 G2 G3
Figure7.15.lllustration
oftopologically vertices.
equivalent
tached to any one of the four vertices, the resulting graph will look the same.
The vertices in G1 are therefore topologically equivalent to each other.
The graph G2 has two pairs of topologically equivalent vertices, u1 with
u4 and uz with u3, even though the vertex and edge labels are identical. It is
easy to seethat u1 is not topologically equivalent to u2 becausethe number of
edgesincident on the vertices is different. Therefore, attaching a new edge to
u1 results in a different graph than attaching the same edge to u2. Meanwhile,
the graph G3 does not have any topologically equivalent vertices. While a1
andu4 have the same vertex labels and number of incident edges,attaching a
new edge to u1 results in a different graph than attaching the same edge to u4.
The notion of topologically equivalent vertices can help us understand why
multiple candidate subgraphs can be generatedduring edge growing. Consider
the (k - 1)-subgraphs G1 and G2 shown in Figure 7.16. To simplify the
notation, their core, which contains k - 2 common edges between the two
graphs, is drawn as a rectangular box. The remaining edge in Gl that is not
included in the core is shown as a dangling edge connecting the vertices a and
b. Similarly, the remaining edge in G2 that is not part of the core is shown as
a dangling edge connecting vertices c and d. Although the cores for G1 and
G2 are identical, a and c may or may not be topologically equivalent to each
Figure7.16.General formerging
approach viaedgegrowing.
a pairofsubgraphs
452 Chapter 7 Association Analysis: Advanced Concepts
(a)a+candbtd (b)a=candb*d
G3 = Merge(G1,G2) G3 = Merge(G1,G2)
(c)a+candb=d
G3 = Merge(c1, c2)
G3 = Merge(G1,G2) G3 = Merge(G1,G2)
(d)a=candb=d
Figure7.17.Candidate generated
subgraphs viaedgegrowing.
Figure7.18.Multiplicity
of candidates
during generation.
candidate
Figure7.19.Graphisomorphism
consider the two graphs shown in Figure 7.19. Even though both graphs look
different, they are actually isomorphic to each other becausethere is a one-to-
one mapping between vertices in both graphs.
0p pq
p0 r0
M=
pr 00
q0 00
Figure7.20.Adjacency of a graph.
matrixrepresentation
7.5 Subgraph Patterns 455
example of such a matrix for the given graph. In principle, a graph can have
more than one adjacency matrix representation because there are multiple
ways to order the vertices in the adjacency matrix. In the example shown in
Figure 7.20, lhe first row and column correspond to the vertex a that has 3
edges, the second row and column correspond to another vertex a that has
2 edges, and so on. To derive all the adjacency matrix representations for
a graph, we need to consider all possible permutations of rows (and their
corresponding columns) of the matrix.
Mathematically, each permutation corresponds to a multiplication of the
initial adjacency matrix with a corresponding permutation matrix, as illus-
trated in the following example.
Example 7.3. Consider the following matrix:
23
67
M_
10 11
L4 15
The following permutation matrix can be used to exchange the first row (and
column) with the third row (and column\ of M:
Prs:
where Prs is obtained by swapping the first and third row of the identity
matrix. To exchangethe first and third rows (and columns), the permutation
matrix is multiplied wilh M:
M' : P{sx M x
Note that multiplying M from the right with P13 exchangesthe first and third
columns of.M, while multiplying M from the left with Pfi exchanges the first
and third rows of M. If all three matrices are multiplied, this will produce a
matrix M'whose first and third rows and columns have been swapped. r
456 Chapter 7 Association Analysis: Advanced Concepts
A(3) A(4)
code = 1100111000010010010100001011
A(2) A(1)
A(3) A(4)
code = 101101001010000010011
0001110
Figure
7.21.String
representation matrices.
ofadjacency
book, but interested readers may consult the bibliographic notes at the end of
this chapter.
Section 6.7.1 on page 371 described how correlation analysis can be used to
analyze the relationship between a pair of categorical variables. Measures
such as interest factor (Equation 6.5) and the /-coefficient (Equation 6.8)
were shown to be useful for discovering itemsets that are positively correlated.
This section extends the discussionto negatively correlated patterns.
Let X : {rt,r2t...,r7,} denotea k-itemsetand P(X) denotethe proba-
bility that a transaction contains X. In association analysis, the probability
is often estimated using the itemset support, s(X).
7.6 Infrequent Patterns 459
k
< : s ( r r ) x s ( r 2 ) x. . . x s ( r k ) , (7.3)
" ( x ) jf:lr" ( " i )
The preceding definition provides only a partial condition for negative cor-
relation between items in X and items in Y. A full condition for negative
correlation can be stated as follows:
s(xur)-s(x)s(Y)
r- _'tf I
: s(XU)') - uY)+ s(xuY)l uY)+ s(xur)l
fs(x f(x
f.l
: s(xu")lt s ( X u Y )- s ( x u v ) - s ( x u v ) l s(XuY)s(xuY)
: s(X u Y)s(X u 7) - s(X u Y)s(X r-tY),
the condition for negative correlation can be stated as follows:
The negatively correlated itemsets and association rules are known as nega-
tively correlated patterns throughout this chapter.
FrequentPatterns
Figwe7.22.Comparisons
among patterns,
infrequent patterns,
negative andnegatively
correlated
patterns.
Tabfe7.9.Atwo-way
contingency ruleX --.-+Y.
tablefortheassociation
Y Y
X s(X u Y) s ( Xu Y ) s(x)
X s(X u Y ) s ( Xu Y ) s(x)
s(v) s(v) 1
Maximal Frequent
Itemset
'/'
Frequent
Itemset
Border
Infrequent
Figure7.23,Frequent itemsets.
andinfrequent
growth. These itemsets correspondto those located below the frequent itemset
border shown in Figure 7.23.
Since the number of infrequent patterns can be exponentially large, es-
pecially for sparse, high-dimensional data, techniques developed for mining
infrequent patterns focus on finding only interesting infrequent patterns. An
example of such patterns includes the negatively correlated patterns discussed
in Section 7.6.2. These patterns are obtained by eliminating all infrequent
itemsets that fail the negative correlation condition provided in Inequality
7.3. This approach can be computationally intensive because the supports
for all infrequent itemsets must be computed in order to determine whether
they are negatively correlated. Unlike the support measure used for mining
frequent itemsets, correlation-basedmeasuresused for mining negatively corre-
lated itemsets do not possessan anti-monotone property that can be exploited
for pruning the exponential search space. Although an efficient solution re-
mains elusive, several innovative methods have been developed, as mentioned
in the bibliographic notes provided at the end of this chapter.
The remainder of this chapter presentstwo classesof techniquesfor mining
interesting infrequent patterns. Section 7.6.5 describes methods for mining
7.6 InfrequentPatterns 463
OriginalTransactions Transactions
with Negativeltems
Figure7.24.
Augmenting
a datasetwithnegative
items.
negative patterns in data, while Section 7.6.6 describes methods for finding
interesting infrequent patterns based on support expectation.
1. The number of items doubles when every item is augmented with its
corresponding negative item. Instead of exploring an itemset lattice of
size2d, where d is the number of items in the original data set, the lattice
becomesconsiderably larger, as shown in Exercise 21 on page 485.
when the support for most itemsets is low; otherwise, the number of
frequent itemsets grows exponentially.
s ( { p , Q , r } ): - q } ) - ' ( { p , r } ) + s ( { p ,q , r } ) .
"({p}) "({p,
More generally,the support for any itemsetX UY can be obtainedas follows:
Figure7.25.Example hierarchy.
of a concept
same product family, we expect the association between ham and chips to be
somewhat similar to the association between bacon and chips. If the actual
support for any one ofthese pairs is lessthan their expected support, then the
infrequent pattern is interesting.
To illustrate how to compute the expected support, consider the diagram
shown in Figure 7.26. Supposethe itemset {C,G} is frequent. Let s(') denote
the actual support of a pattern and e(.) denote its expected support. The
expected support for any children or siblings of C and G can be computed
using the formula shown below.
e(s(E,J)):
s(C,G)rffi"8 (7.8)
For example, if soda and snack food are frequent, then the expected
support between diet soda and chips can be computed using Equation 7.8
because these items are children of soda and snack food, respectively. If
the actual support for diet soda and chips is considerably lower than their
expected value, then diet soda and chips form an interesting infrequent
pattern.
7.6 InfrequentPatterns 467
DEJK
Figure7.26.Mining
interesting patterns
negative usinga concept
hierarchy.
a .-v
'.,,^
a\' tl
.\_-/
Figwe7.27. Anindirect
association a pairof items.
between
2. 2Y I 0 such that:
Note that the mediator support and dependence conditions are used to
ensure that items in Y form a close neighborhood to both a and b. Some
of the dependencemeasuresthat can be used include interest, cosine or IS,
Jaccard, and other measurespreviously described in Section 6.7.1 on page 371.
Indirect associationhas many potential applications. In the market basket
domain, a and b may refer to competing items such as desktop and laptop
computers. In text mining, indirect association can be used to identify syn-
onyms, antonyms, or words that are used in different contexts. For example,
given a collection of documents, the word data may be indirectly associated
with gold via the mediator mining. This pattern suggests that the word
mining can be used in two different contexts-data mining versus gold min-
itrg.
Indirect associationscan be generated in the following way. First, the set
of frequent itemsets is generated using standard algorithms such as Apri'ori'
or FP-growth. Each pair of frequent k-itemsets are then merged to obtain
a candidate indirect association (a,b,Y), where a and b are a pair of items
and Y is their common mediator. For example, if {p,q,r} and {p,q,s} are
7.7 Bibliographic Notes 469
ciation rules using a concept hierarchy. Tan et al. [365] proposed the idea of
mining indirect associationsfor sequential and non-sequential data. Efficient
algorithms for mining negative patterns have also been proposed by Boulicaut
et al. [345], Teng et al. [366], Wu et al. [369], and Antonie and Za'iane 13421.
Bibliography
f341] R. Agrawal and R. Srikant. Mining Sequential Patterns. In Proc. of IntI. Conf. on
Data Engi,neeri:ng, pages 3 14, Taipei, Taiwan, 1995.
1342] M.-L. Antonie and O. R. Zaiane. Mining Positive and Negative Association Rules:
An Approach for Confined Rules. In Proc. of the 8th European Conf of Princi,ples
and Practice of Knowledge D,i,scoueryi,n Databases, pages 27-38, Pisa, Italy, September
2004.
[343] Y. Aumann and Y. Lindell. A Statistical Theory for Quantitative Association Rules.
In KDD99, pages 261-270, San Diego, CA, August 1999.
13441 J . Ayres, J. Flannick, J. Gehrke, and T. Yiu. Sequential Pattern mining using a bitmap
representation. In Proc. of the 9th IntI. Conf. on Knowledge D,iscouerg and Data Mining,
pages 429 435, trdmonton, Canada, JuJy 2002.
[345] J.-F. Boulicaut, A. Bykowski, and B. Jeudy. Towards the Tlactable Discovery of
Association Rules with Negations. In Proc. of the lth Intl. Conf on Flerible Query
Answering Sgstems FQAS'1}, pages 425-434, Warsaw, Poland, October 2000.
[346] H. Cheng, X. Yan, and J. Han. IncSpan: incremental mining of sequential patterns
in large database. In Proc. of the 10th Intl. Conf. on Knowledge Discouerg and, Data
M'in'ing, pages 527 532, Seattle, WA, August 2004.
[347] T. Fukuda, Y. Morimoto, S. Morishita, and T. Tokuyama. Mining Optimized Associa-
tion Rules for Numeric Attributes. In Proc. of the 15th SErnp. on Principles of Database
Sgstems, pages 182-191, Montreal, Canada, June 1996.
1348] M. N. Garofalakis, R. Rastogi, and K. Shim. SPIRIT: Sequential Pattern Mining with
Regular Expression Constraints. In Proc. of the 25th VLDB ConJ., pages 223-234,
Edinburgh, Scotland, 1999.
1349] E.-H. Han, G. Karypis, and V. Kumar. Min-Apriori: An Algorithm for Finding As-
sociation Rules in Data with Continuous Attributes. http://www.cs.umn.edu/-han,
1997.
[350] J. Han and Y. Fu. Mining Multiple-Level Association Rules in Large Databases. IEEE
Trans. on Knowledge and Data Eng'ineering, 11(5):798-804, 1999.
[351] A. Inokuchi, T. Washio, and H. Motoda. An Apriori-based Algorithm for Mining F]e-
quent Substructures from Graph Data. In Proc. of the /1th European Conf. of Principles
and, Practice of Knowledge D'iscouery in Databases,pages 13-23, Lyon, France, 2000.
[352] M. V. Joshi, G. Karypis, and V. Kumar. A Universal Formulation of Sequential
Patterns. In Proc. of the KDD'2001 workshop on Temporal Data Mi,ning, San Ftancisco,
CA, August 2001.
[353] M. Kuramochi and G. Karypis. Frequent Subgraph Discovery. In Proc. of the 2001
IEEE Intl. Conf. on Data Mi,ning, pages 313-320, San Jose, CA, November 2001.
[354] M. Kuramochi and G. Karypis. Discovering Frequent Geometric Subgraphs. In Proc.
of the 2002 IEEE Intl. Conf. on Data Mini,ng, pages 258-265, Maebashi City, Japan,
December 2002.
472 Chapter 7 Association Analysis: Advanced Concepts
[355] B. Lent, A. Swami, and J. Widom. Clustering Association Rules. In Proc. of the 13th
IntI. Conf. on Data Engineering, pages 220 231, Birmingham, U.K, April 1997.
[356] H. Mannila, H. Toivonen, and A. I. Verkamo. Discovery of F]equent Episodes in Event
Sequences. Data Mi,ni.ng and Knowledge Di,scouery,1(3):259-289, November 1997.
[357] R. J. Miller and Y. Yang. Association Rules over Interval Data. In Proc. of 1997
ACM-SIGMOD IntL Conf. on Management of Data, pages 452 461, T\rcson, AZ, May
1997.
1358] S. Parthasarathy and M. Coatney. Efficient Discovery of Common Substructures in
Macromolecules. In Proc. of the 2002 IEEE Intl. Conf. on Data M'ining, pages 362 369,
Maebashi City, Japan, December 2002.
1359] J. Pei, J. Han, B. Mortazavi-Asl, Q. Chen, U. Dayal, and M. Hsu. PrefixSpan: Mining
Sequential Patterns efficiently by prefix-projected pattern growth. In Proc of the 17th
IntI. Conf. on Data Engi,neering, Heidelberg, Germany, April 2001.
[360] A. Savasere,E. Omiecinski, and S. Navathe. Mining for Strong Negative Associations
in a Large Database of Customer TYansactions. In Proc. of the llth IntI. Conf. on Data
Eng'ineering, pages 494-502, Orlando, Florida, February 1998.
[361] M. Seno and G. Karypis. SLPMiner: An Algorithm for Finding Frequent Sequential
Patterns Using Length-Decreasing Support Constraint. In Proc. of the 2002 IEEE Intl.
Conf. on Data Mzni,ng, pages 418-425, Maebashi City, Japan, December 2002.
f362] R. Srikant and R. Agrawal. Mining Generalized Association Rules. In Proc. of the
21st VLDB Conf., pages 407-419, Ztxich, Switzerland, 1995.
1363] R. Srikant and R. Agrawal. Mining Quantitative Association Rules in Large Relational
Tables. In Proc. of 1996 ACM-SIGMOD Intl. Conf. on Managementof Data, pages 1
12, Montreal, Canada, 1996.
1364] R. Srikant and R. Agrawal. Mining Sequential Patterns: Generalizations and Perfor-
mance Improvements. In Proc. of the Sth Intl Conf. on Ertending Database Technologg
(EDBT'96), pages 18 32, Avignon, France, 1996.
1365] P. N. Tan, V. Kumar, and J. Srivastava. Indirect Association: Mining Higher Order
Dependencies in Data. In Proc. of the lth European Conf. of Princ'iples and Practice
of Knouledge D'iscoueryin Databases, pages 632-637, Lyon, FYance,2000.
[366] W. G. Teng, M. J. Hsieh, and M.-S. Chen. On the Mining of Substitution Rules for
Statistically Dependent Items. In Proc. of the 2002 IEEE Intl. Conf. on Data Mining,
pages 442-449, Maebashi City, Japan, December 2002.
1367] K. Wang, S. H. Tay, and B. Liu. Interestingness-Based Interval Merger for Numeric
Association Rules. In Proc. of the lth Intl. Conf. on Knowledge Discouery and Data
Mr,ruing,pages 121 128, New York, NY, August 1998.
f368] G. I. Webb. Discovering associations with numeric variables. In Proc. of the 7th IntI.
Conf. on Knowledge Discouery and, Data M'ining, pages 383-388, San Francisco, CA,
August 2001.
f369] X. Wu, C. Zhang, and S. Zhang. Mining Both Positive and Negative Association Rules.
ACM Trans. on Informat'ion Sgstems,22(3):381 405,2004.
[370] X. Yan and J. Han. gSpan: Graph-based Substructure Pattern Mining. In Proc.
of the 2002 IEEE IntI. Conf. on Data Mi,ni.ng, pages 72L-724, Maebashi City, Japan,
December 2002.
f3711 M. J. Zakl. Efficiently mining frequent trees in a forest. In Proc. of the 8th Intl. Conf.
on Knowledge Discouery and Data Mining, pages 71-80, Edmonton, Canada, Jdy 2002.
1372] H. Zlnang, B. Padmanabhan, and A. Tuzhilin. On the Discovery of Significant Statis-
tical Quantitative Rules. In Proc. of the 10th Intl. Conf. on Knowled,ge D'i,scouery and'
Data Mi,ni,ng,pages 374-383, Seattle, WA, August 2004.
7.8 Exercises 473
7.8 Exercises
1. Consider the traffic accident data set shown in Table 7.10.
Table7,10.Traffic
accident
dataset.
Weat her Driver's Tlaffic Seat belt Urash
Condition Condition Violation Severity
Good Alcohol-impaired Exceed speed limit No Major
Bad Sober None Yes Minor
Good Sober Disobey stop sign Yes Minor
Good Sober Exceed speed limit Yes Major
Bad Sober Disobey traffic signal No Major
Good Alcohol-impaired Disobey stop sign Yes Minor
Bad Alcohol-impaired None Yes Major
Good Sober Disobey trafrc signal Yes Major
Good Alcohol-impaired None No Major
Bad Sober Disobey traffic signal No Major
Good Alcohol-impaired Exceed speed limit Yes Major
Bad Sober Disobey stop sign Yes Minor
2. (a) Consider the data set shown in Table 7.11. Supposewe apply the following
discretization strategies to the continuous attributes of the data set.
2.
7.11,DatasetforExercise
Table
TID Temperature Pressure Alarm 1 Alarm 2 Alarm 3
I 9l) 1105 0 0 1
2 6D 1040 I 1
I 0
3 103 1090 I 1 1
4 97 1084 1 0 0
o 80 1038 0 1 1
r) 100 1080 1 1 0
7 83 1025 1 0 1
8 86 1030 1 0 0
o 101 1100 1 1 I
,). Consider the data set shown in Table 7.I2. The first attribute is continuous,
while the remaining two attributes are asymmetric binary. A rule is considered
to be strong if its support exceeds 15% and its confidence exceeds60%. The
data given in Table 7.12 supports the following two strong rules:
( i ) { ( 1 < A < 2 ) , 8 : 1 } - - - +{ C : 1 }
( i i ) { ( 5 < A < 8 ) , 8 : 1 } - - +{ C : 1 }
Table7.12.
DatasetforExercise
3.
A B C
1 1 I
2 1 I
,1 1 0
4 1 0
o 1 1
o 0 1
7 0 0
8 1 1
q
0 0
10 0 0
11 0 0
12 0 1
Table
7.13.DatasetforExercise
4.
Age Number of Hours Online per Week (B)
(A) 0-5 5-10 10-20 20-30 30-40
10-15 2 .f
( 2
15-25 2 ( 10 10 3
25-35 10 15 r .J 2
35-50 4 o K
3 2
(a) For each combination of rules given below, specify the rule that has the
highestconfidence.
i . 1 5< A < 2 5 - - - - +
1 0< B < 2 0 , I 0 < A < 2 5 - - - - 1
+ 0 < B < 2 0 ,a n d
75 < A ( 35-------+ 70 < B <20.
476 Chapter 7 Association Analysis: Advanced Concepts
5. For the data set with the attributes given below, describe how you would con-
vert it into a binary transaction data set appropriate for association analysis.
Specifically, indicate for each attribute in the original data set
The following is a list of attributes for the data set along with their possible
values. Assume that all attributes are collected on a per-student basis:
- Russian
- Spanish
6. Consider the data set shown in Table 7.14. Suppose we are interested in ex-
tracting the following association rule:
( Age l ctz,Play Piano : Yes} ------'
{41 {Enjoy Classical Music : Yes}
Table
7.14.Data
setforExercise
6.
Age Play Piano Eniov Classical Music
a Yes Yes
11 Yes Yes
1A
I4 Yes No
17 Yes No
19 Yes Yes
2l No No
25 No No
29 Yes Yes
33 No No
39 No Yes
4I No No
4.7 No Yes
7. Consider the transactions shown in Table 7.15, with an item taxonomy given
in Figure 7.25.
478 Chapter 7 Association Analysis: Advanced Concepts
7.15.Example
Table olmarket
basket
transactions.
Tbansaction ID Items tsought
1 Chips, Cookies, Regular Soda, Ham
z Chips, Ham, Boneless Chicken, Diet Soda
2 Ham, Bacon, Whole Chicken, Regular Soda
4 Chips, Ham, BonelessChicken, Diet Soda
r
Chips, Bacon, BonelessChicken
tl Chips, Ham, Bacon, Whole Chicken, Regular Soda
7 Chips, Cookies, BonelessChicken, Diet Soda
(a) What are the main challenges of mining association rules with item tax-
onomy?
(b) Consider the approach where each transaction t is replaced by an extended
transaction tt that contains all the items in f as well as their respective
ancestors. For example, the transaction t : { Chips, Cookies} will be
replaced by tt : {Ctrips, Cookies, Snack Food, Food}. Use this approach
to derive all frequent itemsets (up to size 4) with support > 70%.
(c) Consider an alternative approach where the frequent itemsets are gener-
ated one level at a time. Initially, all the frequent itemsets involving items
at the highest level of the hierarchy are generated. Next, we use the fre-
quent itemsets discovered at the higher level of the hierarchy to generate
candidate itemsets involving items at the lower levels of the hierarchy. For
example, we generate the candidate itemset {Cnips, Diet Soda} only if
{Snack Food, Soda} is frequent. Use this approach to derive all frequent
itemsets (up to size 4) with support > 70%.
(d) Compare the frequent itemsets found in parts (b) and (c). Comment on
the efficiency and completeness of the algorithms.
8 . The following questions examine how the support and confi.denceof an associ-
ation rule may vary in the presence of a concept hierarchy.
(a) Consider an item r in a given concept hierarchy. Let 11, fr2, . . .,7r denote
the k children of r in the concept hierarchy. Show that < Li:r t(T'),
"(r)
where s(.) is the support of an item. Under what conditions will the
inequality become an equality?
(b) Let p and q denote a pair of items, while p and Q are their corresponding
parents in the concept hierarchy. If s({p, q}) > mi,nsup, which of the fol-
Iowing itemsets are guaranteed to be frequent? (i) q}), (ii) s({p,4}),
"({p,
and (iii) s({p,,?})
(c) Consider the association rule {p} ------+
{q}. Supposethe confidence of the
rule exceeds mi,nconf . Which of the following rules are guaranteed to
7.8 Exercises 479
have confidence higher than m'inconfZ (i) {p} ------{,?}, (ii) {p} ------+
{q},
and (iii) {p} ----.+{4}.
< { 1 , 3 }{ 2 } { 2 , 3 }{ 4 } > ,
assuming no timing constraints.
(b) List all the 3-element subsequences contained in the data sequence for
part (a) assuming that no timing constraints are imposed.
(c) List all the 4-subsequencescontained in the data sequence for part (a)
(assuming the timing constraints are flexible).
(d) List all the 3-element subsequences contained in the data sequence for
part (a) (assuming the timing constraints are flexible).
10. Find all the frequent subsequences with support > 50% given the sequence
database shown in Table 7.16. Assume that there are no timing constraints
imposed on the sequences.
Table
7.16, Example
ofevent generated
sequences byvarious
sensors.
Sensor Timestamp Events
S1 1 A,B
2 C
3 D,E
^ C
S2 1 A,B
2 C,D
.) E
S3 1 B
2 A
3 B
4 D,E
S4 1 C
2 D,E
3 C
4 E
S5 1 B
2 A
.) B,C
4 A,D
480 Chapter 7 Association Analysis: Advanced Concepts
11. ( a ) F o r e a c ho f t h e s e q u e n c er sr : < € r e z . . . e t . . . e t + t . . . € t a s t ) g i v e nb e l o w ,
determine whether they are subsequencesof the sequence
< { 7 , 2 ,3 } { 2 , 4 } { 2 , 4 ,5 } { 3 , 5 } i 6 } >
14. Consider the data sequenceshown in Table 7.17 for a given object. Count the
number of occurrencesfor the sequence({p}{q}{"}) according to the following
counting methods:
Table7.17.Example
ofevent 14.
dataforExercise
sequence
Timestamp Events
1 P'Q
2 r
t) S
4 P,Q
tr frs
6 p
7 Qtr
8 QrS
9 p
10 QrrtS
482 Chapter 7 Association Analysis: Advanced Concepts
15. Describe the types of modifications necessary to adapt the frequent subgraph
mining algorithm to handle:
For each type of graph given above, describe which step of the algorithm will be
affected (candidate generation, candidate pruning, and support counting), and
any further optimization that can help improve the efEciency of the algorithm.
16. Draw all candidate subgraphs obtained from joining the pair of graphs shown in
Figure 7.28. Assume the edge-growingmethod is used to expand the subgraphs.
(a)
(b)
Figure7.28.Graphs 16.
forExercise
17. Draw all the candidate subgraphs obtained by joining the pair of graphs shown
in Figure 7.29. Assume the edge-growing method is used to expand the sub-
graphs.
7.8 Exercises 483
(a)
(b)
Figure forExercise
7.29,Graphs 17.
18. (a) If support is defined in terms of induced subgraph relationship, show that
the confidenceofthe rule 91 - gz can be greater than 1 ifgl and !2 are
allowed to have overlapping vertex sets.
(b) What is the time complexity needed to determine the canonical label of
a graph that contains lVl vertices?
(c) The core of a subgraph can have multiple automorphisms. This will in-
crease the number of candidate subgraphs obtained after merging two
frequent subgraphs that share the same core. Determine the maximum
number of candidate subgraphs obtained due to automorphism of a core
of size k.
(d) Two frequent subgraphs of size k may share multiple cores. Determine
the maximum number of cores that can be shared by the two frequent
subgraphs.
le. (a) Consider a graph mining algorithm that uses the edge-growing method to
join the two undirected and unweighted subgraphs shown in Figure 19a.
+
484 Chapter 7 Association Analysis: Advanced Concepts
I Draw all the distinct cores obtained when meiging the two subgraphs.
II How many candidates are generated using the following core?
20. The original association rule mining framework considers only presence of items
together in the same transaction. There are situations in which itemsets that
are infrequent may also be informative. For instance, the itemset TV, DVD, -
VCR suggeststhat many customerswho buy TVs and DVDs do not buy VCRs.
In this problem, you are asked to extend the association rule framework to neg-
ative itemsets (i.e., itemsets that contain both presence and absence of items).
We will use the negation symbol (-) to refer to absenceof items.
(a) A naive way for deriving negative itemsets is to extend each transaction
to include absenceof items as shown in Table 7.18.
Table
7.18,Example dataset.
ofnumeric
TID TV -TV DVD -DVD VCR -VCR
1 I 0 0 1 0 I
2 1
0 0 I 0 I
27. Suppose we would like to extract positive and negative itemsets from a data
set that contains d items.
22. For each type of pattern defined below, determine whether the support measure
is monotone, anti-monotone, or non-monotone (i.e., neither monotone nor anti-
monotone) with respect to increasing itemset size.
(a) Itemsets that contain both positive and negative items such as {a,b,Z,d}.
Is the support measure monotone, anti-monotone, or non-monotone when
applied to such patterns?
(b) Boolean logical patterns such as {(a v b V c), d, e}, which may con-
tain both disjunctions and conjunctions of items. Is the support measure
monotone, anti-monotone, or non-monotone when applied to such pat-
terns?
23. Many association analysis algorithms rely on an Apriori-like approach for find-
ing frequent patterns. The overall structure of the algorithm is given below.
------
{o v b} {c,d},
which may contain both disjunctions and conjunctions of items. The corre-
sponding itemset can be written as {(o Y b),c,d}.
(a) Does the Apriori. principle still hold for such itemsets?
(b) How should the candidate generation step be modified to find such pat-
terns?
(c) How should the candidate pruning step be modified to find such patterns?
(d) How should the support counting step be modified to find such patterns?
ClusterAnalysis:
BasicConceptsand
Algorithms
Cluster analysis divides data into groups (clusters) that are meaningful, useful,
or both. Ifmeaningful groups are the goal, then the clusters should capture the
natural structure of the data. In some cases,however,cluster analysis is only a
useful starting point for other purposes,such as data summarization. Whether
for understanding or utility, cluster analysis has long played an important
role in a wide variety of fields: psychology and other social sciences, biology,
statistics, pattern recognition, information retrieval, machine learning, and
data mining.
There have been many applications of cluster analysis to practical prob-
lems. We provide some specific examples, organized by whether the purpose
of the clustering is understanding or utility.
8.1 Overview
Before discussing specific clustering techniques, we provide some necessary
background. First, we further define cluster analysis, illustrating why it is
difficult and explaining its relationship to other techniques that group data.
Then we explore two important topics: (1) different ways to group a set of
objects into a set of clusters, and (2) types of clusters.
Cluster analysis groups data objects based only on information found in the
data that describesthe objects and their relationships. The goal is that the
objects within a group be similar (or related) to one another and different from
(or unrelated to) the objects in other groups. The greater the similarity (or
homogeneity) within a group and the greater the difference between groups,
the better or more distinct the clustering.
In many applications, the notion of a cluster is not well defined. To better
understand the difficulty of deciding what constitutes a cluster, considerFigure
8.1, which shows twenty points and three different ways of dividing them into
clusters. The shapes of the markers indicate cluster membership. Figures
8.1(b) and 8.1(d) divide the data into two and six parts, respectively. However,
the apparent division of each of the two larger clusters into three subclusters
may simply be an artifact of the human visual system. AIso, it may not be
unreasonable to say that the points form four clusters, as shown in Figure
8.1(c). This figure illustrates that the definition of a cluster is imprecise and
that the best definition depends on the nature of data and the desired results.
Cluster analysis is related to other techniques that are used to divide data
objects into groups. For instance, clustering can be regarded as a form of
classification in that it creates a labeling of objects with class (cluster) labels.
However, it derives these labels only from the data. In contrast, classification
8.1 Overview 491
aa a
aa a aa - tt.- ^:^
oo lr a
aa aa !o rr ^^i^
a aa I
++
'++ * ++*
+i + ** -]rl.
vv
V
?
.l' !o ,,**!.
point belongs to each cluster, and these probabilities must also sum to 1. Be-
causethe membership weights or probabilities for any object sum to 1, a finzy
or probabilistic clustering does not addresstrue multiclass situations, such as
the case of a student employee, where an object belongs to multiple classes.
Instead, these approachesare most appropriate for avoiding the arbitrariness
of assigning an object to only one cluster when it may be close to several. In
practice, a htzzy or probabilistic clustering is often converted to an exclusive
clustering by assigning each object to the cluster in which its membership
weight or probability is highest.
the distance between any two points within a group. Well-separated clusters
do not need to be globular, but can have any shape.
fades into the noise and does not form a cluster in Figure 8.2(d). A density-
baseddefinition of a cluster is often employed when the clusters are irregular or
intertwined, and when noise and outliers are present. By contrast, a contiguity-
based definition of a cluster would not work well for the data of Figure 8.2(d)
since the noise would tend to form bridses between clusters.
Road Map
In this chapter, we use the following three simple, but important techniques
to introduce many of the concepts involved in cluster analysis.
:: : :: ; : : : : : : : : ::iiill,'lN: : : :: : : :
: : : : : : : : ; : : : ; : : / l i i i l i i i i i i i i i:i:N: ; : :
: ::::i :.:::i :: :i l i i i i i : i i i i i i i i ,i i i r i i l i , i ,
:' : : : : : : : \ , i ' l , i , i , i , i ,: i: .: l: t: :
:,:,,
:,i':'i'ii:'i,ilil.rir4:,
Figure
8.2.Different
types
ofclusters
asillustrated points.
bysetsoftwo-dimensional
8.2 K-means
Prototype-based clustering techniques create a one-level partitioning of the
data objects. There are a number of such techniques, but two of the most
prominent are K-means and K-medoid. K-means defines a prototype in terms
of a centroid, which is usually the mean of a group of points, and is typically
8.2 K-means 497
In the first step, shown in Figure 8.3(a), points are assignedto the initial
centroids, which are all in the larger group of points. For this example, we use
the mean as the centroid. After points are assignedto a centroid, the centroid
is then updated. Again, the figure for each step shows the centroid at the
beginning of the step and the assignment of points to those centroids. In the
second step, points are assignedto the updated centroids, and the centroids
498 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
AAAAAA AA
trDA A
tr o + o+ o o tr
otr ^ tro ^ otr | trQ
o-oo 8- :.coP9 o--oo 8" b3 P
s o-{oo 8- :.cTPS o-dP o
tr"o- tr"o- tr'o-
o "oo o "oo o "oo tr
Figure8.3. UsingtheK-means
algorithm insample
to findthreeclusters data.
are updated again. In steps 2, 3, and 4, which are shown in Figures 8.3 (b),
(c), and (d), respectively,two of the centroids move to the two small groups of
points at the bottom of the figures. When the K-means algorithm terminates
in Figure 8.3(d), becauseno more changesoccur, the centroids have identified
the natural groupings of points.
For some combinations of proximity functions and types of centroids, K-
means always convergesto a solution; i.e., K-means reachesa state in which no
points are shifting from one cluster to another, and hence, the centroids don't
change. Becausemost of the convergenceoccurs in the early steps, however,
the condition on line 5 of Algorithm 8.1 is often replacedby a weaker condition,
e.g., repeat until only l% of the points change clusters.
We considereach of the steps in the basic K-means algorithm in more detail
and then provide an analysis of the algorithm's space and time complexity.
Table8.1.Table
of notation.
Svmbol Description
x An object.
Ci The zth cluster.
Ci The centroid of cluster C6.
c The centroid of all points.
T11,4 The number of objects in the ith cluster.
TI-L The number of objects in the data set.
K The number of clusters.
K
SSE: t t d,i,st( ci,r ) 2 (8.1)
i:t r€Ci
where di,st is the standard Euclidean (Lz) distance between two objects in
Euclidean space.
Given these assumptions, it can be shown (see Section 8.2.6) that the
centroid that minimizes the SSE of the cluster is the mean. Using the notation
in Table 8.1, the centroid (mean) of the ith cluster is defined by Equation8.2.
I
Ci:
mi t*
xeC,i.
(8.2)
h-
\-a \-
Iotaluoneslon: )
ZJ ZJ
) cosxnelx,c;.) (8.3)
i:I x€C,i
The General Case There are a number of choicesfor the proximity func-
tion, centroid, and objective function that can be used in the basic K-means
8.2 K-means 501
Table8.2. K-means:
Common forproximity,
choices andobjective
centroids, functions.
Proximity Fbnction Centroid Obiective F\rnction
Manhattan (L1) median Minimize sum of the Lr distance of an ob-
iect to its cluster centroid
Squared Euclidean (L!) mean Minimize sum of the squared L2 distance
of an obiect to its cluster centroid
coslne mean Maximize sum of the cosine similarity of
an object to its cluster centroid
Bregman divergence mean Minimize sum of the Bregman divergence
of an obiect to its cluster centroid
algorithm and that are guaranteed to converge. Table 8.2 shows some possible
choices,including the two that we have just discussed. Notice that for Man-
hattan (L1) distance and the objective of minimizing the sum of the distances,
the appropriate centroid is the median of the points in a cluster.
The last entry in the table, Bregman divergence(Section 2.4.5), is actually
a classof proximity measuresthat includes the squared Euclidean distance, Ll,
the Mahalanobis distance, and cosine similarity. The importance of Bregman
divergence functions is that any such function can be used as the basis of a K-
means style clustering algorithm with the mean as the centroid. Specifically,
if we use a Bregman divergence as our proximity function, then the result-
ing clustering algorithm has the usual properties of K-means with respect to
convergence,local minima, etc. Furthermore) the properties of such a cluster-
ing algorithm can be developed for all possible Bregman divergences.Indeed,
K-means algorithms that use cosine similarity or squared Euclidean distance
are particular instances of a general clustering algorithm based on Bregman
divergences.
For the rest our K-means discussion, we use two-dimensional data since
it is easy to explain K-means and its properties for this type of data. But,
as suggested by the last few paragraphs, K-means is a very general clustering
algorithm and can be used with a wide variety of data types, such as documents
and time series.
AA AA
rA n
AAN A
^aA
a
o +1o!loP
o
a
"9UvOvn
^o"o n"
"oo
A o
o --
trtr trtr tr on
u nu O
*trtr
o tr
Figure8.4.Threeoptimal clusters.
andnon-optimal
the SSE for three clusters, while Figure 8.4(b) shows a suboptimal clustering
that is only a local minimum.
Choosing the proper initial centroids is the key step of the basic K-means
procedure. A common approach is to choose the initial centroids randomly,
but the resulting clusters are often poor.
Exarnple 8.1 (Poor Initial Centroids). Randomly selected initial cen-
troids may be poor. We provide an example of this using the same data set
used in Figures 8.3 and 8.4. Figures 8.3 and 8.5 show the clusters that re-
sult from two particular choices of initial centroids. (For both figures, the
positions of the cluster centroids in the various iterations are indicated by
crosses.)In Figure 8.3, even though all the initial centroids are from one natu-
ral cluster, the minimum SSE clustering is still found. In Figure 8.5, however,
even though the initial centroids seem to be better distributed, we obtain a
suboptimal clustering, with higher squared error. r
Example 8.2 (Lirnits of Random Initialization). One technique that
is commonly used to address the problem of choosing initial centroids is to
perform multiple runs, each with a different set of randomly chosen initial
centroids, and then select the set of clusters with the minimum SSE. While
simple, this strategy may not work very well, depending on the data set and
the number of clusters sought. We demonstrate this using the sample data set
shown in Figure 8.6(a). The data consists of two pairs of clusters, where the
clusters in each (top-bottom) pair are closer to each other than to the clusters
in the other pair. Figure 8.6 (b d) shows that if we start with two initial
centroids per pair of clusters, then even when both centroids are in a single
8.2 K-means 503
AA
r
a ^aa ^-a
^A
A A "AAA ^
^61 ofo.
vo"vO t o
-OO o"o-
o
tr tr Dtr tr
otr ntr tro oo
v06 o on
o -So oooi "oo "- o* Utr- tr -tro tr -oo ?_oo
oo o oo Eo o
o
tr o tr o
cluster, the centroids will redistribute themselves so that the "true" clusters
are found. However, Figure 8.7 shows that if a pair of clusters has only one
initial centroid and the other pair has three, then two of the true clusters will
be combined and one true cluster will be split.
Note that an optimal clustering will be obtained as long as two initial
centroids fall anywhere in a pair of clusters, since the centroids will redistribute
themselves, one to each cluster. Unfortunately, as the number of clusters
becomes larger, it is increasingly likely that at least one pair of clusters will
have only one initial centroid. (See Exercise 4 on page 559.) In this case,
becausethe pairs of clusters are farther apart than clusters within a pair, the
K-means algorithm will not redistribute the centroids between pairs of clusters,
and thus, only a local minimum will be achieved. r
Because of the problems with using randomly selected initial centroids,
which even repeated runs may not overcome, other techniques are often em-
ployed for initialization. One effective approach is to take a sample of points
and cluster them using a hierarchical clustering technique. K clusters are ex-
tracted from the hierarchical clustering, and the centroids of those clusters are
used as the initial centroids. This approach often works well, but is practical
only if (1) the sample is relatively small, €.9., a few hundred to a few thousand
(hierarchical clustering is expensive), and (2) K is relatively small compared
to the sample size.
The following procedure is another approach to selecting initial centroids.
Select the first point at random or take the centroid of all points. Then, for
each successiveinitial centroid, select the point that is farthest from any of
the initial centroids already selected. In this way, we obtain a set of initial
5O4 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
A A o A A o
aoa aOO AAA aOO
A -aaAA A AA^ o-^oo
a
aa^ o"o
aaa a ooo AAA A oov
A vo A O9
o V
tr A
tr trtr tr {atr
trn tr a- tr ^oo
- v _9
:
_ Bu
nn
o "o ifo oo {Fot-
trtr trtr V\/
v
A A A A
A^
AAA AA
A AA^ A
aaA ooo
f;Sa
AAA
a A
t Oln
-o A
tr tr
trtr tr tr otr tr
trn tr
oo{o trd-oo
D'tr trtr
otr trtr
Figure8.6,Twopairsof clusters
witha pairofinitial withineachpairofclusters.
centroids
centroids that is guaranteed to be not only randomly selected but also well
separated. Unfortunately, such an approach can select outliers, rather than
points in denseregions (clusters). AIso, it is expensiveto compute the farthest
point from the current set of initial centroids. To overcome these problems?
this approach is often applied to a sample of the points. Since outliers are
rare, they tend not to show up in a random sample. In contrast, points
from every dense region are likely to be included unless the sample size is very
small. Also, the computation involved in finding the initial centroids is greatly
reduced becausethe sample size is typically much smaller than the number of
points.
Later on, we will discusstwo other approachesthat are useful for produc-
ing better-quality (lower SSE) clusterings: using a variant of K-means that
8.2 K-means 505
A A A
A A^
AA AA ^Oo
A A oot o o-^o o
aA^ o "{o
AA.
aaA aaA a ooo
a
oo
+ A
o
+
A A
AAA AAA
Aa A Ar A
A AA ^
aa?n
AA. AA-
A4 Aa
A A A o
A A^
A^
AA A.
A o-^o o A o"^oo
AA^
AA^ o"+o AA^
aa^ o "+o
AAA A ooo aaA a ooo
A vo A
o o
+ +
A A
AAAA AAAA
An A A -trv
u
u.
^A A vrV
aa-An o-+'-w
AA_ AA_ -uv
AA AA otrv
o
The space requirements for K-means are modest because only the data points
and centroids are stored. Specifically, the storage required is O((m-l K)n),
where rn is the number of points and n is the number of attributes. The time
requirements for K-means are also modest-basically linear in the number of
data points. In particular, the time required is O(1x K +mxn), where 1is the
number of iterations required for convergence. As mentioned, 1 is often small
and can usually be safely bounded, as most changes typically occur in the
506 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
first few iterations. Therefore, K-means is linear in rn, the number of points,
and is efficient as well as simple provided that K, the number of clusters, is
significantly less than m.
One of the problems with the basic K-means algorithm given earlier is that
empty clusters can be obtained if no points are allocated to a cluster during
the assignment step. If this happens, then a strategy is needed to choose a
replacement centroid, since otherwise, the squared error will be larger than
necessary. One approach is to choose the point that is farthest away from
any current centroid. If nothing else, this eliminates the point that currently
contributes most to the total squared error. Another approach is to choose
the replacement centroid from the cluster that has the highest SSE. This will
typically split the cluster and reduce the overall SSE of the clustering. If there
are several empty clusters, then this processcan be repeated several times.
Outliers
When the squared error criterion is used, outliers can unduly influence the
clusters that are found. In particular, when outliers are present, the resulting
cluster centroids (prototypes) -uy not be as representative as they otherwise
would be and thus, the SSE will be higher as well. Becauseof this, it is often
useful to discover outliers and eliminate them beforehand. It is important,
however, to appreciate that there are certain clustering applications for which
outliers should not be eliminated. When clustering is used for data com-
pression, every point must be clustered, and in some cases,such as financial
analysis, apparent outliers, e.g., unusually profitable customers, can be the
most interesting points.
An obvious issue is how to identify outliers. A number of techniques for
identifying outliers will be discussedin Chapter 10. If we use approachesthat
remove outliers before clustering, we avoid clustering points that will not clus-
ter well. Alternatively, outliers can also be identified in a postprocessingstep.
For instance) we can keep track of the SSE contributed by each point, and
eliminate those points with unusually high contributions, especially over mul-
tiple runs. Also, we may want to eliminate small clusters since they frequently
represent groups of outliers.
8.2 K-means 5O7
An obvious way to reduce the SSE is to find more clusters, i.e., to use a larger
K. However, in many cases, we would like to improve the SSE, but don't
want to increase the number of clusters. This is often possible because K-
means typically convergesto a local minimum. Various techniques are used
to "fix up" the resulting clusters in order to produce a clustering that has
lower SSE. The strategy is to focus on individual clusters since the total SSE
is simply the sum of the SSE contributed by each cluster. (We will use the
terminology total SSE and cluster ,9^9E,respectively, to avoid any potential
confusion.) We can change the total SSE by performing various operations
on the clusters, such as splitting or merging clusters. One commonly used
approach is to use alternate cluster splitting and merging phases. During a
splitting phase, clusters are divided, while during a merging phase, clusters
are combined. In this way, it is often possibleto escapelocal SSE minima and
still produce a clustering solution with the desired number of clusters. The
following are some techniques used in the splitting and merging phases.
Two strategies that decreasethe total SSE by increasing the number of
clusters are the following:
Split a cluster: The cluster with the largest SSE is usually chosen, but we
could also split the cluster with the largest standard deviation for one
particular attribute.
Introduce a new cluster centroid: Often the point that is farthest from
any cluster center is chosen. We can easily determine this if we keep
track of the SSE contributed by each point. Another approach is to
choose randomly from all points or from the points with the highest
SSE.
Merge two clusters: The clusters with the closest centroids are typically
chosen,although another, perhaps better, approach is to merge the two
clusters that result in the smallest increase in total SSE. These two
merging strategies are the same ones that are used in the hierarchical
508 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
Instead of updating cluster centroids after all points have been assignedto a
cluster, the centroids can be updated incrementally, after each assignment of
a point to a cluster. Notice that this requires either zero or two updates to
cluster centroids at each step, since a point either moves to a new cluster (two
updates) or stays in its current cluster (zero updates). Using an incremental
update strategy guarantees that empty clusters are not produced since all
clusters start with a single point, and if a cluster ever has only one point, then
that point will always be reassignedto the same cluster.
In addition, if incremental updating is used, the relative weight of the point
being added may be adjusted; e.g., the weight of points is often decreasedas
the clustering proceeds. While this can result in better accuracy and faster
convergence, it can be difficult to make a good choice for the relative weight,
especially in a wide variety of situations. These update issuesare similar to
those involved in updating weights for artificial neural networks.
Yet another benefit of incremental updates has to do with using objectives
other than "minimize SSE." Supposethat we are given an arbitrary objective
function to measure the goodness of a set of clusters. When we process an
individual point, we can compute the value of the objective function for each
possiblecluster assignment,and then choosethe one that optimizes the objec-
tive. Specific examples of alternative objective functions are given in Section
8.5.2.
On the negative side, updating centroids incrementally introduces an or-
der dependency. In other wotds, the clusters produced may depend on the
order in which the points are processed. Although this can be addressedby
randomizing the order in which the points are processed,the basic K-means
approach of updating the centroids after all points have been assignedto clus-
ters has no order dependency. Also, incremental updates are slightly more
expensive. However, K-means converges rather quickly, and therefore, the
number of points switching clusters quickly becomesrelatively small.
8.2.3 BisectingK-means
so on, until K clusters have been produced. The details of bisecting K-means
are given by Algorithm 8.2.
A o o o B
o
ooo aAA
o
ooo NE tr nE E
o oo8o oo8o oft E "-+E
ooo o AXA ooo o E'E B E'E E
A ^- A o EE trtr
o tr tr
+ + +
o o
OoOo ^rF a ooo o oo o an
ooo%?
ooo%3
o o-
OO
A, A-A
A; AA
O6
o o' "q%^:
o 6 a
"fr"4
a^
A A
K-means and its variations have a number of limitations with respect to finding
different types of clusters. In particular, K-means has difficulty detecting the
"natural" clusters, when clusters have non-spherical shapesor widely different
sizesor densities. This is illustrated by Figures 8.9, 8.10, and 8.11. In Figure
8.9, K-means cannot find the three natural clusters becauseone of the clusters
is much larger than the other two, and hence,the larger cluster is broken, while
one of the smaller clusters is combined with a portion of the larger cluster. In
Figure 8.10, K-means fails to find the three natural clusters becausethe two
smaller clusters are much denser than the Iarger cluster. Finally, in Figure
8.11, K-means finds two clusters that mix portions of the two natural clusters
becausethe shape of the natural clusters is not globular.
The difficulty in these three situations is that the K-means objective func-
tion is a mismatch for the kinds of clusters we are trying to find since it is
minimized by globular clusters of equal size and density or by clusters that are
well separated. However) these limitations can be overcome, in some sense,if
the user is willing to accept a clustering that breaks the natural clusters into a
number of subclusters. Figure 8.12 shows what happens to the three previous
data sets if we find six clusters instead of two or three. Each smaller cluster is
pure in the sensethat it contains only points from one of the natural clusters.
K-means is simple and can be used for a wide variety of data types. It is also
quite efficient, even though multiple runs are often performed. Some variants,
including bisecting K-means, are even more efficient, and are less suscepti-
ble to initialization problems. K-means is not suitable for all types of data,
8.2 K-means 51-1
ooo
o oo
ooo
o
oooooooo
o9 oo O9 Oo
Figure8.9. K-means
withclusters
ofdifferent
size.
V
V V
A
ooo L
V Vv O^
A ^ O
too O
-E-
VVV 'vv -n
v
VV
"4+"\
^AAa o "o*o u -
-crtr-tr
rilif
n-
V w. V ooo oooo
VV V V V o +
-l
fi-
-,Untr
VVVV oooo
Vv
VVV ooo*.'o " u_uqa u
V V' 6 O-
vy -tr
v v o oo o
VV oo
Figure8.10.K-means
withclusters
ofdifferent
density.
-
_
LJ
tr T'I
tr" ntr tr
oo
ooo
uoO
a'\-
ro ooq
o oo o o" o
o ouo o
oo o
Figure8.11. K-means
withnon-globular
clusters.
5L2 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
oo o
opo
o o a\ o
og trtr
A
nA
o o o " " ,*' - 4 A a -ll
ln-
U-
-E-tr-l-Enn"
oio u nlf'l-
oFf,"
o ^ lA
ge O V v
v
vY7
o oo "
+ 17
na\ -
"# v v
o og v
OV
I
trDtr
o oo(
!+
N A^
n-D
v.
"* +A < '
zro
" o oooq$
^^ o-o
oo o
o o- ou o o n
\J
Figure8.12.UsingK-means
tofindclusters ofthenatural
thataresubclusters clusters.
8.2 K-means 513
K
sSE:ttk,-*)' (8.4)
i:l reCt
5L4 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
Herc, Ci is the ith cluster, r is a point in C,i, and c,;is the mean of the ith
cluster. SeeTable 8.1 for a complete list of notation.
We can solve for Lhe kth centroid c4, which minimizes Equation 8.4, by
differentiating the SSE, setting it equal to 0, and solving, as indicated below.
nK
\./r- r2- *+ ( q , - r n ) : 0
iL tU t1
1
* @n- rn): 0 + rrl1ac1,
:
D"r)(1,- D"r
D, mlc
reC6 r€Cp
Thus, as previously indicated, the best centroid for minimizing the SSE of
a cluster is the mean of the points in the cluster.
We can solve for the kth centroid c7r,which minimizes Equation 8.5, by
differentiating the SAE, setting it equal to 0, and solving.
8.3 Agglomerative Hierarchical Clustering 5L5
3tou :
ocx
: t 3p1,-rl:s
,6ro"*
a\
a
T fiV- - rl :o *
c/1,
e
- cn)
sisn(r : o
If we solve for q", we find that qr: med'ian{r e Cp}, the median of the
points in the cluster. The median of a group of points is straightforward to
compute and less susceptibleto distortion by outliers.
Divisive: Start with one, all-inclusive cluster and, at each step, split a cluster
until only singleton clusters of individual points remain. In this case)we
need to decide which cluster to split at each step and how to do the
splitting.
pl p2 p3 p4
relationships and the order in which the clusters were merged (agglomerative
view) or split (divisive view). For sets of two-dimensional points, such as those
that we will use as examples, a hierarchical clustering can also be graphically
representedusing a nested cluster diagram. Figure 8.13 shows an example of
these two types of figures for a set of four two-dimensional points. These points
were clustered using the single-link technique that is describedin Section 8.3.2.
(a) MIN (single link.) (b) MAX (complete link.) (c) Group average.
Figure8.14.Graph-based
definitions proximity
ofcluster
sults from merging the two clusters. Like K-means, Ward's method attempts
to minimize the sum of the squared distances of points from their cluster
centroids.
8.3.2 SpecificTechniques
Sample Data
Figure points.
8.15.Setof6 two-dimensional of 6 points.
Table8.3, rg coordinates
p1 p2 p3 p4 p5 p6
p1 0.00 0.24 0.22 0.37 0.34 0.23
p2 0.24 0.00 0.15 0.20 0.14 0.25
p3 0.22 0.15 0.00 u.li) 0.28 0.11
p4 0.37 0.20 0.15 0.00 0.29 0.22
p5 0.34 0.14 0.28 0.29 0.00 0.39
p6 0.23 0.25 0.11 0.22 0.39 0.00
Table8.4. Euclidean matrix
distance for6 ooints.
For the single link or MIN version of hierarchical clustering, the proximity
of two clusters is defined as the minimum of the distance (maximum of the
similarity) between any two points in the two different clusters. Using graph
terminology, if you start with all points as singleton clusters and add links
between points one at a time, shortest links first, then these single links com-
bine the points into clusters. The single link technique is good at handling
non-elliptical shapes,but is sensitive to noise and outliers.
Example 8.4 (Single Link). Figure 8.16 shows the result of applying the
single link technique to our example data set of six points. Figure 8.16(a)
shows the nested clusters as a sequenceof nested ellipses,where the numbers
associatedwith the ellipsesindicate the order of the clustering. Figure S.16(b)
shows the same information, but as a dendrogram. The height at which two
clusters are merged in the dendrogram reflects the distance of the two clusters.
For instance, from Table 8.4, we see that the distance between points 3 and 6
52O Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
Figure
8.16,Single ofthesixpoints
linkclustering shown
inFigure
8.15.
is 0.11, and that is the height at which they are joined into one cluster in the
dendrogram. As another example, the distance between clusters {3,6} and
{2,5} is given by
, ,5}) :
d i , s t ( { 3 , 6 {} 2 min(dest(3,2),di,st(6,2),di,st(3,5),di,st(6,5))
min(O.
15,0.25,0.28,0.39)
0.15.
For the complete link or MAX version of hierarchical clustering, the proximity
of two clusters is defined as the maximum of the distance (minimum of the
similarity) between any two points in the two different clusters. Using graph
terminology, if you start with all points as singleton clusters and add links
between points one at a time, shortest links first, then a group of points is
not a cluster until all the points in it are completely linked, i.e., form a clique.
Complete link is less susceptible to noise and outliers, but it can break large
clusters and it favors globular shapes.
Example 8.5 (Complete Link). Figure 8.17 shows the results of applying
MAX to the sample data set of six points. As with single link, points 3 and 6
8.3 Agglomerative Hierarchical Clustering 521
36412
Figure
8.17.Complete ofthesixpoints
linkclustering inFigure
shown 8.15.
are merged first. However,{3,6} is merged with {4}, instead of {2,5i or {1}
because
Group Average
For the group average version of hierarchical clustering, the proximity of two
clusters is defined as the average pairwise proximity among all pairs of points
in the different clusters. This is an intermediate approach between the single
and complete link approaches. Thus, for group average, the cluster proxim-
522 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
0.1
364251
Figure8.18.Groupaverage ofthesixpoints
clustering shownin Figure
8.15.
ity prori,mi,ty(Ci,Ci) of clusters C,i and Cr', which are of size mi and mi,
respectively, is expressed by the following equation:
\*.co Prori'mitY(x,Y)
r€ci
prori,mi.ty(Cr,C) : . (8.6)
rni * mj
Example 8.6 (Group Average). Figure 8.18showsthe resultsof applying
the group averageapproachto the sampledata set of six points. To illustrate
how group averageworks, we calculatethe distancebetweensomeclusters.
d i s t ( { 3 , 6 , 4 }{,i } ) : ( 0 . 2 2+ 0 . 3 7+ 0 . 2 3 ) / ( 3x t )
: 0.28
di,st({2,5},{1}) : (0.2357 + 03a21)l(2 * I)
: 0.2889
d i , s t ( { 3 , 6 , 4 } , { 2 , 5 } ): ( 0 . 1 5+ 0 . 2 8+ 0 . 2 5+ 0 . 3 9+ 0 . 2 0+ 0 . 2 9 ) l ( 6* 2 )
: 0.26
Figure8.19.Ward's ofthesixpoints
clustering shownin Figure
8.15.
For Ward's method, the proximity between two clusters is defined as the in-
creasein the squared error that results when two clusters are merged. Thus,
this method uses the same objective function as K-means clustering. While
it may seem that this feature makes Ward's method somewhat distinct from
other hierarchical techniques, it can be shown mathematically that Ward's
method is very similar to the group average method when the proximity be-
tween two points is taken to be the square of the distance between them.
Example 8.7 (Ward's Method). Figure 8.19 shows the results of applying
Ward's method to the sample data set of six points. The clustering that is
produced is different from those produced by single link, complete link, and
group average. r
Centroid methods calculate the proximity between two clusters by calcu-
lating the distance between the centroids of clusters. These techniques may
seem similar to K-means, but as we have remarked, Ward's method is the
correct hierarchical analog.
Centroid methods also have a characteristic----often considered bad-that
is not possessedby the other hierarchical clustering techniques that we have
discussed: the possibility of inversions. Specifically, two clusters that are
merged may be more similar (less distant) than the pair of clusters that were
merged in a previous step. For the other methods, the distance between
524 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
Table8.5.Table
of Lance-Williams
coefficients hierarchical
forcommon clustering
approaches.
Clustering Method Q.A 0.B, /'l 'l
Any of the cluster proximities that we have discussedin this section can be
viewed as a choice of different parameters (in the Lance-Williams formula
shown below in Equation 8.7) for the proximity between clusters Q and R,
where,R is formed by merging clusters A and B. In this equation, p(.,.) is
a proximity function, while rn4, mB, and me are the number of points in
clusters A, B, and Q, respectively. In other words, after we merge clusters A
and B to form cluster .8, the proximity of the new cluster, ft, to an existing
cluster, Q, is a linear function of the proximities of Q with respect to the
original clusters A and B. Table 8.5 shows the values of these coefficientsfor
the techniques that we have discussed.
step, which clusters should be merged (or split for divisive approaches). This
approach yields clustering algorithms that avoid the difficulty of attempting
to solve a hard combinatorial optimization problem. (It can be shown that
the general clustering problem for an objective function such as "minimize
SSE" is computationally infeasible.) Furthermore, such approaches do not
have problems with local minima or difficulties in choosing initial points. Of
course,the time complexity of O(m2log m) and the spacecomplexity of O(m2)
are prohibitive in many cases.
One aspect of agglomerative hierarchical clustering that we have not yet dis-
cussedis how to treat the relative sizesof the pairs of clusters that are merged.
(This discussionapplies only to cluster proximity schemesthat involve sums,
such as centroid, Ward's, and group average.) There are two approaches:
weighted, which treats all clusters equally, and unweighted, which takes
the number of points in each cluster into account. Note that the terminology
of weighted or unweighted refers to the data points, not the clusters. In other
words, treating clusters of unequal size equally gives different weights to the
points in different clusters, while taking the cluster size into account gives
points in different clusters the same weight.
We will illustrate this using the group averagetechnique discussedin Sec-
tion 8.3.2, which is the unweighted version of the group average technique.
In the clustering literature, the full name of this approach is the Unweighted
Pair Group Method using Arithmetic averages(UPGMA). In Table 8.5, which
gives the formula for updating cluster similarity, the coefficientsfor UPGMA
involve the size of each of the clusters that were merged:.aA: *ffi,(tB :
,"ffi,0:0,?:0. For the weighted versionof group average-known as
WPGMA-the coefficientsare constants:aa: Lf 2,aB : L12,P: 0,7 : 0.
In general, unweighted approachesare preferred unless there is reason to be-
lieve that individual points should have different weights; e.g., perhaps classes
of objects have been unevenly sampled.
For example, although the "minimize squared error" criterion from K-means
is used in deciding which clusters to merge in Ward's method, the clusters at
each level do not represent local minima with respect to the total SSE. Indeed,
the clusters are not even stable, in the sensethat a point in one cluster may
be closer to the centroid of some other cluster than it is to the centroid of its
current cluster. Nonetheless,Ward's method is often used as a robust method
of initializing a K-means clustering, indicating that a local "minimize squared
error" objective function does have a connection to a global "minimize squared
error" objective function.
There are some techniques that attempt to overcome the limitation that
merges are final. One approach attempts to fix up the hierarchical clustering
by moving branches of the tree around so as to improve a global objective
function. Another approach uses a partitional clustering technique such as K-
means to create many small clusters, and then performs hierarchical clustering
using these small clusters as the starting point.
8.4 DBSCAN
Density-based clustering locates regions of high density that are separated
from one another by regions of low density. DBSCAN is a simple and effec-
tive density-basedclustering algorithm that illustrates a number of important
conceptsthat are important for any density-basedclustering approach. In this
section, we focus solely on DBSCAN after first considering the key notion of
density. Other algorithms for finding density-based clusters are described in
the next chapter.
8.4 DBSCAN 527
Although there are not as many a,pproachesfor defining density as there are for
defining similarity, there are several distinct methods. In this section we dis-
cuss the center-basedapproach on which DBSCAN is based. Other definitions
of density will be presented in Chapter 9.
In the center-basedapproach, density is estimated for a particular point in
the data set by counting the nurnber of points within a specified radius, .Eps,
of that point. This includes the point itself. This technique is graphically
illustrated by Figure 8.20. The number of points within a radius of Eps of
point A is 7, including A itself.
This method is simple to irnplement, but the density of any point will
depend on the specified radius. For instance, if the radius is large enough,
then all points will have a density of rn, the number of points in the data set.
Likewise, if the radius is too small, then all points will have a density of 1.
An approach for deciding on ther appropriate radius for low-dimensional data
is given in the next section in the context of our discussionof DBSCAN.
Border points: A border point is not a core point, but falls within the neigh-
borhood of a core point. In Figure 8.21, point B is a border point. A
border point can fall within the neighborhoods of several core points.
Noise points: A noise point is any point that is neither a core point nor a
border point. In Figure 8.21, point C is a noise point.
528 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
core point
Figure8.20. Center-based
density. Figure
8.21.Core, points.
andnoise
border,
Given the previous definitions of core points, border points, and noise points,
the DBSCAN algorithm can be informally described as follows. Any two core
points that are close enough-within a distance Eps of one another-are put
in the same cluster. Likewise, any border point that is close enough to a core
point is put in the same cluster as the core point. (Ties may need to be resolved
if a border point is close to core points from different clusters.) Noise points
are discarded. The formal details are given in Algorithm 8.4. This algorithm
uses the same concepts and finds the same clusters as the original DBSCAN,
but is optimized for simplicity, not efficiency.
The basic time complexity of the DBSCAN algorithm is O(m x time to find
points in the -Eps-neighborhood),where rn is the number of points. In the
worst case, this complexity is O(^'). However, in low-dimensional spaces,
there are data structures, such as kd-trees, that allow efficient retrieval of all
8.4 DBSCAN 529
points within a given distance of a specified point, and the time complexity
can be as low as O(mlogm). The space requirement of DBSCAN, even for
high-dimensional data, is O(m) because it is only necessaryto keep a small
amount of data for each point, i.e., the cluster label and the identification of
each point as a core, border, or noise point.
There is, of course, the issue of how to determine the parameters Eps and
MinPts. The basic approach is to look at the behavior of the distance from
a point to its kth nearest neighbor, which we will call the k-dist. For points
that belong to some cluster, the value of k-dist will be small if k is not larger
than the cluster size. Note that there will be some variation, depending on the
density of the cluster and the r:r,ndomdistribution of points, but on average,
the range of variation will not be huge if the cluster densities are not radically
different. However, for points that are not in a cluster, such as noise points,
the k-dist will be relatively large. Therefore, if we compute the k-dist for
all the data points for some ,k, sort them in increasing order, and then plot
the sorted values, we expect to see a sharp change at the value of k-dist that
correspondsto a suitable value of Eps. lf we select this distance as the Eps
parameter and take the value oi k as the MinPts parameter, then points for
which ,k-dist is less than -Opswill be labeled as core points, while other points
will be labeled as noise or borderrpoints.
Figure 8.22 shows a sample data set, while the k-dist graph for the data is
given in Figure 8.23. The value of Eps that is determined in this way depends
on k, but does not change dramatically as k changes. If the value of k is too
small, then even a small number of closely spaced points that are noise or
outliers will be incorrectly labeled as clusters. If the value of k is too large,
then small clusters (of size less than k) are likely to be labeled as noise. The
original DBSCAN algorithm used a value of k : 4, which appears to be a
reasonablevalue for most two-dimensional data sets.
DBSCAN can have trouble with density if the density of clusters varies widely.
Consider Figure 8.24, which shows four clusters embedded in noise. The den-
sity of the clusters and noise regions is indicated by their darkness. The noise
around the pair of denser clusters, A and B, has the same density as clusters
C and D. If the -Eps threshold is low enough that DBSCAN finds C and D as
clusters, then A and B and the points surrounding them will become a single
530 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
z
6
Figure data.
8.22.Sample Figure8,23.K-distplotforsample
data.
Figure8.24.Fourclusters in noise.
embedded
An Example
To illustrate the use of DBSCAN, we show the clusters that it finds in the
relatively complicated two-dimensional data set shown in Figure 8.22. This
data set consists of 3000 two-dimensional points. The Eps threshold for this
data was found by plotting the sorted distancesofthe fourth nearest neighbor
of each point (Figure 8.23) and identifying the value at which there is a sharp
increase. We selected Eps :10, which correspondsto the knee of the curve.
The clusters found by DBSCAN using these parameters, i.e., Mi,nPts: 4 and
Eps : 10, are shown in Figure 8.25(a). The core points, border points, and
noise points are displayed in Figure 8.25(b).
I xxX Ix x
XX
X
f XX
'i+
X
X I X
,j
1 i+-I+.tJtlr,
I
f
la X
X
X
""t
x X
X
X
X
*.
"1 x
X
r trX
€
I
X
i.
X
Figure8.25,DBSCAN
clustering points.
of3000two-dimensional
532 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
DBSCAN can find many clusters that could not be found using K-means,
such as those in Figure 8.22. As indicated previously, however, DBSCAN has
trouble when the clusters have widely varying densities. It also has trouble
with high-dimensional data becausedensity is more difficult to define for such
data. One possible approach to dealing with such issues is given in Section
9.4.8. Finally, DBSCAN can be expensive when the computation of nearest
neighbors requires computing all pairwise proximities, as is usually the case
for high-dimensional data.
8.5.1 Overview
3. Evaluating how well the results of a cluster analysis fit the data wi,thout
referenceto external information.
Notice that items L, 2, and 3 do not make use of any external information-
they are unsupervised techniques while item 4 requires external information.
Item 5 can be performed in either a supervised or an unsupervised manner. A
further distinction can be made with respect to items 3, 4, and 5: Do we want
to evaluate the entire clustering or just individual clusters?
While it is possible to deverlop various numerical measures to assessthe
different aspects of cluster validity mentioned above, there are a number of
challenges. First, a measure of cluster validity may be quite limited in the
scope of its applicability. For example, most work on measures of clustering
tendency has been done for two- or three-dimensional spatial data. Second,
we need a framework to interprr:t any measure. If we obtain a value of 10 for a
measurethat evaluateshow well cluster labels match externally provided class
labels, does this value represent a good, fair, or poor match? The goodness
of a match often can be measured by looking at the statistical distribution of
this value, i.e., how likely it is that such a value occurs by chance. Finally, if
a measure is too complicated to apply or to understand, then few will use it.
The evaluation measures, or indices, that are applied to judge various
aspects of cluster validity are traditionally classified into the following three
types.
534 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
o V
oo o a VVYV
a ao a VV
Oa VVV
o oo V VV
ao
a
o v vV
v v
1O ao
yY
V Yv
oo to O
VV
Y' Y
tt. a OO
V VY
tt y VV
3 o 'ti. O-
r o YVV v
oO vvv ttg
oo ' a o t vwvv
vv t
1O o V VV
a o *
o .a
oot a x xtur
10 a o ** x
ooor ****
a I
!. t ;o a
a o ***
y* * *
I
I
oo o o oo ** * ta
, I
o
OO
* *
*x * ** * x
ooo ** * ,(* * *)( *
* 'K * t(
l lo
* )( *.*x * *
)K. *
* *
I
1O * 4*
;{<.
* *
a
o )( * x* *
** * ** x**
x' * 4*
3tt. a * )'( **. ... *
a o x*
**.
x * i *
#
oo o g* )K *oo *
**
o VY * oo
o * v O
o v! *Y v$
yV yV
Y o
V Vvv .Y
Y
VV Y
Y
V'
v
V
Y V
Y' YV
VY
r.':. a
o O o
vv VV o oo
V
v oo a
(c) Three clusters found by K-means. (d) Three clusters found by complete
Figure8.26.Clustering
of 100uniformly points.
distributed
8.5 Cluster Evaluation 535
K
oueralluatidi,ty: t wi uali,d,i,ty(C.i). (8.8)
t:l
Figure viewofcluster
8.27.Graph-based cohesion
andseparation.
cohesion(Ci) :
\ pro.rimilg(x,ci) (8.11)
xeLt
Figure8.28,Prototype-based
viewof cluster andseparation.
cohesion
in Equation 8.8. However, we need to decide what weights to use. Not sur-
prisingly, the weights used can vary widely, although typically they are some
measure of cluster size.
Table 8.6 provides examples of validity measuresbased on cohesion and
separation. Iy is a measure of cohesion in terms of the pairwise proximity of
objects in the cluster divided by the cluster size. 12 is a measure of cohesion
based on the sum of the proximities of objects in the cluster to the cluster
centroid. t1 is a measure of separation defined as the proximity of a cluster
centroid to the overall centroid multiplied by the number of objects in the
cluster. 9t, which is a measure based on both cohesion and separation, is
the sum of the pairwise proximity of all objects in the cluster with all objects
outside the cluster-the total weight of the edgesof the proximity graph that
must be cut to separate the cluster from all other clusters-divided bv the
sum of the pairwise proximity of objects in the cluster.
Table ofgraph-based
8.6.Table cluster measures.
evaluation
Name Cluster Measure Cluster Weisht Type
graph-based
a I
L7
mi
cohesion
prototype-based
,7.
L2 D*ect Pr ori'mi'tY(x, c 1) I cohesion
prototype-based
c
u'l prorzmity(ci,c) mi separation
graph-based
sk
9t Ii .l D l:: , ProtimitY(x.Y D;:g; Prori,mits(x,Y) separation and
Jc"J
cohesion
8.5 Cluster Evaluation 539
clusterssE: I :
dtrt1"6,*)2 d,tst(x,y)2 (8.14)
-""1 D
r^L I
xeCi xQCay€Ci
equal, i.e., mi : m I K , then this relationship takes the simple form given by
Equation 8.16. (SeeExercise 28 on page 566.) It is this type of equivalencethat
motivates the definition of prototype separation in terms of both Equations
8 . 1 2a n d 8 . 1 3 .
1KK
T o taSl S B: + t, dist( c;.ci) 2 (8.16)
2 K ?r -?t ' x r y
l= I
K
TSS \-
ZJ
\-
Zr
(* - ,)'
reu
t \-
/J
TE L;
((" -
"n)
- (r-
"n))'
K KK
(* - ro)'- 2DI (" - -",) l k - "u)'
"o)(" + D
\-
Z-/ /\-
reC ?:I JEU): i:7 r€Ct
K K
t
i:L
- -
D (" "n)'+Dlcil(c c)2
r€C;
SSE+ SSB
8.5 Cluster Evaluation 54L
So far, we have focused on using cohesion and separation in the overall eval-
uation of a group of clusters. Many of these measuresof cluster validity also
can be used to evaluate individual clusters and objects. For example, we can
rank individual clusters according to their specific value of cluster validity, i.e.,
cluster cohesion or separation. A cluster that has a high value of cohesion may
be considered better than a clutter that has a lower value. This information
often can be used to improve the quality of a clustering. If, for example, a
cluster is not very cohesive,then we may want to split it into several subclus-
ters. On the other hand, if two clusters are relatively cohesive,but not well
separated, we may want to merge them into a single cluster.
We can also evaluate the objects within a cluster in terms of their con-
tribution to the overall cohesion or separation of the cluster. Objects that
contribute more to the cohesion and separation are near the "interior" of the
cluster. Those objects for which the opposite is true are probably near the
"edge" of the cluster. In the following section, we consider a cluster evalua-
tion measure that uses an approach based on these ideas to evaluate points,
clusters, and the entire set of clusters.
1. For the ith object, calculate its average distance to all other objects in
its cluster. Call this value a;.
2. For the i,th object and any cluster not containing the object, calculate
the object's averagedistance to all the objects in the given cluster. Find
the minimum such value with respect to all clusters; call this value b.;.
3. For the i,th object, the silhouette coefficient is s; : (b'i- a.i)f rnax(ai,b1).
e :t,,ti'tt r:,;:!:1:i
zu
"i-'11,.,,
;I'ir,'irr', -
et$&s di r" t, :i;,f{,e
* 4#F*
o
* It
,,ti l:i* s ..d{-.*4 "'" :"j:r,
s ".tiii:
gr:'ri:i:*b + i-:Y,$ f.i,:i,.r:,bs.
, r;- "l'+*-I
'u ti'u,in*
o 01 02 03 07 08 oe 1
:,lr**,"0:*n.,:":
Figure8.29.Silhouette forpointsintenclusters.
coefficients
If we are given the similarity matrix for a data set and the cluster labels from
a cluster analysis of the data set, then we can evaluate the "goodness" of
the clustering by looking at the correlation between the similarity matrix and
an ideal version of the similarity matrix based on the cluster labels. (With
minor changes,the following applies to proximity matrices, but for simplicity,
we discuss only similarity matrices.) More specifically, an ideal cluster is one
whose points have a similarity of 1 to all points in the cluster, and a similarity
of 0 to all points in other clusters. Thus, if we sort the rows and columns
of the similarity matrix so that all objects belonging to the same class are
together, then an ideal similarity matrix has a block diagonal structure. In
other words, the similarity is non-zero, i.e., 1, inside the blocks of the similarity
8.5 Cluster Evaluation 543
Similarity
Figure8.30.Similarity
matrix
forwell-separated
clusters.
matrices
Figure8.31.Similarity fromrandom
forclusters data.
nique puts the objects in the same cluster for the first time. For example, if at
some point in the agglomerative hierarchical clustering process, the smallest
distance between the two clusters that are merged is 0.1, then all points in
one cluster have a cophenetic clistanceof 0.1 with respect to the points in the
other cluster. In a cophenetic distance matrix, the entries are the cophenetic
distances between each pair of objects. The cophenetic distance is different
for each hierarchical clustering of a set of points.
Example 8.L1- (Cophenetic Distance Matrix). Table 8.7 showsthe cophen-
tic distance matrix for the single link clustering shown in Figure 8.16. (The
data for this figure consists of the 6 two-dimensional points given in Table
8.3.)
distance
Table8.7. Cophenetic forsinglelinkanddataintable8.3
matrix
Point P1 P2 P3 P4 P5 P6
P1 0 0.222 0.222 0.222 0.222 0.222
P2 0.222 0 0.148 0 . 1 5 r 0.139 0.148
P3 0.222 0.148 0 0 . 1 5 1 0.148 0.110
P4 0.222 0.151 0.151 0 0.151 0.151
P5 0.222 0.139 0.148 0.151 0 0.148
P6 0.222 0.148 0 . 11 0 0 . 1 5 1 0.148 0
Table8.8. Cophenetic
correlation
coefficient
fordataofTable8.3andfouragglomerative
hierarchical
clustering
techniques.
Technique CPCC
Single Link 0.44
Complete Link 0.63
Group Average 0.66
Ward's 0.64
055
o
05
a 045
04
035
03
051015202530 051015202530
Numberof Clusters Numberof ClusteF
Figure
8.32,SSEversusnumber
ofclusters
for 8.33.Average
Figure silhouette ver-
coefficient
thedataofFigure
8.29. susnumber forthedataof Figure
of clusters
8.29,
One obvious way to determine if a data set has clusters is to try to cluster
it. However, almost all clusterirrg algorithms will dutifully find clusters when
given data. To addressthis issue,we could evaluate the resulting clusters and
only claim that a data set has clusters if at least someof the clusters are of good
quality. However, this approactr does not address the fact the clusters in the
data can be of a different type than those sought by our clustering algorithm.
To handle this additional problem, we could use multiple algorithms and again
evaluate the quality of the resulting clusters. If the clusters are uniformly poor,
then this may indeed indicate that there are no clusters in the data.
Alternatively, and this is the focus of measuresof clustering tendency, we
can try to evaluate whether a data set has clusters without clustering. The
most common approach, especially for data in Euclidean space, has been to
use statistical tests for spatial randomness. Unfortunately, choosing the cor-
rect model, estimating the parameters, and evaluating the statistical signifi-
cance of the hypothesis that the data is non-random can be quite challenging.
Nonetheless,many approaches have been developed, most of them for points
in low-dimensional Euclidean space.
Exarnple 8.14 (Hopkins Statistic). For this approach,we generateppoints
that are randomly distributed acrossthe data space and also sample p actual
548 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
data points. For both sets of points we find the distance to the nearest neigh-
bor in the original data set. Let theui be the nearest neighbor distancesofthe
artificially generated points, while the ui are the nearest neighbor distances
of the sample of points from the original data set. The Hopkins statistic fI is
then defined by Equation 8.17.
H- DT:t.t (8.17)
+ Dl:twt
D,Pl:rut,
If the randomly generated points and the sample of data points have
roughly the same nearest neighbor distances, then 11 will be near 0.5. Values
of fI near 0 and 1 indicate, respectively, data that is highly clustered and
data that is regularly distributed in the data space. To give an example, the
Hopkins statistic for the data of Figure 8.26 was computed for p : 20 and 100
different trials. The average value of 11 was 0.56 with a standard deviation
of 0.03. The same experiment was performed for the well-separatedpoints of
Figure 8.30. The average value of fI was 0.95 with a standard deviation of
0.006. r
There are a number of measures entropy, purity, precision, recall, and the
F-measure that are commonly used to evaluate the performance of a classi-
fication model. In the case of classification?we measure the degree to which
predicted class labels correspond to actual class labels, but for the measures
just mentioned, nothing fundamental is changed by using cluster labels in-
stead of predicted classlabels. Next, we quickly review the definitions of these
measures,which were discussedin Chapter 4.
Entropy: The degreeto which each cluster consistsof objects of a single class.
For each cluster, the class distribution ofthe data is calculated first, i.e.,
for cluster jl we compute pU, the probability that a member of cluster ri
belongs to classj as pU : mt j /mt, where mi is the number of objects in
cluster i, and mii is the number of objects of class j in cluster i. Using
this class distribution, the entropy of each cluster ri is calculated using
the standard formula, €i == -Di-tptilogzptj, where tr is the number of
classes. The total entropy for a set of clusters is calculated as the sum
of the e_ntropiesof each cluster weighted by the size of each cluster, i.e.,
e : DLtffei, where 1{ is the number of clusters and rn is the total
number of data points.
Tabfe8.9. K-means
clustering
results
fortheLATimes
document
dataset.
Cluster Enter- Financial Foreign Metro National Sports Entropy Purity
tainment
1 3 K
40 506 96 27 r.2270 0.7474
2 4 7 280 29 39 2 1.1472 0.7756
.-) 1 1 I 7 4 677 0 . 1 8 1 3 0.9796
4 10 r62 ,f119 IJ 2 r.7487 0.4390
r r
331 22 70 IJ 23 1.3976 0.7134
o ( 358 12 2r2 48 IJ r.5523 0.5525
Total D<A
cDo 34r 943 273 738 1.1450 0.7203
The measures that we discuss in this section are all based on the premise
that any two objects that are in the same cluster should be in the same class
and vice versa. We can view this approach to cluster validity as involving
the comparison of two matrices: (1) the ideal cluster similarity rnatrix
discussedpreviously, which has a 1 in the i,jth entry if two objects, i. and j,
are in the same cluster and 0, otherwise, and (2) an ideal class similarity
matrix defined with respect to class labels, which has a 1 in the i,jth entry if
8.5 Cluster Evaluation 551
Table
8.10.ldeal
cluster matrix.
similaritv Table
8.11.ldeal
class matrix.
similariW
Point pl p2 p3 p4 p5 Point p1 p2 p3 p4 p5
p1 11100 p1 11000
p2 11100 p2 11000
p3 11100 p3 00111
p4 00011 p4 00111
p5 00011 p5 00111
More generally, we can use any of the measures for binary similarity that
we sav/ in Section 2.4.5. (For erxample,we can convert these two matrices into
binary vectors by appending the rows.) We repeat the definitions of the four
quantities used to define those similarity measures,but modify our descriptive
text to fit the current context. Specifically,we need to compute the following
four quantities for all pairs of distinct objects. (There are m(m - I) 12 stch
pairs, if m is the number of objects.)
,foo: number of pairs of objects having a different class and a different cluster
.for : number of pairs of objects having a different class and the same cluster
,fio : number of pairs of objects having the same class and a different cluster
.fir : number of pairs of objects having the same class and the same cluster
foo-l ft
Rand statistic : (8.18)
,foo* "for-l frc -l fn
552 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
.l1r
Jaccard coefficient : ( 8.1e)
fot -t fn'l ft
Example 8.17 (Rand and Jaccard Measures). Based on these formulas,
we can readily compute the Rand statistic and Jaccard coefficient for the
examplebasedon Tables8.10and 8.11. Noting that foo: 4, fot:2, frc:2,
and /rr : 2, the Rand statistic : (2 + 4) 110: 0.6 and the Jaccard coefficient
:2lQ+2+2):0.33. r
We also note that the four quantities, foo, fot, fis, and fi1, define a con-
t'ingency table as shown in Table 8.12.
Table8.12.Two-way tablefordetermining
contingency pairsof objects
whether areinthesameclass
andsamecluster.
Same Cluster Different Cluster
Same Ulass .t17 Iro
Diflerent Class .l07 ./ 00
S- 7Zl
F-
z
where the maximum is taken over all clusters z at all levels, m1 is the number
of objects in classj, and rn is the total number of objects.
50
Figure8.34.Histogram
of SSEfor500random
datasets.
the points in the three clusters, find three clusters in each data set using K-
means, and accumulate the distribution of SSE values for these clusterings. By
using this distribution of the SSE values, we can then estimate the probability
of the SSE value for the original clusters. Figure 8.34 shows the histogram of
the SSE from 500 random runs. The lowest SSE shown in Figure 8.34 is 0.0173.
For the three clusters of Figure 8.30, the SSE is 0.0050. We could therefore
conservativelyclaim that there is less than a I%ochancethat a clustering such
as that of Figure 8.30 could occur by chance. r
To conclude, we stressthat there is more to cluster evaluation-supervised
or unsupervised than obtaining a numerical measure of cluster validity. Un-
lessthis value has a natural interpretation based on the definition of the mea-
sure, we need to interpret this value in some way. If our cluster evaluation
measure is defined such that lower values indicate stronger clusters, then we
can use statistics to evaluate whether the value we have obtained is unusually
low, provided we have a distribution for the evaluation measure. We have pre-
sented an example of how to find such a distribution, but there is considerably
more to this topic, and we refer the reader to the bibliographic notes for more
pointers.
Finally, even when an evaluation measure is used as a relative measure,
i.e., to compare two clusterings, we still need to assessthe significancein the
difference between the evaluation measuresof the two clusterings. Although
one value will almost always be better than another, it can be difficult to
determine if the difference is significant. Note that there are two aspects to
this significance: whether the differenceis statistically significant (repeatable)
8.6 BibliographicNotes 555
and whether the magnitude of the differenceis meaningful with respect to the
application. Many would not regard a differenceof 0.1% as significant, even if
it is consistently reproducible.
Bibliography
f3731 M. S. Aldenderfer and R. K. Blashfield. Cluster Analysr,s. Sage Publications, Los
Angeles, 1985
[374] M. R. Anderberg. Cluster Analysis for Appli.cati,ons. Academic Press, New York,
December 1973.
Bibliography 557
13751M. Ankerst, M. M. Breunig, H.-P. Kriegel, and J. Sander. OPTICS: Ordering Points
To Identify the Clustering Structure. In Proc. of 1999 ACM-SIGMOD Intl. Conf. on
Managementof Data, pages49 60, Philadelphia,Pennsylvania,June 1999.ACM Press.
[376] P. Arabie, L. Hubert, and G. D. Soete. An overviewof combinatorialdata analysis.
In P. Arabie, L. Hubert, and G. D. Soete,editors, Clusteri,ngand Classifi,cation,
pages
188 2L7.World Scientific,Singapore,January 1996.
13771
G. Ball and D. Hall. A Clustering Technique for Summarizing Multivariate Data.
Behauior Sc'ience,12:153-155,March 1967.
[378]A. Banerjee, S. Merugu, I. S. Dhillon, and J. Ghosh. Clustering with Bregman Diver-
gences. In Proc. of the 2001 SIaIM Intl. Conf. on Data M'ini,ng, pages 234 245, Lake
Buena Vista, FL, April 2004.
[37e]P. Berkhin. Survey Of Clusterirrg Data Mining Techniques. Technical report, Accrue
Software. San Jose. CA. 2002.
[380]D. Boley. Principal Direction Divisive Partitioning. Data Mi,ni.ng and Knowledge
Discouery, 2(4):325-344, 1998.
P. S. Bradley and U. M. Fayyad. Refining Initial Points for K-Means Clustering. In
Proc. of the 15th Intl. Conf. on Machine Learni,ng, pages 91 99, Madison, WI, July
1998. Morgan Kaufmann Publishers Inc.
[382] C L U T O 2 . I . 7 : Software for Ciustering High-Dimensional Datasets.
/www.cs.umn.edu/-61ypis, November 2003.
[383] L S. Dhillon, Y. Guan, and J. Kogan. Iterative Clustering of High Dimensional Text
Data Augmented by Local Search In Proc. of the 2002 IEEE Intl. Conf. on Data
Mining, pages 131 138. ItrEE Computer Society, 2002
I. S. Dhillon and D. S. Modha. Concept Decompositions for Large Sparse Text Data
Using Clustering. M ach'ine Learn,,ing,a2Q I 2) :1a3 I75, 2001.
13851 R. O. Duda, P. E. Hart, and D. G. Stork. Pattern Classi.ficati,on John Wiley & Sons,
Inc., New York, second edition, 2001.
13861 M. Ester, H.-P. Kriegel, J. Sander, M. Wimmer, and X. Xu. Incremental Clustering
for Mining in a Data Warehousing Environment In Proc. of the 2/1th VLDB Conf.,
pages 323 333, New York City, August 1998. Morgan Kaufmann.
13871 M. Ester, H.-P. Kriegel, J. Sander, and X. Xu. A Density-Based Algorithm for Dis-
covering Clusters in Large Spatial Databases with Noise. In Proc. of the Znd Intl. Conf.
on Knowledge Discouery and Data M'in'ing, pages 226 231, Portland, Oregon, August
1996. AAAI Press.
[388] B. S. trveritt, S. Landau, and M. Leese. Cluster Analysis. Arnold Publishers, London,
fourth edition, May 2001.
l38elD. Fisher. Iterative Optimization and Simplification of Hierarchical Clusterings. -/ozr-
naL of Artif"cial Intelli,gence Research, 4:147-179, 1996.
M. Halkidi, Y. Batistakis, and M Vazirgiannis. Cluster validity methods: part L
SIGMOD Record (ACM Speci,alInterest Group on Management of Data),31(2):40 45,
June 2002.
M. Halkidi, Y. Batistakis, and N{. Vazirgiannis. Clustering validity checking methods:
part II. SIGMOD Record (ACM Special Interest Group on Managernent of Data), 3L
(3):19-27, Sept. 2002.
1392] G. Hamerly and C. trlkan. Alternatives to the k-means algorithm that find better
clusterings. In Proc. of the 1lth IntI. Conf . on Informat'ion and Knowledge Management,
pages 600 607, Mclean, Virginia, 2002. ACM Press.
558 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
[393] J. Han, M. Kamber, and A. Tirng. Spatial Clustering Methods in Data Mining: A
review. In H. J. Miller and J. Han, editors, Geographi'cData Mining and Knowledge
Discouery, pages 188-217. Taylor and Francis, London, December 2001.
[394] J. Hartigan. Clusteri,ng Algorithms. Wiley, New York, 1975.
[395] T. Hastie, R. Tibshirani, and J. H. Friedman. The Elements of Statistical Learning:
Data Mini,ng, Inference, Predi,ct'ion.Springer, New York, 2001.
f396] A. K. Jain and R. C. Dubes. Algorithms for Clustering Data. Prentice Hall
Advanced Reference Series. Prentice Hall, March 1988. Book available online at
http: / /www.cse. msu.edu/ -j ain/ Clustering-Jain-Dubes. pdf .
[397] A. K. Jain, M. N. Murty, and P. J. Flynn. Data clustering: A review. ACM Computing
Surueys,3L(3):26a 323, September 1999.
[398] N. Jardine and R. Sibson. Mathemat'ical Tanonomg. Wiley, New York, 1971.
13991G. Karypis, E.-H. Han, and V. Kumar. Multilevel Refinement for Hierarchical CIus-
tering. Technical Report TR 99-020, University of Minnesota, Minneapolis, MN, 1999.
[400] L. Kaufman and P. J. Rousseeuw. Find,ing Groups i,n Data: An Introducti,on to Cluster
Analgsi,s. Wiley Series in Probability and Statistics. John Wiley and Sons, New York,
November 1990.
[401] J. M. Kleinberg. An Impossibility Theorem for Clustering. ln Proc. of the 16th Annual
Conf. on Neural Informat'ion Processi.ng Systems, December, I 142002.
[402] B. Larsen and C. Aone. Fast and Effective Text Mining Using Linear-Time Document
Clustering. In Proc. of the 5th IntI. Conf. on Knowledge Discouery and Data M'ining,
pages 16-22, San Diego, California, 1999. ACM Press.
[403] J. MacQueen. Some methods for classification and analysis of multivariate observa-
tions. In Proc. of the Sth Berkeleg Sgmp. on Mathernatical Stati,sti,cs and, Probabi,Iitg,
pages 281-297. University of California Press, 1967.
1404] G. W. Milligan. Clustering Validation: Results and Implications for Applied Analyses.
In P. Arabie, L. Hubert, and G. D. Soete, editors, Clusteri,ng and Classif,cati,on,pages
345 375. World Scientific, Singapore, January 1996.
[405] B. Mirkin. Mathematical Classi,fication and Clustering, volume Il of Nonconuer Opti'-
mi:zati,onand Its Appli,cations. Kluwer Academic Publishers, August 1996.
[406] T. Mitchell. Machine Learning. McGraw-Hill, Boston, MA, 1997.
[407] F. Murtagh. Multidimensi.onal Clustering Algori.thms. Physica-Verlag, Heidelberg and
Vienna, 1985.
[408] D. Pelleg and A. W. Moore. X-means: Extending l(-means with Efficient Estimation
of the Number of Clusters. It Proc. of the 17th Intl. Conf. on Machine Learning, pages
727 734. Morgan Kaufmann, San Francisco, CA, 2000.
[409] C. Romesburg. Cluster Analysis for Researchers. Life Time Learning, Belmont, CA,
1984.
[410] J. Sander, M. Ester, H.-P. Kriegel, and X. Xu. Density-Based Clustering in Spatial
Databases: The Algorithm GDBSCAN and its Applications. Data M'ini,ng and"Knowl-
edgeDiscouery,2(2):169-194, 1998.
[411] S. M. Savaresi and D. Boley. A comparative analysis on the bisecting K-means and
the PDDP clustering algorithms. Intelligent Data Analysi.s, 8(4):345 362,2004.
14121P. H. A. Sneath and R. R. Sokal. Nurnerical Taronomg. Freeman, San Francisco, 1971.
f4131 H. Spd,th. Clusler Analgsi,s Algorithms for Data Red,uction and Classificati,on of Ob-
jecls, volume 4 of Computers and Thei,r Appli,cation. ElIis Horwood Publishers, Chich-
ester, 1980. ISBN 0-85312-14l-9.
8.7 Exercises 559
8.7 Exercises
1. Consider a data set consisting of 22o data vectors, where each vector has 32
components and each component is a 4-byte value. Suppose that vector quan-
tization is used for compression and that 216 prototype vectors are used. How
many bytes of storage does t;hat data set take before and after compression and
what is the compressionratio?
2. Find all well-separated clusl;ersin the set of points shown in Figure 8.35.
a
a a
oo
oo a'
a
a
a oo a
oo
oo ao
iigure8.35.Points
forExercise
2.
(a) PIot the probability of obtaining one point from each cluster in a sample
of size K for values of K between 2 and 100.
(b) For K clusters, K : 10,100, and 1000, find the probability that a sample
of size 21( contains at least one point from each cluster. You can use
either mathematical methods or statistical simulation to determine the
answer.
5. Identify the clusters in Figure 8.36 using the center-, contiguity-, and density-
based definitions. AIso indicate the number of clusters for each case and give
a brief indication of your reasoning. Note that darkness or the number of dots
indicates density. If it helps, assume center-based means K-means, contiguity-
based means sinsle link. and densitv-based means DBSCAN.
Figure8,36.Clusters 5.
forExercise
6. For the following sets of two-dimensional points, (1) provide a sketch of how
they would be split into clusters by K-means for the given number of clusters
and (2) indicate approximately where the resulting centroids would be. Assume
that we are using the squared error objective function. If you think that there
is more than one possible solution, then please indicate whether each solution
is a global or local minimum. Note that the label of each diagram in Figure
8.37 matches the corresponding part of this question, e.g., Figure 8.37(a) goes
with part (a).
(") K : 2. Assuming that the points are uniformly distributed in the circle,
how many possible ways are there (in theory) to partition the points
into two clusters? What can you say about the positions of the two
centroids? (Again, you don't need to provide exact centroid locations,
just a qualitative description.)
8.7 Exercises 561-
/tr-l-l']\ @-..*O
q#@(s@@ffift#
(a.) (b) (c) (d) (eJ
Figure
8.37.Diagrams
forExercise
6.
(b) 1( : 3. The distance between the edges of the circles is slightly greater
than the radii of the circles.
(") K : 3. The distance between the edges of the circles is much less than
the radii of the circles.
a\ K :2.
(e) 1( : 3. Hint: Use the symmetry of the situation and remember that we
are looking for a rough sketch of what the result would be.
For the given data set, which of the following should occur in order to minimize
the squared error when finding If clusters:
(a) Centroids should be equally distributed between more dense and less dense
regrons.
(b) More centroids should be allocated to the less dense region.
(c) More centroids should be allocated to the denser region.
Note: Do not get distracted by special cases or bring in factors other than
density. However, if you feel the true answer is different from any given above,
justify your response.
8 . Consider the mean of a cluster of objects from a binary transaction data set.
What are the minimum and maximum values of the components of the mean?
What is the interpretation of components of the cluster mean? Which compo-
nents most accurately charzr,cterizethe objects in the cluster?
9 . Give an example of a data set consisting of three natural clusters, for which
(almost always) K-means would likely find the correct clusters, but bisecting
K-means would not.
562 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
10. Would the cosine measure be the appropriate similarity measureto use with K-
means clustering for time series data? Why or why not? If not, what similarity
measure would be more appropriate?
1 1 . Total SSE is the sum of the SSE for each separateattribute. What does it mean
if the SSE for one variable is low for all clusters? Low for just one cluster? High
for all clusters? High for just one cluster? How could you use the per variable
SSE information to improve your clustering?
12. The leader algorithm (Hartigan 1394])represents each cluster using a point,
known as a leader, and assigns each point to the cluster corresponding to the
closest leader, unless this distance is above a user-specifiedthreshold. In that
case,the point becomesthe leader of a new cluster.
(a) What are the advantages and disadvantages of the leader algorithm as
compared to K-means?
(b) Suggest ways in which the leader algorithm might be improved.
1 3 The Voronoi diagram for a set of 1( points in the plane is a partition of all
the points of the plane into K regions, such that every point (of the plane)
is assigned to the closest point among the 1( specified points. (See Figure
8.38.) What is the relationship between Voronoi diagrams and K-means clus-
ters? What do Voronoi diagrams tell us about the possible shapes of K-means
clusters?
Figure8.38.Voronoi 13.
forExercise
diagram
L 4 . You are given a data set with 100 records and are asked to cluster the data.
You use K-means to cluster the data, but for all values of K, | < 1{ < 100,
the K-means algorithm returns only one non-empty cluster. You then apply
an incremental version of K-means, but obtain exactly the same result. How is
this possible? How would single link or DBSCAN handle such data?
r o . Traditional agglomerative hierarchical clustering routines merge two clusters at
each step. Does it seem likely that such an approach accurately captures the
8.7 Exercises 563
(nested) cluster structure of a set of data points? If not, explain how you might
postprocessthe data to obtain a more accurate view of the cluster structure.
1 6 . Use the similarity matrix in Table 8.13 to perform single and complete link
hierarchical clustering. Show your results by drawing a dendrogram. The den-
drogram should clearly show the order in which the points are merged.
Table8.13.Similarity
matrix
forExercise
16.
p1 ^t pr p4 p5
p1 1.00 0.10 0.41 0.55 0.35
p2 0.10 1.00 0.64 0.47 0.98
p3 0.41 0.64 1.00 0.44 0.85
p4 0.55 0.47 0.44 1.00 0.76
p5 0.35 0.98 0.85 0.76 1.00
(a) For each of the following sets of initial centroids, create two clusters by
assigning each point to the nearest centroid, and then calculate the total
squared error for each set of two clusters. Show both the clusters and the
total squared error for each set of centroids.
i. {18,45}
ii. {15,40}
(b) Do both sets of centroids represent stable solutions; i.e., if the K-means
algorithm was run on this set of points using the given centroids as the
starting centroids, would there be any change in the clusters generated?
(c) What are the two clusters produced by single link?
(d) Which technique, K-means or single link, seems to produce the "most
natural" clustering in this situation? (For K-means, take the clustering
with the lowest squared error.)
(e) What definition(s) of clustering does this natural clustering correspond
to? (Well-separated, center-based,contiguous, or density.)
(f) What well-known characteristic of the K-means algorithm explains the
previous behavior?
564 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
1 8 . Supposewe find K clusters using Ward's method, bisecting K-means, and ordi-
nary K-means. Which of these solutions represents a local or global minimum?
Explain.
10 Hierarchical clustering algorithms require O(m2 Iog(m)) time, and consequently,
are impractical to use directly on larger data sets. One possible technique for
reducing the time required is to sample the data set. For example, if l( clusters
are desired and 1/m points are sampled from the m points, then a hierarchi-
cal clustering algorithm will produce a hierarchical clustering in roughly O(rn)
time. K clusters can be extracted from this hierarchical clustering by taking
the clusters on the Kth level of the dendrogram. The remaining points can
then be assigned to a cluster in linear time, by using various strategies. To give
a specific example, the centroids of the 1( clusters can be computed, and then
each of the m - J* remaining points can be assigned to the cluster associated
with the closest centroid.
For each of the following types of data or clusters, discussbriefly if (1) sampling
will causeproblems for this approach and (2) what those problems are. Assume
that the sampling technique randomly choosespoints from the total set of m
points and that any unmentioned characteristics of the data or clusters are as
optimal as possible. In other words, focus only on problems caused by the
particular characteristic mentioned. Finally, assume that K is very much less
than m.
20. Consider the following four faces shown in Figure 8.39. Again, darkness or
number of dots represents density. Lines are used only to distinguish regions
and do not represent points.
(a) For each figure, could you use single link to find the patterns represented
by the nose, eyes, and mouth? Explain.
(b) For each figure, could you use K-means to find the patterns represented
by the nose, eyes)and mouth? Explain.
8.7 Exercises 565
@@
@
\#
(b) (d)
Figure
8.39.Figure
forExercise
20.
(c) What limitation does clustering have in detecting all the patterns formed
by the points in Figure 8.39(c)?
21. Compute the entropy and purity for the confusion matrix in Table 8.14.
Table8.14.Confusion
matrix
forExercise
21.
Cluster Entertainment Financial Foreign Metro National Sports Total
#1 I 1 0 11 / 676 693
4' 27 89 333 827 253 .).) 7562
-JJ.'
326 40,1 8 105 16 29 949
Total 354 555 347 943 273 738 3204
22. You are given two sets of 100 points that fall within the unit square. One set
of points is arranged so that the points are uniformly spaced. The other set of
points is generated from a uniform distribution over the unit square.
23. Using the data in Exercise 24, compute the silhouette coefficient for each point,
each of the two clusters, and the overall clustering.
24. Given the set of cluster labels and similarity matrix shown in Tables 8.15 and
8.16, respectively, compute the correlation between the similarity matrix and
the ideal similarity matrix, i.e., the matrix whose ijth enfty is 1 if two objects
belons to the same cluster. and 0 otherwise.
566 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
Table8,15.Table labels
ofcluster forExercise forExercise
matrix
24. Table8.16.Similarity 24.
Point Cluster Label Point P1 P2 P3 P4
P1 1 P1 1 0 . 8 0.65 t.r.5l)
P2 1 P2 0.8 1 0.7 0.6
'I
P3 2 P3 tr.oc 0.7 0.9
P4 2 P4 u . 5 5 0 . 6 0.9 1
25. Compute the hierarchical F-measure for the eight objects {p1, p2, p3, p4, p5,
p6, p7, p8) and hierarchical clustering shown in Figure 8.40. Class A contains
points pI,p2, and p3, while p4, p5, p6, p7, and p8 belong to classB.
{ p 1 ,p 2 ,p 4 ,p 5 , }
8.40.Hierarchical
Figure 25.
forExercise
clustering
26. Compute the cophenetic correlation coefficient for the hierarchical clusterings
in Exercise 16. (You will need to convert the similarities into dissimilarities.)
27. Prove Equation 8.14.
28. Prove Equation 8.16.
29. Prove that Df-rD,.. (r - m)(m - *o) :0. This fact was used in the proof
that TSS : SSE + SSB in Section8.5.2.
30. Clusters of documents can be summarized by finding the top terms (words) for
the documents in the cluster, e.g., by taking the most frequent k terms, where
k is a constant, say 10, or by taking all terms that occur more frequently than
a specified threshold. Suppose that K-means is used to find clusters of both
documents and words for a document data set.
(a) How might a set of term clusters defined by the top terms in a document
cluster differ from the word clusters found by clustering the terms with
K-means?
(b) How could term clustering be used to define clusters of documents?
and where the weight of that link is the value of the object for that attribute. For
sparse data, if the value is 0, the Iink is omitted. Bipartite clustering attempts
to partition this graph into disjoint clusters, where each cluster consists of a
set of object nodes and a set of attribute nodes. The objective is to maximize
the weight of links between the object and attribute nodes of a cluster, while
minimizing the weight of links between object and attribute links in different
clusters. This type of clustering is also known as co-clustering since the
objects and attributes are clustered at the same time.
32. In Figure 8.41, match the sirnilarity matrices, which are sorted according to
cluster labels, with the sets of points. Differences in shading and marker shape
distinguish between clusters, and each set of points contains 100 points and
three clusters. In the set of points labeled 2, there are three very tight, equal-
sized clusters.
568 Chapter 8 Cluster Analysis: Basic Concepts and Algorithms
'1
09
08
07
06
>0 5
o4
03
,i#' ds}{
..oh"
4*'
04 06 08 '1
02
x
B
40 60 80 100 2A 40 60
matrices
andsimilarity
8,41.Points
Figure 32.
forExercise
ClusterAnalysis:
Additionallssuesand
Algorithms
A large number of clustering algorithms have been developed in a variety
of domains for different types of applications. None of these algorithms is
suitable for all types of data, clusters, and applications. In fact, it seemsthat
there is arlwaysroom for a new clustering algorithm that is more effi.cientor
better suited to a particular type of data, cluster, or application. Instead,
we can only claim that we have techniques that work well in some situations.
The reason is that, in many cases,what constitutes a good set of clusters is
open to subjective interpretation. Furthermore) when an objective measure is
employed to give a precise definition of a cluster, the problem of finding the
optimal clustering is often computationally infeasible.
This r:hapter focuseson important issuesin cluster analysis and explores
the concerptsand approachesthat have been developed to address them. We
begin with a discussionof the key issuesof cluster analysis, namely, the char-
acteristics of data, clusters, and algorithms that strongly impact clustering.
These issuesare important for understanding, describing, and comparing clus-
tering techniques,and provide the basis for deciding which technique to use in
a specific situation. For example) many clustering algorithms have a time or
spaceconnplexityof O(m2) (m being the number of objects) and thus, are not
suitable fbr large data sets. We then discuss additional clustering techniques.
For each rbechnique, we describethe algorithm, including the issuesit addresses
and the rnethods that it uses to address them. We conclude this chapter by
providing; some general guidelines for selecting a clustering algorithm for a
given application.
57O Chapter 9 Cluster Analysis: Additional Issuesand Algorithms
o DBSCAN can handle clusters of different sizes and shapes and is not
strongly affected by noise or outliers. K-means has difficulty with non-
globular clusters and clusters of different sizes. Both algorithms can
perform poorly when clusters have widely differing densities.
o K-means can only be used for data that has a well-defined centroid,
such as a mean or median. DBSCAN requires that its definition of
density, which is based on the traditional Euclidean notion of density,
be meaningful for the data.
the traditional Euclidean definition of density does not work well for
high-dimensional data.
The original versions of K-means and DBSCAN were designed for Eu-
clidean data, but both have been extended to handle other types ofdata.
o DI3SCAN and K-means both look for clusters using all attributes, that
is, they do not look for clusters that may involve only a subset of the
attbributes.
K-means can find clusters that are not well separated, even if they over-
lap (see Figure 8.2(b)), but DBSCAN merges clusters that overlap.
o DIISCAN produces the same set of clusters from one run to another,
wtrile K-means, which is typically used with random initialization of
centroids. does not.
The foll:wing are some characteristics of data that can strongly affect cluster
analvsis,,
572 Chapter 9 Cluster Analysis: Additional Issues and Algorithms
Size Many clustering algorithms that work well for small or medium-size
data sets are unable to handle larger data sets. This is addressed further
in the discussion of the characteristics of clustering algorithms scalability is
one such characteristic-and in Section 9.5, which discussesscalableclustering
algorithms.
Noise and Outliers An atypical point (outlier) can often severely degrade
the performance of clustering algorithms, especially algorithms such as K-
means that are prototype-based. On the other hand, noise can cause tech-
niques, such as single link, to join clusters that should not be joined. In some
cases, algorithms for removing noise and outliers are applied before a clus-
tering algorithm is used. Alternatively, some algorithms can detect points
that represent noise and outliers during the clustering processand then delete
them or otherwise eliminate their negative effects. In the previous chapter,
for instanceTwe saw that DBSCAN automatically classifieslow-density points
as noise and removes them from the clustering process. Chameleon (Section
9.1 Characteristics of Data, Clusters, and Clustering Algorithms 573
Scale Different attributes, e.g., height and weight, m&y be measured on dif-
ferent scales. These differencescan strongly affect the distance or similarity
between two objects and, consequently,the results of a cluster analysis. Con-
sider clustering a group of people based on their heights, which are measured
in meters, and their weights, which are measured in kilograms. If we use Eu-
clidean distance as our proximity measure)then height will have little impact
and people will be clustered mostly based on the weight attribute. If, however,
we standardize each attribute by subtracting off its mean and dividing by its
standard deviation, then we will have eliminated effects due to the difference
in scale. More generally, normalization techniques, such as those discussedin
Section 2.3.7, are typically used to handle these issues.
Shape Some clusters are regularly shaped, e.g., rectangular or globular, but
in general, clusters can be of arbitrary shape. Techniques such as DBSCAN
and single link can handle clusters of arbitrary shape, but prototype-based
schemesand some hierarchical techniques, such as complete link and group
average) cannot. Chameleon (Section 9.4.4) and CURE (Section 9.5.3) are
examplesof techniquesthat were specifically designedto addressthis problem.
Differing Sizes Many clustering methods, such as K-means, don't work well
when clusters have different sizes. (See Section 8.2.4.) This topic is discussed
further in Section9.6.
Differing Densities Clusters that have widely varying density can cause
problems for methods such as DBSCAN and K-means. The SNN density-
based clustering technique presented in Section 9.4.8 addressesthis issue.
exponential in the total number of dimensions. For that reason, it is not feasi-
ble to simply look for clusters in all possible subsets of dimensions unless the
number of dimensions is relatively low.
One approach is to apply feature selection, which was discussedin Sec-
tion 2.3.4. However, this approach assumesthat there is only one subset of
dimensions in which the clusters exist. In reality, clusters can exist in many
distinct subspaces(sets of dimensions), some of which overlap. Section 9.3.2
considerstechniques that addressthe general problem of subspaceclustering,
i.e., of finding both clusters and the dimensions they span.
Order Dependence For some algorithms, the quality and number of clus-
ters produced can vary, perhaps dramatically, depending on the order in which
the data is processed.While it would seemdesirable to avoid such algorithms,
sometimesthe order dependenceis relatively minor or the algorithm may have
other desirable characteristics. SOM (Section 9.2.3) is an example of an algo-
rithm that is order dependent.
Scalability It is not unusual for a data set to contain millions of objects, and
the clustering algorithms used for such data sets should have linear or near-
linear time and space complexity. Even algorithms that have a complexity of
O(*') are not practical for large data sets. Furthermore, clustering techniques
for data sets cannot always assumethat all the data will fit in main memory or
that data elements can be randomly accessed.Such algorithms are infeasible
for large data sets. Section 9.5 is devoted to the issue of scalabilitv.
proper valuesl thus, the attitude is usually, "the fewer parameters, the bet-
ter." Choosing parameter values becomes even more challenging if a small
change in the parameters drastically changes the clustering results. Finally,
unless a procedure (which may involve user input) is provided for determining
parameter values, a user of the algorithm is reduced to using trial and error
to find suitable parameter values.
Perhaps the most well-known parameter selectionproblem is that of "choos-
ing the right number of clusters" for partitional clustering algorithms, such as
K-means. One possible approach to that issue is given in Section 8.5.5, while
referencesto others are provided in the bibliographic notes.
Road Map
o Objects are allowed to belong to more than one cluster. More specifically,
an object belongs to every cluster with some weight. Such an approach
addressesthe fact that some objects are equally close to several cluster
prototypes.
F\rzzy Sets
Lotfi Zadeh introduced frzzy set theor:y and finzy logic in 1965 as a way
of dealing with imprecision and uncertainty. Briefly, fuzzy set theory allows an
object to belong to a set with a degreeof membership between 0 and 1, while
htzzy logic allows a statement to be true with a degreeof certainty between 0
and 1. Traditional set theory and logic are special casesof their finzy counter-
parts that restrict the degree of set membership or the degree of certainty to
be either 0 or 1. Ftzzy concepts have been applied to many different areas,in-
cluding control systems, pattern recognition, and data analysis (classification
and clustering).
Consider the following example of hnzy logic. The degree of truth of the
statement "It is cloudy" can be defined to be the percentageof cloud cover in
the sky, e.g., if the sky is 50% covered by clouds, then we would assign "It is
cloudy" a degreeof truth of 0.5. If we have two sets, "cloudy days" and "non-
cloudy days," then we can similarly assign each day a degree of membership
in the two sets. Thus, if a day were 2570cloudy, it would have a 25Vodegreeof
membership in "cloudy days" and a 75Todegreeof membership in "non-cloudy
days.tt
F\tzzy Clusters
Assume that we have a set of data points X : {*t, . . . ,x-}, where each point,
x4, is an n-dimensionalpoint, i.e., x4 : (rn,. ..,rin). A collectionof finzy
9.2 Prototype-Based Clustering 579
clusters, Ct, Cz, ..., Cn is a subset of all possiblefizzy subsetsof .t. (This
simply means that the membership weights (degrees),wii,have been assigned
values between 0 and 1 for each point, xi, o,ndeach cluster, Ci.) However, we
also want to impose the following reasonableconditions on the clusters in order
to ensure that the clusters form what is called a fitzzy psuedo-partition.
2. Each cluster, Ci, contains, with non-zero weight, at least one point, but
does not contain, with a weight of one, all of the points.
rn
0< tuUlm
i:I
F\tzzy c-means
While there are many types of fuzzy chstering-indeed, many data analysis
algorithms can be "ftrzzified" we only consider the fuzzy vercion of K-means,
which is called fiizzy c-rneans. In the clustering literature, the version of K-
means that does not use incremental updates of cluster centroids is sometimes
referred to as c-means, and this was the term adapted by the fuzzy community
for the finzy versionof K-means. The fizzy c-meansalgorithm, also sometimes
known as FCM, is given by Algorithm 9.1.
Computing SSE The definition of the sum of the squared error (SSE) is
modified as follows:
ktn
. . ., Cu): t
SSE(C1,C2, \uf,dtst(xt, cj)2 (e.1)
.J-L .-L
where c7 is the centroid of the j'h cluster and p, which is the exponent that
determines the influence of the weights, has a value between 1 and oo. Note
that this SSE is just a weighted version of the traditional K-means SSE given
in Equation 8.1.
cj: S:Lwlrx;l\ul,
n i\-
(s.2)
i-r i:\
ysit : (Lldist(x6,"j)'),-
/ fplonu(*.,")')h (e.3)
, n:t
This formula may appear a bit mysterious. However, note that if P :2,
then we obtain Equation 9.4, which is somewhat simpler. We provide an
intuitive explanation of Equation 9.4, which, with a slight modification, also
applies to Equation 9.3.
k
lxii : 1fd,ist(xi,")' Itla*t@6 (e.4)
f s:I "r)'
A^'
A ^'
^' A
AA . ^.
^'
^.
A Ar a
^'
AA
A A
A A
@
tr@r
o o@ o
T
OO ao rEo @ l1 rl
a o tr ll ll
@ t
ooto o @ I I I
I
oa o @ T I
I
I
o @
I I
ta' E I
o O@ 1l
T
o I
I
#ffiT,:fl],
Figure9.1. Fuzzyc-means
clustering pointset.
ofa two-dimensional
Mixture Models
an object from it. Repeat the process m times, where rn is the number of
objects.
More formally, assumethat there are K distributions and m objects, ,{ :
{*t, . . . ,x*}. Let the 7rh distribution have parameters 0i, and let O be the set
of all parameters,i.e., @ : {0r,...,0x}. Then, prob(x,101)is the probability
of the ith object if it comes from the 7'h distribution. The probability that
the jth distribution is chosento generate an object is given by the weight u7,
I < j < 1(, where these weights (probabilities) are subject to the constraint
that they sum to one, i.e., Ditul: 1. Then, the probability of an object x
is given by Equation 9.5.
K
prob(xl}): t wpi@lli) (e.5)
j:t
o
n
(a) Probability density function for (b) 20,000 points generated from the
the mixture model. mixture model.
1 - trt4t2 1 _
' :) - c
Drob(rltO 8 + _e . (e.8)
2\/2iT 2t/2r
Figure 9.2(a) shows a plot of the probability density function of this mix-
ture m,rdel, while Figure 9.2(b) shows the histogram for 20,000 points gener-
ated from this mixture model.
Given ix statistical model for the data, it is necessaryto estimate the param-
eters of that model. A standard approach used for this task is maximum
likelihc'od estimation, which we now explain.
To begin, consider a set of rn points that are generated from a one-
dimensional Gaussian distribution. Assuming that the points are generated
independently, the probability of these points is just the product of their in-
dividual probabilities. (Again, we are dealing with probability densities, but
to keep our terminology simple, we will refer to probabilities.) Using Equa-
tion 9.7, we can write this probability as shown in Equation 9.9. Since this
probability would be a very small number, we typically will work with the log
probability, as shown in Equation 9.10.
586 Chapter 9 Cluster Analysis: Additional Issuesand Algorithms
!- | t,i-ut2
p ro b (X l @) II
: ,; e- - ";z- (e.e)
. a v a^u
a:l
!\ (r - ut2 -
Ios prob(XlO) : - Lt;+ - mlogo
0.5m1og2tr ( e.10)
i=I
: L(@lx): TI +
ti,ketihood,(@lx) (e.11)
LL ^ /r*^
. 1 v a t t v " "Ett
: l(OlX): - t
losti,kelihood(Olx) - 0.bmlog2tr
- mlogo (9.12)
z--I
ry
40
40
470
E 40
z
J90
-s0
-510
15 IOg proD
(a) Ilistogram of 200 points from a (b) Log likelihood plot of the 200 points for
Gaussian distribution. different values of the mean and standard
deviation.
9.3. 200points
Figure froma Gaussian andtheirlogprobability
distribution parameter
fordifferent
values.
Graphing the likelihood of the data for different values of the parameters is
not practical, at least if there are more than two parameters. Thus, standard
statisrbicalprocedure is to derive the maximum likelihood estimates of a statis-
tical parameter by taking the derivative of likelihood function with respect to
that parameter, setting the result equal to 0, and solving. In particular, for a
Gauss;iandistribution, it can be shown that the mean and standard deviation
of the sample points are the maximum likelihood estimates of the correspond-
ing peurameters of the underlying distribution. (SeeExercise 9 on 648.) Indeed,
for the 200 points consideredin our example, the parameter values that max-
imized the log likelihood were precisely the mean and standard deviation of
t h e 2 0 0 p o i n t s ,i . e . ,u : - 4 . 1 a n d o : 2 . 1 .
mean is the mean of the objects in the distribution. In the context of mixture
models and the trM algorithm, the computation of the mean is modified to
account for the fact that every object belongs to a distribution with a certain
probability. This is illustrated further in the following example.
Table9.1. Firstfewiterations
oftheEMalgorithm
forthesimple
example.
Iteration l-rt Hz
0 -2.00 3.00
1 , aA
4.r0
-3.94 4.07
.l -3.97 4.04
4 -3.98 4.03
-3.98 4.03
20,000
U2: \-
L
( e.15)
We repeat these two steps until the estimates of p1 and p,2 either don't
change or change very little. Table 9.1 gives the first few iterations of the EM
algorithm when it is applied to the set of 20,000 points. For this data, we
know which distribution generated which point, so we can also compute the
mean of the points from each distribution. The means are p1 : -3.98 and
ltz: 4.03. I
Example 9.5 (The EM Algorithm on Sample Data Sets). We give
three examples that illustrate the use of the EM algorithm to find clusters
using mixture models. The first example is based on the data set used to
illustrate the finzy c-means algorithm-see Figure 9.1. We modeled this data
as a mixture of three two-dimensional Gaussian distributions with different
means and identical covariance matrices. We then clustered the data using
the EM algorithm. The results are shown in Figure 9.4. Each point was
assignedto the cluster in which it had the largest membership weight. The
points belonging to each cluster are shown by different marker shapes, while
the degreeof membership in the cluster is shown by the shading. Membership
in a cluster is relatively weak for those points that are on the border of the two
clusters, but strong elsewhere. It is interesting to compare the membership
weights and probabilities of Figures 9.4 and 9.1. (See Exercise 11 on page
648.)
For our second example, we apply mixture model clustering to data that
contains clusters with different densities. The data consists of two natural
clusters, each with roughly 500 points. This data was created by combining
two sets of Gaussiandata, one with a center at (-4,1) and a standard deviation
of 2, and one with a center at (0,0) and a standard deviation of 0.5. Figure 9.5
shows the clustering produced by the EM algorithm. Despite the differences
9.2 Prototvpe-Based Clusterins 591
Finding clusters by modeling the data using mixture models and applying the
EM algorithm to estimate the parameters of those models has a variety of
advantages and disadvantages. On the negative side, the trM algorithm can
be slow, it is not practical for models with large numbers of components, and
it does not work well when clusters contain only a few data points or if the
data points are nearly co-linear. There is also a problem in estimating the
number of clusters or7 more generally, in choosingthe exact form of the model
to use. This problem typically has been dealt with by applying a Bayesian
approach, which, roughly speaking, givesthe odds of one model versusanother,
based on an estimate derived from the data. Mixture models may also have
difficulty with noise and outliers, although work has been done to deal with
this problem.
On the positive side, mixture models are more general than K-means or
finzy c-meansbecausethey can use distributions of various types. As a result,
mixture models (basedon Gaussiandistributions) can find clusters of different
sizesand elliptical shapes. AIso, a model-basedapproach provides a disciplined
way of eliminating some of the complexity associatedwith data. To see the
patterns in data, it is often necessaryto simplify the data, and fitting the data
to a model is a good way to do that if the model is a good match for the data.
Furthermore, it is easy to characterize the clusters produced, since they can
be described by a small number of parameters. Finally, many sets of data are
indeed the result of random processes)and thus should satisfy the statistical
assumptions of these models.
592 Chapter 9 Cluster Analysis: Additional Issuesand Algorithms
o
ao
a O o
a
a oo o a I
oo
a
a 1O a 85
OO a
oa
oo
8
a o
a
A 7
^. AA
r .4. ^. A .65
tl A
atta
.6
ll A
I
lr ^' A
0.55
lr ^. A
lrr 1A
I
^. 0.5
Maximum
Probablility
!-o ..
X<
{x
x (,\
x
*
XX *
rx +*
x* :l<*
x*
++ x?(x *
.+ :X a<*
*
fl
T *
+' + ' t *,r
+]-
+ T +
+TJ
+ -+=
j;tr+if;
''+
;r
*
,( h*
)e
*x *
,x ,t*
* :x
)(
* **
modelandK-means
Figure9.6. Mixture clustering points.
of a setoftwo-dimensional
594 Chapter I Cluster Analysis: Additional Issuesand Algorithms
@@@
@@@
r.;)
\r\rvr.;) G)
SOMneural
rectangular
3-by-3
Figure9,7.Two-dimensional network.
nearby in the topographic ordering. In this way, SOM produces an ordered set
of centroids for any given data set. In other words, the centroids that are close
to each other in the SOM grid are more closely related to each other than to
the centroids that are farther away. Becauseof this constraint, the centroids of
a two-dimensional SOM can be viewed as lying on a two-dimensional surface
that tries to fit the n-dimensional data as well as possible. The SOM centroids
can also be thought of as the result of a nonlinear regressionwith respect to
the data points.
At a high level, clustering using the SOM technique consists of the steps
described in Algorithm 9.3.
from the available data points. This is very much like randomly selecting
centroids for K-means.
Selection of an object The first step in the loop (line 3) is the selectionof
the next object. This is fairly straightforward, but there are some difficulties.
Since convergencemay require many steps, each data object may be used
multiple times, especially if the number of objects is small. However, if the
number of objects is large, then not every object needs to be used. It is also
possible to enhance the influence of certain groups of objects by increasing
their frequency in the training set.
Update The update step (line 5) is the most complicated. Let m1, ...,
rn7, be the centroids. (For a rectangular grid, note that k is the product of
the number of rows and the number of columns.) For time step f, let p(t)
be the current object (point) and assume that the closest centroid to p(l) is
m;. Then, for time t+I, the jth centroid is updated by using the following
equation. (We will see shortly that the update is really restricted to centroids
whose neurons are in a small neighborhood of m;.)
Figure9.8. Visualization
of therelationships
between lor LosAngeles
SOMcluster Times
document
dataset.
shows the points and the positions of the 36 referencevectors (shown as x's)
produced by SOM. The points are arranged in a checkerboard pattern and
are split into five classes:circles, triangles, squares,diamonds, and hexagons
(stars). A 6-by-6 two-dimensional rectangular grid of centroids was used with
random initialization. As Figure 9.9(a) shows, the centroids tend to distribute
themselves to the dense areas. Figure 9.9(b) indicates the majority class of
the points associatedwith that centroid. The clusters associatedwith triangle
points are in one contiguous area, as are the centroids associated with the
four other types of points. This is a result of the neighborhood constraints
enforced by SOM. While there are the same number of points in each of the
five groups, notice also that the centroids are not evenly distributed. This is
partly due to the overall distribution of points and partly an artifact of putting
each centroid in a sinsle cluster.
Applications
Once the SOM vectors are found, they can be used for many purposes other
than clustering. For example, with a two-dimensional SOM, it is possible to
associatevarious quantities with the grid points associatedwith each centroid
(cluster) and to visualize the results via various types of plots. For example,
plotting the number of points associatedwith each cluster yields a plot that
revealsthe distribution of points among clusters. A two-dimensional SOM is a
non-linear projection of the original probability distribution function into two
9.2 Prototype-BasedClustering599
o e o
osn { ^ Xd o
dX'o oo o E^o q X- diamond diamond diamond h9Xagon nexagon nexagon
oo o gl i " J"
;;; "x*""?
oxe.i"
* S""\
" .*r*
'oX ** diamond dlamond diamond ctrde hexagon hengon
- o o "
"^ ox
"o o "8>E
?X o-xo o
^s diamond dimond ctrcle nexagon
^&
" :,^ ^ oxo
o
9{"- .o
o o^' o > q t^-g( o
oo
" .'x
- -o@ square cfcb triangle tiangle
"l -4
rn%a^aA
8k"."
'",x8 k '^Aa a da ^ ")\ a
^X X quare tiangle hangle
."XF"
"d r^ o A A A
X .Fo
" EooX D ^Xa a
oo "A
E Bo
quare quare tiangl€ tdan9le hangb
(a) Distribution of SOM reference vectors (b) Classes of the SOM cen-
(X's) for a two-dimensional point set. broids.
datapoints.
to two-dimensional
Figure9.9. SOMapplied
This is a key step in the process, but also the least well defined, as there
are many ways to split the possible values of each attribute into a number
of contiguous intervals. For continuous attributes, one common approach is
to split the values into equal width intervals. If this approach is applied to
each attribute, then the resulting grid cells all have the same volume, and the
density of a cell is conveniently defined as the number of points in the cell.
However, more sophisticated approaches can also be used. In particular,
for continuous attributes any of the techniques that are commonly used to
discretize attributes can be applied. (See Section 2.3.6.) In addition to the
equal width approach already mentioned, this includes (1) breaking the values
of an attribute into intervals so that each interval contains an equal number
of points, i.e., equal frequency discretization, or (2) using clustering. Another
approach, which is used by the subspaceclustering algorithm MAFIA, initially
602 Chapter 9 Cluster Analysis: Additional Issuesand Algorithms
breaks the set of values of an attribute into a large number of equal width
intervals and then combines intervals of similar density.
Regardlessof the approach taken, the definition of the grid has a strong
impact on the clustering results. We will consider specific aspectsof this later.
A natural way to define the density of a grid cell (or a more generally shaped
region) is as the number of points divided by the volume of the region. In other
words, density is the number of points per amount of space,regardlessof the
dimensionality of that space. Specific, low-dimensional examples of density
are the number of road signs per mile (one dimension), the number of eagles
per square kilometer of habitat (two dimensions), and the number of molecules
of a gas per cubic centimeter (three dimensions). Ar mentioned, however, a
common approach is to use grid cells that have the same volume so that the
number of points per cell is a direct measure of the cell's density.
Example 9.8 (Grid-Based Density). Figure 9.10 shows two sets of two-
dimensional points divided into 49 cells using a 7-by-7 grid. The first set
contains 200 points generatedfrom a uniform distribution over a circle centered
at (2, 3) of radius 2, while the second set has 100 points generated from a
uniform distribution over a circle centered at (6, 3) of radius 1. The counts
for the grid cells are shown in Table 9.2. Since the cells have equal volume
(area), we can consider these values to be the densities of the cells. r
0000000
0000000
417186000
L4L413130L827
1118102L02431
320144000
0000000
Figute9.10.Grid-based
density. Table9.2. Pointcountsfororidcells.
9.3 Density-Based Clustering 603
On the positive side, grid-based clustering can be very efficient and effective.
Given a partitioning of each attribute, a single pass through the data can
determine the grid cell of every object and the count of every grid. Also,
even though the number of potential grid cells can be high, grid cells need to
be created only for non-empty cells. Thus, the time and space complexity of
defining the grid, assigning each object to a cell, and computing the density
of each cell is only O(m), where m is the number of points. If adjacent,
occupied cells can be efficiently accessed,for example, by using a search tree,
then the entire clustering process will be highly efficient, e.g., with a time
complexity of O(m log rz). For this reason,the grid-based approach to density
604 Chapter 9 Cluster Analysis: Additional Issuesand Algorithms
The clustering techniques considered until now found clusters by using all
of the attributes. However, if only subsets of the features are considered,i.e.,
subspacesofthe data, then the clusters that we find can be quite different from
one subspaceto another. There are two reasons that subspaceclusters may
be interesting. First, the data may be clustered with respect to a small set of
attributes, but randomly distributed with respect to the remaining attributes.
Second, there are cases in which different clusters exist in different sets of
dimensions. Consider a data set that records the sales of various items at
various times. (The times are the dimensions and the items are the objects.)
Some items might show similar behavior (cluster together) for particular sets
of months, e.g.) summer, but different clusters would likely be characterized
by different months (dimensions).
9.3 Density-Based Clustering 605
a
ttt
. ! ,a'
r.tl :
a
a: ,a
t
al
06 08 1 12 14 16 18
x
Figure9.11. Example
figures
forsubspace
clustering.
0.14
o.12
U'
c
o
(L
o
(U
LL
0.04
0.02
00.5 1*t.u22.5
Figure9.12,Histogram
showing of points
thedistribution forther attribute.
for a dense cell is ( : 0.06, or 6%oof the points, then three one-dimensional
clusters can be identified in Figure 9.12, which shows a histogram of the data
points of Figure 9.11(a) for the r attribute.
Figure 9.11(b) shows the points plotted in the ry plane. (The z attribute
is ignored.) This figure also contains histograms along the r and g axes that
show the distribution of the points with respect to their r and g coordinates,
respectively. (A higher bar indicates that the corresponding interval contains
relatively more points, and vice versa.) When we consider the gr axis, we see
three clusters. One is from the circle points that do not form a cluster in the
full space,one consists of the square points, and one consists of the diamond
and triangle points. There are also three clusters in the r dimension; they
correspond to the three clusters diamonds, triangles, and squares in the
full space. These points also form distinct clusters in the ry plane. Figure
9.11(c) shows the points plotted in the rz plane. There are two clusters,
if we consider only the z attribute. One cluster corresponds to the points
representedby circles, while the other consists of the diamond, triangle, and
square points. These points also form distinct clusters in the rz plane. In
Figure 9.11(d), there are three clusters when we consider both the y and z
coordinates. One of these clusters consists of the circlesl another consists
9.3 Density-Based Clustering 60T
of the points marked by squares. The diamonds and triangles form a single
cluster in the yz plane. I
These figures illustrate a couple of important facts. First, a set of points-
the circles may not form a cluster in the entire data space, but may form a
cluster in a subspace.Second,clusters that exist in the full data space (or even
a subspace)show up as clusters in lower-dimensionalspaces.The first fact tells
us that we may need to look in subsetsof dimensionsto find clusters, while the
second fact tells us that many of the clusters we find in subspacesmay only
be "shadows" (projections) of higher-dimensional clusters. The goal is to find
the clusters and the dimensions in which they exist, but we are typically not
as interested in clusters that are projections of higher-dimensional clusters.
CLIQUE
Consider a set of adjacent, k-dimensional cells that form a cluster; i.e., there is
a collection of adjacent cells that have a density above the specified threshold
(. A corresponding set of cells in k - 1 dimensions can be found by omitting
one of the k dimensions (attributes). The lower-dimensional cells are still ad-
jacent, and each low-dimensional cell contains all points of the corresponding
high-dimensional cell. It may contain additional points as well. Thus, a low-
dimensional cell has a density greater than or equal to that of its corresponding
high-dimensional cell. Consequently,the low-dimensional cells form a cluster;
i.e., the points form a cluster with the reduced set of attributes.
Algorithm 9.5 gives a simplified version of the steps involved in CLIQUE.
Conceptually, the CLIQUtr algorithm is similar to the Apriori, algorithm for
finding frequent itemsets. See Chapter 6.
known Apri,ori, principle from association analysis, its properties are well un-
derstood. Another useful feature is CLIQUE's ability to summarize the list of
cells that comprises a cluster with a small set of inequalities.
Many limitations of CLIQUE are identical to the previously discussedlim-
itations of other grid-based density schemes. Other limitations are similar to
those of the Apri,ori. algorithm. Specifically,just as frequent itemsets can share
items, the clusters found by CLIQUE can share objects. Allowing clusters to
overlap can greatly increase the number of clusters and make interpretation
difficult. Another issue is that Apri,orz (and CLIQUE) potentially have expo-
nential time complexity. In particular, CLIQUE will have difficulty if too many
dense cells are generated at lower values of k. Raising the density threshold
( can alleviate this problem. Still another potential limitation of CLIQUE is
explored in Exercise 20 on page 650.
.=
a
c
o
o
Figure9.13.lllustration
of DENCLUE
density
concepts
inonedimension.
and discarded. Also, if a local peak can be connected to a second local peak
by a path of data points, and the density at each point on the path is above
the minimum density threshold, then the clusters associatedwith these local
peaks are merged. Therefore, clusters of any shape can be discovered.
Irnplementation Issues
(c) Overall density gray scale plot. (cl) Overall density surlace plot.
Figure9,14.Example
oftheGaussian (kernel)
influence function
andanoverall
density
function.
the neighborhood; i.e., points in the samecell and in cells that are connectedto
the point's cell. While this approach can sacrifice some accuracy with respect
to density estimation, computational complexity is greatly reduced.
3 . Define core objects and build clusters around them. To do this for graph-
based clustering, it is necessaryto introduce a notion ofdensity-based on
a proximity graph or a sparsified proximity graph. As with DBSCAN,
building clusters around core objects leads to a clustering technique that
can find clusters of differing shapes and sizes.
two clusters are merged only if the resulting cluster will have character-
istics similar to the original two clusters.
We begin by discussing the sparsification of proximity graphs, providing
two examplesof techniqueswhose approach to clustering is based solely on this
technique: MST, which is equivalent to the single link clustering algorithm,
and Opossum. We then discuss Chameleon, a hierarchical clustering algorithm
that uses a notion of self-similarity to determine if clusters should be merged.
We next define Shared Nearest Neighbor (SNN) similarity, a new similarity
measure)and introduce the Jarvis-Patrick clustering algorithm, which usesthis
similarity. Finally, we discuss how to define density and core objects based
on SNN similarity and introduce an SNN density-basedclustering algorithm,
which can be viewed as DBSCAN with a new similarity measure.
9.4.t Sparsification
Construct a Modified
Figure9.15.ldealprocess usingsparsification.
ofclustering
Figure9.16.Minimum
spanning points.
treefora setofsixtwo-dimensional
OPOSSUM is simple and fast. It partitions the data into roughly equal-sized
clusters, which, depending on the goal of the clustering, can be viewed as an
advantage or a disadvantage. Becausethey are constrained to be of roughly
equal size, clusters can be broken or combined. However, if OPOSSUM is
used to generate a large number of clusters, then these clusters are typically
relatively pure pieces of larger clusters. Indeed, OPOSSUM is similar to the
initial step of the Chameleon clustering routine, which is discussednext.
a '
aats
Figure9.17.Situation
inwhichcloseness
is nottheappropriate
merging
criterion.
@1999,IEEE
and (d) are merged, they yield a cluster that seemsmore similar to the original
clusters than the cluster that results from merging clusters (a) and (b).
Chameleon is an agglomerative clustering algorithm that addressesthe is-
suesof the previous two paragraphs. It combines an initial partitioning of the
data, using an efficient graph partitioning algorithm, with a novel hierarchical
clustering schemethat usesthe notions of closenessand interconnectivity, to-
gether with the local modeling of clusters. The key idea is that two clusters
should be merged only if the resulting cluster is similar to the two original
clusters. Self-similarity is described first, and then the remaining details of
the Chameleon algorithm are presented.
Sp6'(C;,Ci)
,Dr u
/ 1--
, ( e.17)
where rn6 and mi are the sizes of clusters Ct and Cj, respectively,
Snc(Cn,Cr) is the averageweight of the edges(of the k-nearest neighbor
graph) that connect clusters Cr a;ndCi; Sec(Ct) is the averageweight of
edgesif we bisect cluster C,;; and Ssc(C.i) is the averageweight of edges
if we bisect cluster Cj. (EC stands for edge cut.) Figure 9.18 illustrates
the notion of relative closeness.As discussedpreviously, while clusters
9.4 Graph-Based Clustering 619
ll&sss
##ffi
s
t&9
a
I t
e*
tq
I 4
a
te
tl 'g**
rrg*
t
(c) (d)
Figure9.18.lllustration
ofthenotion
of relative
closeness. IEEE
G)1999,
Figure
9.19.lllustration
ottl'rlnotion
ofretative
in,.Jl'onn.r,.oness.
@1999,tEEE
(a) and (b) are closer in absolute terms than clusters (c) and (d), this is
not true if the nature of the clusters is taken into account.
(d), have more connections than the rectangular clusters, (a) and (b).
However, merging (c) and (d) produces a cluster that has connectivity
quite different from that of (c) and (d). In contrast, merging (a) and (b)
produces a cluster with connectivity very similar to that of (a) and (b).
Chameleon Algorithm
Figure process
9.20.Overall bywhich performs
Chameleon clustering. IEEE
O1999,
Graph Partitioning
Once a sparsified graph has been obtained, an efficient multilevel graph par-
titioning algorithm, such as METIS (see bibliographic notes) can be used to
partition the data set. Chameleon starts with an all-inclusive graph (cluster)
and then bisects the largest current subgraph (cluster) until no cluster has
more than MIN-SIZE points, where MIN_SIZE is a user-specifiedparameter.
This processresults in a large number of roughly equally sized groups of well-
connectedvertices (highly similar data points). The goal is to ensurethat each
partition contains objects mostly from one true cluster.
(a) (b)
Figure9.21.Chameleon tocluster
applied setsofpoints.
a pairoftwo-dimensional IEEE
@1999,
Chameleon can effectively cluster spatial data, even though noise and outliers
are present and the clusters are of different shapes, sizes, and density. Cha-
meleon assumesthat the groups of objects produced by the sparsification and
graph partitioning process are subclusters; i.e., that most of the points in a
partition belong to the same true cluster. If not, then agglomerative hier-
archical clustering will only compound the errors since it can never separate
objects that have been wrongly put together. (See the discussion in Section
8.3.4.) Thus, Chameleon has problems when the partitioning processdoes not
produce subclusters, as is often the case for high-dimensional data.
If two points are similar to many of the same points, then they are
similar to one another, even if a direct measurement of similarity
does not indicate this.
Table9.3. Similarity
among
documents
indifferent of a newspaper.
sections
Section Average Cosine Similarity
Entertainment 0.032
Financial 0.030
Foreign 0.030
Metro 0.021
National 0.027
Sports 0.036
AII Sections 0.014
Figure9.22.Twocircular
clusters
of 200uniformly points.
distributed
the stars in a galaxy are no less real clusters of stellar objects than the planets
in a solar system?even though the planets in a solar system are considerably
closer to one another on average,than the stars in a galaxy.
In both situations, the key idea is to take the context of points into account in
defining the similarity measure. This idea can be made quantitative by using
a shared nearest neighbor definition of similarity in the manner indicated
by Algorithm 9.10. Essentially, the SNN similarity is the number of shared
neighbors as long as the two objects are on each other's nearest neighbor lists.
Note that the underlying proximity measure can be any meaningful similarity
or dissimilarity measure.
Figure9.23.Computation
of SNNsimilarity twopoints.
between
The similarity graph of the SNN similarities among objects is called the
SNN similarity graph. Since many pairs of objects will have an SNN simi-
larity of 0, this is a very sparse graph.
vv
vvw
";qw
'q? j
Figure9.24.Jarvis-Patrick
clustering pointset.
of a two-dimensional
shapes, and densities. The algorithm works well for high-dimensional data
and is particularly good at finding tight clusters of strongly related objects.
However, JP clustering defines a cluster as a connected component in the
SNN similarity graph. Thus, whether a set of objects is split into two clusters
or left as one may depend on a single link. Hence, JP clustering is somewhat
brittle; i.e., it may split true clusters or join clusters that should be kept
separate.
Another potential limitation is that not all objects are clustered. However,
these objects can be added to existing clusters, and in some cases,there is no
requirement for a complete clustering. JP clustering has a basic time complex-
ity of O(*2), which is the time required to compute the nearest neighbor list
for a set of objects in the general case. In certain cases,e.g., low-dimensional
data, special techniques can be used to reduce the time complexity for finding
nearest neighbors to O(mlogm). Finally, as with other clustering algorithms,
choosing the best values for the parameters can be challenging.
Core points. A point is a core point if the number of points within a given
neighborhood around the point, as determined by SNN similarity and a
supplied parameter -Eps exceedsa certain threshold MinPts, which is
also a supplied parameter.
628 Chapter 9 Cluster Analysis: Additional Issues and Algorithms
n$$fiiis
(a) All points. (b) High SNN (c) Medium SNN (d) Low SNN
density. density. density.
Figure
9.25.SNNdensity points.
oftwo-dimensional
Border points. A border point is a point that is not a core point, i.e., there
are not enough points in its neighborhood for it to be a core point, but
it falls within the neighborhood of a core point.
Noise points. A noise point is any point that is neither a core point nor a
border point.
The SNN density defined above can be combined with the DBSCAN algorithm
to creaJe a new clustering algorithm. This algorithm is similar to the JP
clustering algorithm in that it starts with the SNN similarity graph. However,
instead of using a threshold to sparsify the SNN similarity graph and then
taking connected components as clusters, the SNN density-based clustering
algorithm simply applies DBSCAN.
The steps of the SNN density-based clustering algorithm are shown in AIgo-
rithm 9.12.
that these are clusters of time series of length 492 months) even though they
are visualized as two-dimensional regions. The white areasare regions in which
the pressure was not as uniform. The clusters near the poles are elongated
becauseof the distortion of mapping a spherical surface to a rectangle.
Using SLP, Earth scientists have defined time series, called climate in-
dices, that are useful for capturing the behavior of phenomena involving the
Earth's climate. For example, anomalies in climate indices are related to
abnormally low or high precipitation or temperature in various parts of the
world. Some of the clusters found by SNN density-based clustering have a
strong connection to some of the climate indices known to Earth scientists.
Figure 9.27 shows the SNN density structure of the data from which the
clusters were extracted. The density has been normalized to be on a scale
between 0 and 1. The density of a time series may seem like an unusual
concept, but it measuresthe degree to which the time series and its nearest
neighbors have the same nearest neighbors. Since each time seriesis associated
with a location, it is possible to plot these densities on a two-dimensional plot.
Becauseof temporal autocorrelation, these densitiesform meaningful patterns,
e.g., it is possible to visually identify the clusters of Figure 9.27.
90
60
F-{^ 6m
sffi P
AE
t4
1*r
q ,
F
t*"
\
J
7r! !
h
k JT
I
AN
fc J- &-
ffi t
JE
t nQ # x( ll
FA'
30
\ f\J 4L k \\) I , rrF
o
-Xffi V"{t rU TJ h .
.Eo x
_:t
"LT ht
"+_E\
j
(
{t F-
-30
til '\
\',
-60
t,
1a
\!
t-
*
p
x
*K
#
q
-90
-180-150-120-90-60 -30 0 30 60 90 120 150 180
Longitude
of pressure
Figure9.26.Clusters foundusingSNNdensity-based
timeseries clustering.
ofpressure
9.27.SNNdensity
Figure timeseries.
632 Chapter 9 Cluster Analysis: Additional Issuesand Algorithms
9.5.2 BIRCH
BIRCH (Balanced Iterative Reducing and Clustering using Hierarchies) is a
highly efificientclustering technique for data in Euclidean vector spaces,i'e.,
634 Chapter 9 Cluster Analysis: Additional Issuesand Algorithms
data for which averagesmake sense. BIRCH can efficiently cluster such data
with one pass and can improve that clustering with additional passes.BIRCH
can also deal effectively with outliers.
BIRCH is based on the notion of a Clustering Feature (CF) and a CF tree.
The idea is that a cluster of data points (vectors) can be represented by a
triple of numbers (N, LS, SS), where N is the number of points in the cluster,
,L,9is the linear sum of the points, and ,9,9is the sum of squaresof the points.
These are common statistical quantities that can be updated incrementally
and that can be used to compute a number of important quantities, such as
the centroid of a cluster and its variance (standard deviation). The variance
is used as a measure of the diameter of a cluster.
These quantities can also be used to compute the distance between clusters.
The simplest approach is to calculate an L1 (city block) or L2 (Euclidean)
distance between centroids. We can also use the diameter (variance) of the
merged cluster as a distance. A number of different distance measures for
clusters are defined by BIRCH, but all can be computed using the summary
statistics.
A CF tree is a height-balanced tree. Each interior node has entries of the
form [CF;, childi], where child; is a pointer to the i,th child node. The space
that each entry takes and the page size determine the number of entries in an
interior node. The space of each entry is, in turn, determined by the number
of attributes of each point.
Leaf nodes consist of a sequenceof clustering features, CFi, where each
clustering feature represents a number of points that have been previously
scanned. Leaf nodes are subject to the restriction that each leaf node must
have a diameter that is less than a parameterized threshold, ?. The space
that each entry takes, together with the page size, determines the number of
entries in a leaf.
By adjusting the threshold parameter T, the height of the tree can be
controlled. 7 controls the finenessof the clustering, i.e., the extent to which
the data in the original set of data is reduced. The goal is to keep the CF tree
in main memory by adjusting the ? parameter as necessary.
A CF tree is built as the data is scanned. As eachdata point is encountered,
the CF tree is traversed, starting from the root and choosing the closest node
at each level. When the closest leaf cluster for the current data point is finally
identified, a test is performed to see if adding the data item to the candidate
cluster will result in a new cluster with a diameter greater than the given
threshold, ?. If not, then the data point is added to the candidate cluster bv
9.5 Scalable Clustering Algorithms 635
updating the CF information. The cluster information for all nodes from the
leaf to the root is also updated.
If the new cluster has a diameter greater than T, then a new entry is
created if the leaf node is not full. Otherwise the leaf node must be split.
The two entries (clusters) that are farthest apart are selectedas seedsand the
remaining entries are distributed to one of the two new leaf nodes, based on
which leaf node contains the closest seedcluster. Once the leaf node has been
split, the parent node is updated and split if necessary;i.e., if the parent node
is full. This processmay continue all the way to the root node.
BIRCH follows each split with a merge step. At the interior node where the
split stops, the two closestentries are found. Ifthese entries do not correspond
to the two entries that just resulted from the split, then an attempt is made to
merge these entries and their corresponding child nodes. This step is intended
to increasespaceutilization and avoid problems with skeweddata input order.
BIRCH also has a procedure for removing outliers. When the tree needs
to be rebuilt because it has run out of memory, then outliels can optionally
be written to disk. (An outlier is defined to be a node that has far fewer data
points than average.) At certain points in the process, outliers are scanned
to see if they can be absorbed back into the tree without causing the tree to
grow in size. If so, they are reabsorbed. If not, they are deleted.
BIRCH consists of a number of phases beyond the initial creation of the
CF tree. All the phasesof BIRCH are described briefly in Algorithm 9.13.
9.5.3 CURE
CURE (Clustering Using REpresentatives) is a clustering algorithm that uses
a variety of different techniques to create an approach that can handle large
data sets, outliers, and clusters with non-spherical shapes and non-uniform
sizes. CURE representsa cluster by using multiple representative points from
the cluster. These points will, in theory, capture the geometry and shape of the
cluster. The first representative point is chosen to be the point farthest from
the center of the cluster, while the remaining points are chosenso that they are
farthest from all the previously chosen points. In this way, the representative
points are naturally relatively well distributed. The number of points chosen
is a parameter, but it was found that a value of 10 or more worked well.
Once the representative points are chosen, they are shrunk toward the
center by a factor, a. This helps moderate the effect of outliers, which are
usually farther away from the center and thus, are shrunk more. For example,
a representative point that was a distance of 10 units from the center would
636 Chapter 9 Cluster Analysis: Additional Issuesand Algorithms
Sampling in CURE
(e.1e)
Partitioning
When sampling is not enough, CURE also uses a partitioning approach. The
idea is to divide the points into p groups of size m f p and to use CURE to cluster
each partition in order to reduce the number of objects by a factor of q > I,
where q can be roughly thought of as the averagesize of a cluster in a partition.
9.6 Which Clustering Algorithm? 639
Overall, clusters are produced. (Note that since CURE represents each
ffi
cluster by a number of representative points, the reduction in the number of
objects is not pq.) This preclustering step is then followed by a final clustering
of the mf pq intermediate clusters to produce the desired number of clusters
(K). Both clustering passesuse CURE's hierarchical clustering algorithm and
are followed by a final pass that assigns each point in the data set to one of
the clusters.
The key issue is how p and q should be chosen. Algorithms such as CURE
have a time complexity of O(^') or higher, and furthermore, require that all
the data be in main memory. We therefore want to choose p small enough so
that an entire partition can be processedin main memory and in a'reasonable'
amount of time. At the current time, a typical desktop computer can perform
a hierarchical clustering of a few thousand objects in a few seconds.
Another factor for choosing p, and also q, concerns the quality of the
clustering. Specifically, the objective is to choosethe values of p and q such
that objects from the same underlying cluster end up in the same clusters
eventually. To illustrate, suppose there are 1000 objects and a cluster of size
100. If we randomly generate 100 partitions, then each partition will, on
average, have only one point from our cluster. These points will likely be put
in clusters with points from other clusters or will be discarded as outliers. If
we generate only 10 partitions of 100 objects, but q is 50, then the 10 points
from each cluster (on average) will likely still be combined with points from
other clusters, since there are only (on average) 10 points per cluster and we
need to produce, for each partition, two clusters. To avoid this last problem'
which concernsthe proper choice of q, a suggestedstrategy is not to combine
clusters if they are too dissimilar.
Type of Clustering One important factor in making sure that the type of
clustering matches the intended use is the type of clustering produced by the
algorithm. For some applications, such as creating a biological taxonomy, a
640 Chapter I Cluster Analysis: Additional Issues and Algorithms
Type of Cluster Another key aspect is whether the type of cluster matches
the intended application. There are three commonly encountered types of
clusters: prototype-, graph-, and density-based. Prototype-based clustering
schemes,as well as some graph-basedclustering schemes-complete link, cen-
troid, and Ward's-tend to produce globular clusters in which each object is
sufficiently close to the cluster's prototype or to the other objects in the clus-
ter. If, for example, we want to summarize the data to reduce its size and we
want to do so with the minimum amount of error, then one of these types of
techniques would be most appropriate. In contrast, density-based clustering
techniques, as well as some graph-based clustering techniques, such as single
link, tend to produce clusters that are not globular and thus contain many ob-
jects that are not very similar to one another. If clustering is used to segment
a geographical area into contiguous regions based on the type of land cover,
then one of these techniques is more suitable than a prototype-based scheme
such as K-means.
Noise and Outliers Noise and outliers are particularly important aspects
of the data. We have tried to indicate the effect of noise and outliers on the
various clustering algorithms that we have discussed. In practice, however, it
may be difficult to evaluate the amount of noise in the data set or the number
of outliers. More than that, what is noise oI an outlier to one person may
be interesting to another pelson. For example, if we are using clustering to
segment an area into regions of different population density, we do not want
to use a density-based clustering technique, such as DBSCAN, that assumes
that regions or points with density lower than a global threshold are noise or
outliers. As another example, hierarchical clustering schemes,such as CURE,
often discard clusters of points that are growing slowly since such groups tend
to representoutliers. However, in some applications we may be most interested
in relatively small clustersl e.g., in market segmentation, such groups might
represent the most profitable customers.
Bibliography
1418] R. Agrawal, J. Gehrke, D. Gunopulos, and P. Raghavan. Automatic subspaceclustering
of high dimensional data for data mining applications. In Proc. of 1998 ACM-SIGMOD
IntL. Conf. on Managernent of Data, pages 94 105, Seattle, Washington, June 1998.
ACM Press.
[419] D. Barbar6. Requirements for clustering data streams. SIGKDD Etplorations Newslet-
ter, 3(2):23-27, 2002.
1420] J. Bilmes. A Gentle Tutorial on the EM Algorithm and its Application to Parameter
Estimation for Gaussian Mixture and Hidden Markov Models. Technical Report ICSI-
TR-97-021, University of California at Berkeley, 1997.
l42Il C. M. Bishop, M. Svensen, and C. K. I. Williams. GTM: A principled alternative to
the self-organizing map. In C. von der Malsburg, W. von Seelen,J. C. Vorbruggen, and
Bibliography 645
[457] M. Steinbach, P.-N. Tan, V. Kumar, S. Klooster, and C. Potter. Discovery of climate
indices using clustering. In KDD '03: Proceed,ingsof the ninth ACM SIGKDD 'interna'
tional conference on Knowledge discouery and data mi'n'ing, pages 446-455, New York,
NY. USA. 2003. ACM Press.
[45S] R. E. Stepp and R. S. Michalski. Conceptual clustering of structured objects: A
goal-oriented approach. Arti,fici,al Intelligence, 28(1) :43-69, 1986
1459] A. Strehl and J. Ghosh. A Scalable Approach to Balanced, High-dimensional Cluster-
ing of Market-Baskets. In Proc. of the 7th Intl. Conf. on High Performance Computing
(H|PC 2000), vohtme 1970 of Lecture Notes in Computer Science, pages 525 536, Ban-
galore, India, December 2000. Springer.
[460] T. Zhang, R. Ramakrishnan, and M. Livny. BIRCH: an efficient data clustering method
for very large databases. In Proc. of 1996 ACM-SIGMOD Intl. Conf. on Management
of Data, pages 103-114, Montreal, Quebec, Canada, June 1996. ACM Press.
9.8 Exercises
1 . For sparse data, discuss why considering only the presence of non-zero values
might give a more accurate view of the objects than considering the actual
magnitudes of ralues. When would such an approach not be desirable?
2 . Describe the change in the time complexity of K-means as the number of clusters
to be found increases.
.). Consider a set of documents. Assume that all documents have been normalized
to have unit length of 1. What is the "shape" of a cluster that consists of all
documents whose cosine similarity to a centroid is greater than some specified
constant? In other words, cos(d,c) ) d, where 0 < d < 1.
4 . Discuss the advantages and disadvantages of treating clustering as an optimiza-
tion problem. Among other factors, consider efficiency, non-determinism, and
whether an optimization-based approach captures all types of clusterings that
are of interest.
K
What is the time and space complexity of fuzzy c-means? Of SOM? How do
these complexities compare to those of K-means?
** ,(
*
Figure9.28.DatasetforExercise
12,EMclustering pointsetwithtwoclusters
of a two-dimensional
ofdiffering
density.
a Equation 9.12 gives the likelihood for a set of points from a Gaussian distribu-
tion as a function of the mean p and the standard deviation o. Show math-
ematically that the maximum likelihood estimate of p and o are the sample
mean and the sample standard deviation, respectively.
10. We take a sample of adults and measure their heights. If we record the gender of
each person, we can calculate the average height and the variance of the height,
separately, for men and women. Suppose, however, that this information was
not recorded. Would it be possible to still obtain this information? Explain.
1 1 . Compare the membership weights and probabilities of Figures 9.1 and 9.4,
which come, respectively, from applying fuzzy and EM clustering to the same
set of data points. What differences do you detect, and how might you explain
these differences?
t 2 . Figure 9.28 shows a clustering of a two-dimensional point data set with two
clusters: The leftmost cluster, whose points are marked by asterisks, is some-
what diffuse, while the rightmost cluster, whose points are marked by circles, is
compact. To the right of the compact cluster, there is a single point (marked by
an arrow) that belongs to the diffuse cluster, whose center is farther away than
that of the compact cluster. Explain why this is possible with EM clustering,
but not K-means clustering.
9.8 Exercises 649
13. Show that the MST clustering technique of Section 9.4.2 produces the same
clusters as single link. To avoid complications and special cases) assume that
all the pairwise similarities are distinct.
1 4 . One way to sparsify a proximity matrix is the following: For each object (row
in the matrix), set all entries to 0 except for those corresponding to the objects
k-nearest neighbors. However, the sparsified proximity matrix is typically not
symmetric.
Table
9,4.Twonearest offourpoints.
neighbors
Point First Neiehbor Second Neighbor
I A
2 J 4
a A 2
4 .) 1
Calculate the SNN similarity between each pair of points using the definition
of SNN similarity defined in Algorithm 9.10.
7 7 . For the definition of SNN similarity provided by Algorithm 9.10, the calculation
of SNN distance does not take into account the position of shared neighbors
in the two nearest neighbor lists. In other words, it might be desirable to give
higher similarity to two points that share the same nearest neighbors in the
same or roughly the same order.
(a) Describe how you might modify the definition of SNN similarity to give
higher similarity to points whose shared neighbors are in roughly the same
order.
(b) Discuss the advantages and disadvantages of such a modification.
1 8 Name at least one situation in which you would not want to use clustering
based on SNN similarity or density.
19. Grid-clustering techniques are different from other clustering techniques in that
they partition space instead of sets of points.
650 Chapter 9 Cluster Analysis: Additional Issues and Algorithms
(a) How does this affect such techniques in terms of the description of the
resulting clusters and the types of clusters that can be found?
(b) What kind of cluster can be found with grid-based clusters that cannot
be found by other types of clustering approaches? (Hint: See Exercise 20
in Chapter 8, page 564.)
20. In CLIQUE, the threshold used to find cluster density remains constant, even
as the number of dimensions increases.This is a potential problem since density
drops as dimensionality increases;i.e., to find clusters in higher dimensions the
threshold has to be set at a level that may well result in the merging of low-
dimensional clusters. Comment on whether you feel this is truly a problem and,
if so, how you might modify CLIQUE to address this problem.
2 r . Given a set of points in Euclidean space, which are being clustered using the
K-means algorithm with Euclidean distance, the triangle inequality can be used
in the assignment step to avoid calculating all the distances of each point to
each cluster centroid. Provide a general discussion of how this might work.
22. Instead of using the formula derived in CURE see Equation 9.19--we could
run a Monte Carlo simulation to directly estimate the probability that a sample
of size s would contain at least a certain fraction of the points from a cluster.
Using a Monte Carlo simulation compute the probability that a sample of size
s contains 50% of the elements of a cluster of size 100, where the total number
of points is 1000, and where s can take the values 100, 200, or 500.
10
AnomalyDetection
In anomaly detection, the goal is to find objects that are different from most
other objects. Often, anomalous objects are known as outliers, since, on a
scatter plot of the data, they lie far away from other data points. Anomaly
detection is also known as deviation detection, becauseanomalous objects
have attribute values that deviate significantly from the expected or typical
attribute values, or as exception mining, becauseanomalies are exceptional
in some sense.In this chapter, we will mostly use the terms anomaly or outl'ier.
There are a variety of anomaly detection approaches from several areas,
including statistics, machine learning, and data mining. All try to capture the
idea that an anomalousdata object is unusual or in someway inconsistent with
other objects. Although unusual objects or events are, by definition, relatively
rare, this does not mean'that ttrey do not occur frequently in absolute terms.
For example, an event that is "one in a thousand" can occur millions of times
when billions of events are considered.
In the natural world, human society, or the domain of data sets, most
events and objects are, by definition, commonplace or ordinary. However, we
have a keen awarenessof the possibility of objects that are unusual or extraor-
dinary. This includes exceptionally dry or rainy seasons)famous athletes, or
an attribute value that is much smaller or larger than all others. Our inter-
est in anomalous events and objects stems from the fact that they are often
of unusual importance: A drought threatens crops, an athlete's exceptional
skill may lead to victory, and anomalous values in experimental results may
indicate either a problem with the experiment or a new phenomenon to be
investigated.
The following examples illus;trate applications for which anomalies are of
considerableinterest.
652 Chapter 10 Anomaly Detection
Although much of the recent interest in anomaly detection has been driven
by applications in which anomalies are the focus, historically, anomaly detec-
tion (and removal) has been viewed as a technique for improving the analysis
of typical data objects. For instance, a relatively small number of outliers can
distort the mean and standard deviation of a set of values or alter the set
of clusters produced by a clustering algorithm. Therefore, anomaly detection
(and removal) is often a part of data preprocessing.
10.1 Preliminaries 653
10.1 Preliminaries
Before embarking on a discussionof specific anomaly detection algorithms, we
provide some additional background. Specifically,we (1) explore the causesof
anomalies, (2) consider various anomaly detection approaches, (3) draw dis-
tinctions among approachesbased on whether they use classlabel information,
and (4) describe issuescommorr to anomaly detection techniques.
The following are some common causes of anomalies: data from different
classes,natural variation, and rlata measurement or collection errors.
Data from Different Classes An object may be different from other ob-
jects, i.e., anomalous, because it is of a different type or class. To illustrate,
someone committing credit cald fraud belongs to a different class of credit
card users than those people v'ho use credit cards legitimately. Most of the
examples presented at the beginning of the chapter, namely, fraud, intrusion,
outbreaks of disease,and abnormal test results, are examplesof anomaliesthat
represent a different class of ob.iects. Such anomalies are often of considerable
interest and are the focus of anomaly detection in the field of data mining.
The idea that anomale6 6['jects come from a different source (class) than
most of the data objects is stal;ed in the often-quoted definition of an outlier
by the statistician Douglas Har'ikins.
Definition 10.1 (Hawkins' lDefinition of an Outlier). An outlier is an
observation that differs so much from other observations as to arouse susoicion
that it was generated by a diffe,rent mechanism.
LO.L.4 Issues
Global versus Local Perspective An object may seem unusual with re-
spect to all objects, but not with respect to objects in its local neighborhood.
For example, a person whose height is 6 feet 5 inches is unusually tall with re-
spect to the generalpopulation, but not with respect to professionalbasketball
players.
Road Map
The next four sections describe several major categoriesof anomaly detection
approaches: statistical, proximity-based, density-based, and cluster-based.
One or more specific techniques are consideredwithin each of these categories.
In these sections, we will follow common practice and use the term outlier
instead of anomaly.
Issues
Among the important issuesfacing this approach to outlier detection are the
following:
o4
) 0.25
q
c
o
> 0.2
G
!
g 0.15
(!
-1 012345
x
corresponding values for a when the distribution is l/(0,1). Note that a value
that is more than 4 standard deviations from the mean is a one-in-ten-thousand
occurrence.
\' - / 1'oo
"- \ o.zs 3r3)
662 Chapter 1O Anomaly Detection
x) : (x - x)S*1(x - *)t,
mahalanobzs(x, (10.2)
Figure10,2.Probability of pointsfortheGaussian
density usedto generate
distribution thepointsof
Figure
10.3.
B
@ 24'
A
E
IFt-
lcq @
@ o- e@
p@
%^@
Ftf ^ @@
@
su
@
***
4-3-2-1012345 Mahalanobis
x Distance
Figure10,3.Mahalanobis of points
distance fromthecenter setof 2002points.
of a two-dimensional
664 Chapter 10 Anomaly Detection
objects are put in a set of normal objects and the set of anomalous objects
is empty. An iterative procedure then transfers objects from the ordinary set
to the anomalous set as long as the transfer increasesthe overall likelihood of
the data.
Assume that the data set D contains objects from a mixture of two prob-
ability distributions: M, the distribution of the majority of (normal) objects,
and A, the distribution of anomalous objects. The overall probability distri-
bution of the data can be written as
where x is an object and ,\ is a number between 0 and 1 that gives the expected
fraction of outliers. The distribrtion M is estimated from the data, while the
distribution A is often taken to be uniform. Let Mt and A1 be the set of
normal and anomalous objects, respectively,at time t. Initially, at time f : 0,
M0 : D and As is empty. At an arbitrary time l, the likelihood and log
likelihood of the entire data set D are given by the following two equations,
respectively:
L,(D) II po(xe):
xi eD
-
(,t ,l),-,,*,ll. e,,i*,)){ro.a)
r,,,r*,))(^,^,,_,U,
where Po, Pnr, and P4, are the probability distribution functions for D, M1
and A1, respectively. This equation can be derived from the general definition
of a mixture model given in Equation 9.6 (Section 9.2.2). To do so, it is
necessaryto make the simplifying assumption that the probability is 0 for
both of the following situations: (1) an object in ,4 is a normal object, and (2)
an object in M is an outlier. Algorithm 10.1 gives the details.
Becausethe number of normal objects is large compared to the number of
anomalies, the distribution of the normal objects may not change much when
an object is moved to the set of anomalies. In that case, the contribution of
each normal object to the overall likelihood of the normal objects will remain
relatively constant. Furthermore, if a uniform distribution is assumed for
anomalies,then each object moved to the set of anomalies contributes a fixed
amount to the likelihood of the anomalies. Thus, the overall change in the
total likelihood of the data when an object is moved to the set of anomalies
is roughly equal to the probability of the object under a uniform distribution
LO.2 Statistical Approaches 665
(weighted by ,\) minus the probability of the object under the distribution of
the normal data points (weighted by 1- )). Consequently,the set of anomalies
will tend to consist of those objects that have significantly higher probability
under a uniform distribution rather than under the distribution of the normal
objects.
In the situation just discussed,the approach described by Algorithm 10.1
is roughly equivalent to classifying objects with a low probability under the
distribution of normal objects as outliers. For example, when applied to the
points in Figure 10.3, this technique would classify points A and B (and other
points far from the mean) as outliers. However, if the distribution of the nor-
mal objects changessignificantly as anomalies are removed or the distribution
of the anomalies can be modeled in a more sophisticated manner, then the
results produced by this approach will be different than the results of simply
classifying low-probability objects as outliers. Also, this approach can work
even when the distribution of obiects is multimodal.
a @
@
6n @.
@ o I @ @ B
@oo OO 6@
o^^ ooo @oo
^
o t-J &
6
@o B
o
@
o a 6
6 o
@o a@
Outlier Outlier
Score Score
Figure10,4. Outlier
scorebasedon the Figure 10.5.Outlierscore
based
onthedis-
distance
tofifthnearest
neiohbor. tancetothefirstnearest
neighbor.
Nearby
out-
liershavelowoutlier
scores.
.c
a c
a
a
ao
@@ @@B
& @6 @ @@
@ oE
6@e oO
o ^w^ ^ o
o08
6
o
6
@@
Outlier Outlier
Score Score
Figure 10.6.Outlier
score
basedondistance Figure10.7.Outlier
scorebasedonthedis-
to thefifthnearest
neighbor.
A smallcluster fifth
tancetothe nearest neiohbor.
Clusters
of
becomes anoutlier. differing
density.
point D. In fact, the outlier score for D is much lower than many points that
are oart of the loose cluster.
:(ffi)-'
d,ensi,ty(x,-l (10.6)
where l/(x, k) is the set containing the k-nearest neighborsof x, ll/(x, k)l is
the size of that set, and y is a nearest neighbor.
Another definition of density is the one used by the DBSCAN clustering
algorithm. SeeSection 8.4.
Definition 10.7 (Count of Points within a Given Radius). The density
around an object is equal to the number of objects that are within a specified
distance d of the object.
The parameter d needsto be chosencarefully. If d is too small, then many
normal points may have low density and thus a high outlier score. If d is
chosento be large, then many outliers may have densities (and outlier scores)
that are similar to normal points.
Detecting outliers using any of the definitions of density has similar char-
acteristics and limitations to those of the proximity-based outlier schemes
discussedin Section 10.3. In particular, they cannot identify outliers correctly
when the data contains regions of differing densities. (See Figure 10.7.) To
correctly identify outliers in such data sets, we need a notion of density that
is relative to the neighborhood of the object. For example, point D in Figure
LO.4 Density-Based Outlier Detection 669
10.7 has a higher absolute density, according to Definitions 10.6 and 10.7, than
point A, but its density is lower relative to its nearest neighbors.
There are many ways to define the relative density of an object. One
method that is used by the SNN density-basedclustering algorithm is discussed
in Section 9.4.8. Another method is to compute the relative density as the ratio
of the density of a point x and the averagedensity of its nearest neighbors y
as follows:
density(x, k)
&ueragerelat'iue densi,ty(x,k) : (10.7)
k) llN (x' k)l'
Dyen(*,r)densi'tv(v,
o.uc
oo
On
t
B
o
Figure10.8.Relative (LOF)outlier
density scores points
fortwo-dimensional of Figure
10.7.
these points are shown in Figure 10.8. The shading of each point is determined
by its score; i.e., points with a high score are darker. We have labeled points
A, C, and D, which have the largest outlier scores,with these values. Respec-
tively, these points are the most extreme outlier, the most extreme point with
respect to the compact set of points, and the most extreme point in the loose
set of points.
4.6
a
3.5
@@
2.5
Oa
I
1.5
B
a 1
05
Distance
Figure ofpoints
10.9.Distance fromclosest
centroid.
769 70
o
60
50
40
30
6
f:) 20
x
10
BiJXffi
10.10.Relative
Figure ofpoints
distance fromclosest
centroid.
674 Chapter 10 Anomaly Detection
dimensional data, while Shyu et al. [518] use an approach based on principal
components. A theoretical discussion of outlier removal in high-dimensional
space can be found in the paper by Dunagan and Vempala [475]. The use
of information measuresin anomaly detection is described by Lee and Xiang
1504],while an approach based on the 12 measure is given by Ye and Chen
[520].
Many different types of classification techniques can be used for anomaly
detection. A discussion of approachesin the area of neural networks can be
found in papers by Hawkins et al. [485], Ghosh and Schwartzbard 1479],and
Sykacek [519]. Recent work on rare class detection includes the work of Joshi
et al. [490-494]. The rare class problem is also sometimes referred to as the
imbalanced data set problem. Of relevanceare an AAAI workshop (Japkowicz
1488]),an ICML workshop (Chawla et al. [a71]),and a specialissueof SIGKDD
Explorations (Chawla et al. la72l).
Clustering and anomaly detection have a long relationship. In Chapters 8
and 9, we considered techniques, such as BIRCH, CURE, DENCLUE, DB-
SCAN, and SNN density-based clustering, which specifically include tech-
niques for handling anomalies. Statistical approaches that discuss this re-
lationship are described in papers by Scott [516] and Hardin and Rocke [482].
In this chapter, we have focused on basic anomaly detection schemes.We
have not considered schemesthat take into account the spatial or temporal
nature of the data. Shekhar et al. [517] provide a detailed discussion of the
problem of spatial outliers and present a unified approach to spatial outlier
detection. The issue of outliers in time series was first considered in a sta-
tistically rigorous way by Fox [478]. Muirhead [508] provides a discussion of
different types of outliers in time series. Abraham and Chuang [ 6t] propose a
Bayesian approach to outliers in time series,while Chen and Liu [473] consider
different types of outliers in time seriesand propose a technique to detect them
and obtain good estimates of time seriesparameters. Work on finding deviant
or surprising patterns in time seriesdatabaseshas been performed by Jagadish
et aI. [487] and Keogh et al. [495]. Outlier detection based on geometric ideas,
such as the depth of convex hulls, has been explored in papers by Johnson et
al. [489],Liu et al. [505],and Rousseeuwet al. [51a].
An important application area for anomaly detection is intrusion detection.
Surveys of the applications of data mining to intrusion detection are given by
Lee and Stolfo [502] and Lazarevic et al. [501]. In a different paper, Lazarevic
et al. [500] provide a comparison of anomaly detection routines specific to
network intrusion. A framework for using data mining techniques for intrusion
detection is provided by Lee et al. [503]. Clustering-based approachesin the
Bibliography 677
area of intrusion detection include work by Eskin et al. 14771,Lane and Brodley
[499], and Portnoy et al. [509].
Bibliography
f461] B. Abraham and A. Chuang. Outlier Detection and Time Series Modeling. Techno-
metrics, Sl(\:2aI 248, May 1989.
14621 C. C. Aggarwal and P. S. Yu. Outlier detection for high dimensional data. In Proc.
of 2001 ACM-SIGMOD Intl. Conf. on Managernent of Data, pages 37-46. ACM Press,
2001.
f463] V. Barnett. The Study of Outliers: Purpose and Model. Applied Stati.stics, 27(3):
242 250, 1978.
'in Statistical Data. Wiley Series in Probability and
[464] V. Barnett and T. Lewis. Outliers
Statistics. John Wiley & Sons, 3rd edition, April 1994.
[465] S. D. Bay and M. Schwabacher. Mining distance-basedoutliers in near linear time with
randomization and a simple pruning rule. In Proc. of the 9th Intl. Conf. on Knowledge
Discouerg and Data M'ining, pages 29 38. ACM Press, 2003.
f 4 6 6 ] R . J . B e c k m a n a n d R . D . C o o k . ' O u t l i e r . . . . . . . . . . s ' . T e c h n o r n e t r i c s , 2 S ( 2 ) : 1 1194 9 , M a y
1983.
[467] R. J. Beckman and R. D. Cook. f'Outlier..........s']:Response. Technometrics,25(2):
161-163, May 1983.
[468] M. M. Breunig, H.-P. Kriegel, R. T. Ng, and J. Sander. OPTICS-OF: Identifying
Local Outliers. In Proceedings of the Thi,rd European Conference on Princ'iples of Data
Mining and Knowledge D'iscouery, pages 262-270. Springer-Verlag, 1999.
[469] M. M. Breunig, H.-P. Kriegel, R. T. Ng, and J. Sander. LOF: Identifying density-based
local outliers. In Proc. of 2000 ACM-SIGMOD Intl. Conf. on Management of Data,
pages 93-104. ACM Press, 2000.
14701A. Chaudhary A. S. Szalay, and A. W. Moore. Very fast outlier detection in large
multidimensional data sets. In Proc. ACM SIGMOD Workshop on Research Issues 'in
Data Min'ing and Knowledge D'iscouery @MKD),2002.
f471] N. V. Chawla, N. Japkowicz, and A. Kolcz, editors. Workshop on Learni'ng from
Imbalanced Data Sets II, 20th IntI. Conf. on Machine Leamuing,2000. AAAI Press.
[472] N. V. Chawla, N. Japkowicz, and A. Kolcz, editors. SIGKDD Erplorations Newsletter,
Speci,al'issueon learn'ingfrom imbalanced datasets,volume 6(1), June 2004. ACM Press.
1473] C. Chen and L.-M. Liu. Joint Estimation of Model Parameters and Outlier Effects in
Time Series. Jout'nal of the American Stati.stical Assoc'iation, 88(421):284-297, Marc}l
1993.
1474] L. Davies and U. Gather. The Identification of Multiple Outliers. Journal of the
Am eri,can Stati,sti,cal A ssoc'iation, 88 ( 423) :782-792, September I 993.
14751 J. Dunagan and S. Vempala. Optimal outlier removal in high-dimensional spaces.
Journal of Computer and System Sciences, Special Issue on STOC 2001, 68(2):335-
373, March 2004.
[476] E. Eskin. Anomaly Detection over Noisy Data using Learned Probability Distributions.
In Proc. of the 17th Intl. Conf. on Machine Learning, pages 255 262,2000.
[477] E Eskin, A. Arnold, M. Prera,u, L. Portnoy, and S. J. Stolfo. A geometric framework for
unsupervised anomaly detection. In Applications of Data Mini,ng in Computer Securitg,
pages 78-100. Kluwer Academics, 2002.
678 Chapter 10 Anomaly Detection
[478] A. J. Fox. Outliers in Time Series. Journal of the Royal Statisti,cal Society. Series B
( M ethodological), 34(3) :350-363, 1972.
14791 A. Ghosh and A. Schwartzbard. A Study in Using Neural Networks for Anomaly and
Misuse Detection. In 8th USENIX Security Symposiurn, August 1gg9.
1480] R. Gnanadesikan and J. R. Kettenring. Robust Estimates, Residuals, and Outlier
Detection with Multiresponse Data. B'iometrics, 28(I):8I-I2 , March Ig72.
[481] F. Grubbs. Procedures for Testing Outlying Observations. Annal o.f Mathemati.cal
Statistics, 2I(l):27 58, March 1950.
[482] J. Hardin and D. M. Rocke. Outlier Detection in the Multiple Cluster Setting using
the Minimum Covariance Determinant Estimator. Computational Statisti,cs and Data
Analg sis, 44:625-638, 2004.
f483] D. M. Hawkins. Identi,fication of Outliers. Monographs on Applied Probability and
Statistics. Chapman & Hall, May 1980.
'fOutlier..........s]':
f484] D. M. Hawkins. Discussion. Technometrics,2b(2):Ib5_156,May
1983.
1485] S. Hawkins, H. He, G. J. Williams, and R. A. Baxter. Outlier Detection Using Repli-
cator Neural Networks. rn DawaK 2000: Proc. of the lth Intnl. conf. on Data Ware-
hous'ing and Knowledge Discouerg, pages 170 180. Springer-Yerlag,2OO2.
f486] V. J. Hodge and J. Austin. A Survey of Outlier Detection Methodologies. Arti,ficial
Intelligence Reui,ew,22:85 126, 2004.
[487] H. V. Jagadish, N. Koudas, and S. Muthukrishnan. Mining Deviants in a Time Series
Database. In Proc. of the 25th VLDB Conf., pages 102-113, 1999.
f4881 N. Japkowicz, editor. Workshop on Learn'ing from Imbalanced Data Sets I, Seuenteenth
National Conference on Artificial Intelligence, Published, as Techn'ical Report WS-00-05,
2000. AAAI Press.
[489] T. Johnson, I. Kwok, and R. T. Ng. Fast Computation of 2-Dimensional Depth Con-
tours. In KDD98, pages 224-228, 1998.
f490] M. V. Joshi. On Evaluating Performance of Classifiers for Rare Classes. In Proc. of
the 2002 IEEE IntI. Conf. on Data Mining, pages 641 044,2002.
[491] M. V. Joshi, R. C. Agarwal, and V. Kumar. Mining needle in a haystack: Classifying
rare classes via two-phase rule induction. In Proc. of 2001 ACM-SIGM)D Intt. Conf.
on Managernent of Data, pages 91-102. ACM Press, 2001.
1492] M' V. Joshi, R. C. Agarwal, and V. Kumar. Predicting rare classes: can boosting make
any weak learner strong? rn Proc. of 2002 ACM-SIGM)D IntI. Conf. on Management
of Data, pages 297-306. ACM Press, 2002.
[493] M. V. Joshi, R. c. Agarwal, and v. Kumar. Predicting Rare classes: comparing
Two-Phase Rule Induction to Cost-Sensitive Boosting. In Proc. of the 6th European
conf. of Princi'ples and Practice of Knowledge Di,scoueryin Databases, pages 237 24g.
Springer-Verl ag, 2002.
1494] M. V. Joshi, V. Kumar, and R. C. Agarwal. Evaluating Boosting Algorithms to Classify
Rare Classes: Comparison and Improvements. In Proc. of the 2001 IEEE Intl. Conf.
on Data M,ining, pages 257 264,200I.
[495] E. Keogh, S. Lonardi, and B. Chiu. Finding Surprising Patterns in a Time Series
Database in Linear Time and Space. rn Proc. of the 8th IntI. conf. on Knowledge
Discouery and Data Mining, Edmonton, Alberta, Canada, JuJy 2002.
[496] E. M. Knorr and R. T. Ng. A Unified Notion of Outliers: Properties and Computation.
rn Proc. of the Srd IntI. conf . on Knowledge D'iscouerg and Data Mining, pages 2lg-222,
1997.
Bibliography 679
1497 E. M. Knorr and R. T. Ng. Algorithms for Mining Distance-Based Outliers in Large
Datasets. In Proc. of the Zlth VLDB Conf., pages 392 403,24-27 1998.
[498] E. M. Knorr, R. T. Ng, and V. Tucakov. Distance-based outliers: algorithms and
applications. The V L D B J ournal, 8(3-4):237-253, 2000.
1499] T. Lane and C. E. Brodley. An Application of Machine Learning to Anomaly Detection.
In Proc. 20th NIST-NCSC Nati,onal Informat'ion Systems Security Conf.,pages 366 380,
1997.
[500] A. Lazarev\c,L.Ertoz, V. Kumar, A. Ozgur, and J. Srivastava. A Comparative Study
of Anomaly Detection Schemes in Network Intrusion Detection. In Proc. of the 2003
SIAM Intl. Conf. on Data Mini,ng,2OO3.
[501] A. Lazarevic, V. Kumar, and J. Srivastava. Intrusion Detection: A Survey. In Manag-
ing Cyber Threats: Issues, Approaches and Challenges, pages 19-80. Kluwer Academic
Publisher, 2005.
[502] W. Lee and S. J. Stolfo. Data Mining Approaches for Intrusion Detection. In 7th
USENIX Security Sympos'ium, pages 26-29, January 1998.
[503] W. Lee, S. J. Stolfo, and K. W. Mok. A Data Mining Framework for Building Intrusion
Detection Models. In IEEE Sgmposium on Securitg and Priuacg, pages 120-132, 1999.
[504] W. Lee and D. Xiang. Information-theoretic measures for anomaly detection In Proc.
of the 2001 IEEE Syrnpos'ium on Security and Priuacy, pages 130-143, May 2001.
1505] R. Y. Liu, J. M. Parelius, and K Singh. Multivariate analysis by data depth: descrip-
tive statistics, graphics and inference. Annals of Stat'istics,27(3):783-858, 1999.
1506] M. Markou and S. Singh. Novelty detection: A review part 1: Statistical approaches.
Signal Processi,ng, 83(L2):248I 2497, 2003.
15071M. Markou and S. Singh. Novelty detection: A review part 2: Neural network based
approaches. Signal Processi,ng, 83(12):2499 2521, 2003.
[508] C. R. Muirhead. Distinguishing Outlier Types in Time Series. Journal of the Royal
Stati,stical Soci,ety.Series B (Methodologi,cal),48(l):39 47, 1986.
[509] L. Portnoy, E. Eskin, and S. J. Stolfo. Intrusion detection with unlabeled data using
clustering. In In ACM Workshop on Data Mi.ning Appli,ed to Securi'ty,200I.
[510] S. Ramaswamy, R. Rastogi, and K Shim. Efficient algorithms for mining outliers from
large data sets. In Proc. of 2000 ACM-SIGMOD IntI. Conf. on Management of Data,
pages 427 438. ACM Press, 2000.
1511] D. M. Rocke and D. L. Woodruff. Identification of Outliers in Multivariate Data.
Journal oJ the Ameri,can Stati,stical Associat'ion, 91(435):1047-106t, September 1996.
f512] B. Rosner. On the Detection of Many Outliers. Technometrics, 17(3):227 227, 1975.
[513] P. J. Rousseeuw and A. M. Leroy. Robust Regression and Outlier Detection. Wlley
Series in Probability and Statistics. John Wiley & Sons, September 2003.
[514] P. J. Rousseeuw, I. Ruts, and J. W. T[rkey. The Bagplot: A Bivariate Boxplot. ?he
American Statist'ic'ian, 53(4) :382-387, November 1999.
1515] P. J. Rousseeuw and B. C. van Zomeren. Unmasking Multivariate Outliers and Lever-
age Points. Journal of the American Stati,st'icalAssociation,85(411):633-639, September
1990.
[516] D. W. Scott. Partial Mixture Estimation and Outlier Detection in Data and Regres-
sion. In M. Hubert, G. Pison, A. Struyf, and S. V. Aelst, editors, Theory and' Appli''
cat'ions of Recent Robust Methods, Statistics for Industry and Technology. Birkhauser,
2003.
[517] S. Shekhar, C.-T. Lu, and P. Zhang. A Unified Approach to Detecting Spatial Outliers.
G eoInf orrnatica, 7 (2) :139-166, June 2003.
680 Chapter 10 Anomaly Detection
1518] M.-L. Shyu, S.-C. Chen, K. Sarinnapakorn, and L. Chang. A Novel Anomaly Detection
Scheme Based on Principal Component Classifier. In Proc. of the 2003 IEEE Intl. Conf.
on Data Mi,n'ing, pages 353 365, 2003.
1519] P. Sykacek. Equivalent error bars for neural network classifiers trained by bayesian
inference. ln Proc. of the European Symposium on Artifi,cial Neural Networks, pages
l2t 126, 1997.
f5201 N. Ye and Q. Chen. Chi-square Statistical Profiling for Anomaly Detection. In Proc.
of the 2000 IEEE Workshop on Inforrnation Assurance and Securitg, pages 187 193,
June 2000.
LO.7 Exercises
1 . Compare and contrast the different techniques for anomaly detection that were
presentedin Section I0.7.2. In particular, try to identify circumstancesin which
the definitions of anomalies used in the different techniques might be equivalent
or situations in which one might make sense, but another would not. Be sure
to consider different types of data.
4 . Association analysis can be used to find anomalies as follows. Find strong asso-
ciation patterns, which involve some minimum number of objects. Anomalies
are those objects that do not belong to any such patterns. To make this more
concrete, we note that the hyperclique association pattern discussedin Section
6.8 is particularly suitable for such an approach. Specifically, given a user-
selected h-confidencelevel, maximal hyperclique patterns of objects are found.
All objects that do not appear in a maximal hyperclique pattern of at least size
three are classified as outliers.
LO.7 Exercises 681
(a) Does this technique fall into any ofthe categoriesdiscussedin this chapter?
If so, which one?
(b) Name one potential strength and one potential weaknessofthis approach.
(a) For a set of 1,000,000values, how likely are we to have outliers according
to the test that says a value is an outlier if it is more than three standard
deviations from the average? (Assume a normal distribution.)
(b) Does the approach that states an outlier is an object of unusually low
probability need to be adjusted when dealing with large data sets? If so,
how?
7/, I -(x-ptx-1(x-!)
Problxl:- s- 2 (10.8)
(t/2r)-lEl'/'
Using the sample mean x and covariance matrix S as estimates of the mean p
and covariance matrix !, respectively, show that the logprob(x) is equal to the
Mahalanobis distance between a data point x and the sample mean x plus a
constant that does not depend on x.
1 0 . compare the following two measures of the extent to which an object belongs
to a cluster: (1) distance of an object from the centroid of its closest cluster
and (2) the silhouette coefficient described in Section 8.5.2.
(a) The points at the bottom of the compact cluster shown in Figure 10.10
have a somewhat higher outlier score than those points at the top of the
compact cluster. Why?
(b) Suppose that we choose the number of clusters to be much larger, e.g.,
10. Would the proposed technique still be effective in finding the most
extreme outlier at the top of the figure? Why or why not?
(c) The use of relative distance adjusts for differences in density. Give an
example of where such an approach might lead to the wrong conclusion.
12, If the probability that a normal object is classified as an anomaly is 0.01 and
the probability that an anomalous object is classifiedas anomalous is 0.99, then
LO.7 Exercises 683
what is the false alarm rate and detection rate if 99Yaof the objects are normal?
(Use the definitions given below.)
14, Consider a group of documents that has been selected from a much larger set
of diverse documents so that the selected documents are as dissimilar from one
another as possible. If we consider documents that are not highly related (con-
nected, similar) to one another as being anomalous, then all of the documents
that we have selected might be classified as anomalies. Is it possible for a data
set to consist only of anomalous objects or is this an abuse of the terminology?
1 5 . Consider a set of points, where most points are in regions of low density, but a
few points are in regions of high density. If we define an anomaly as a point in
a region of low density, then most points will be classified as anomalies. Is this
an appropriate use of the density-based definition of an anomaly or should the
definition be modified in some way?
1 6 . Consider a set of points that are uniformly distributed on the interval 10,1]. Is
the statistical notion of an outlier as an infrequently observed value meaningful
for this data?
(a) Discuss the behavior of each of the anomaly detection techniques described
in this chapter. (If possible, try this for real data sets and algorithms.)
(b) What do you think the behavior of an anomaly detection algorithm should
be when applied to a set of anomalous objects?
LinearAlgebra
This appendix provides a brief introduction to linear alp;ebrawith a focus on
topics that are relevant to the material in this text. Wr begin by describing
vectors, which can be used to represent both data objects and attributes. We
then discuss matrices, which can be used both to reprer;entdata sets and to
describe transformations on them.
A.1 Vectors
A.1.1 Definition
Figure
A.1.Twovectors
andtheirsumanddifference.
best illustrated graphically, and vector subtraction and addition are shown in
Figures A.1(b) and A.1(c), respectively.Like the addition of numbers,vector
addition has some familiar properties. If u, v, and w are three vectors, then
these properties can be described as follows:
We now define what it means for two vectors to be orthogonal. For simplicity,
we restrict ourselvesto Euclidean vector spaces,although the definitions and
results are easily generalized. We begin by defining the dot product of two
vectors.
Definition A.1 (Dot Product). The dot product u .v of two vectors, u
and v, is given by the following equation:
rL
\-
ll'V :
)_rUlui.
(A.1)
t--1
vr4
proiection
FigureA.2, Orthogonal of vectoru.
ofvectorv inthedirection
where 0 is the angle between the two vectors. By grouping terms and reorder-
ing, this can be rewritten as
set of vectors that span the entire vector space. If we chooseour basis vectors
to be mutually orthogonal (independent), then we automatically obtain a lin-
early independent set since any two vectors that are orthogonal are linearly
independent.
/\uv
COS(tl.\//:' -
'
, (A.4)
ll,'ll llull'
This similarity measure does not take into account the magnitude (length) of
the vectors, but is only concerned with the degreeto which two vectors point
in the same direction. In terms of documents, this means that two documents
are the same if they contain the same terms in the same proportion. Terms
that do not appear in both documents play no role in computing similarity.
We can also simply define the distance between two vectors (points). If
u and v are vectors, then the Euclidean distance between the two vectors
(points) is simply
di,st(r,v) : (t -.r) .(t -.r). (A.5)
This type of measureis more appropriate for the Iris data, since the magnitude
of the various components of the vectors does make a difference in whether
they are consideredto be similar.
4.2 Matrices 691
Also, for vector data, it is meaningful to compute the mean of the set of
vectors, which is accomplished by computing the mean of each component.
Indeed, some clustering approaches, such as K-means (Chapter 8) work by
dividing the data objects into groups (clusters) and characterizing each cluster
by the mean of the data objects (data vectors). The idea is that a good cluster
is one in which the data objects in the cluster are close to the mean, where
closenessis measured by Euclidean distance for data like the Iris data and by
cosine similarity for data like document data.
Other common operations that are performed on data can also be thought
of as operations on vectors. Consider dimensionality reduction. In the sim-
plest approach, someof the componentsof the data vector are eliminated, while
leaving the others unchanged. Other dimensionality reduction techniques pro-
duce a new set of components (attributes) for the data vector that are linear
combinations of the previous components. Still other methods changethe vec-
tors in more complicated ways. Dimensionality reduction is discussedfurther
in Appendix B.
For certain areasofdata analysis, such as statistics, the analysis techniques
are expressedmathematically in terms of operations on data vectors and the
data matrices that contain these data vectors. Thus, a vector representation
brings with it powerful mathematical tools that can be used to represent,
transform, and analyze the data.
In the remainder of this appendix, we will complete the story, by discussing
matrices.
4.2 Matrices
4.2.L Matrices: Definitions
12 71
":l?gN A7:
Ll,)
692 Appendix A Linear Algebra
L1 2) L2 el L3 11.1
Matrix addition has the following properties:
In other words, we take the dot product of the transpose of u with each
row vector of A. In the following example, notice that the number of rows in
694 Appendix A Linear Algebra
[e r] lrl
lttt:t
frzl I
Ll 2)L2l Lel
We can similarly define the multiplication of a matrix by a row vector on
the left side.
Definition ,4'.6 (Multiplication of a Matrix by a Row Vector). The
product of a 1 by m row matrix u and an m by n matrix A is the 1 by n row
matrix v: uA, whose entries are given by the following equation.
In other words, we take the dot product of the row vector with the trans-
pose of each column vector of A. An example is given below.
In words, the i,jth entry of C is the dot product of the i,th row vector of A
and the transpose of the jth column vector of B.
fr rl fs 41 ltz 2r1
tttt:tl
Ll 2)12 el Le 22)
Matrix multiplication has the following properties:
The set of all transformed row vectors of a matrix A is called the row
space of A because the row vectors of the matrix, or some subset of
them, form a basis for the subspaceof transformed row vectors. This is
evident from the following equation, which expressesthe product of a 1
by m row vector r: [rr, ...,urnl and an mby n matrix A as a linear
combination of the rows of the matrix.
TIL
^ \-a
V: 11A: ,tL;.d;.* (A.11)
)
ZJ
o The set of all transformed column vectors is called the column space
of A. The column vectors of the matrix, or some subset of them, form
a basis for the subspace of transformed column vectors. This is clear
from the following equation, which expressesthe product of an n by I
c o l u m nv e c t o r r : lrr,...,un]T and an mby n matrix A as a linear
combination of the columns of the matrix.
TL
^S-
v: Au: ) .uja*j (A.12)
j:r
The dimension of the column space tells us the number of linearly inde-
pendent columns of A.
o The left nullspace is the set of row vectors that the matrix maps to 0.
o The right nullspace (or more commonly, just nullspace) is the set of
column vectors that the matrix maps to 0.
Au: )u (A.13)
In other words, eigenvectors are the vectors that are unchanged, except
for magnitude, when multiplied by A. The eigenvalues are the scaling fac-
tors. This equation can also be written as (A - )I)u : 0.
For square matrices, it is possible to decomposethe matrix using eigenval-
ues and eigenvectors.
A: UAU-I (A.14)
698 Appendix A Linear Algebra
The column vectors of V, v1 , . . . ,yn are the right singular vectors, while
the columns of U are the left singular vectors. The diagonal elements of
E, the singular value matrix, are typically written as or)...,on and are
called the singular values of A. (This use of o should not be confused with
the use of o to represent the standard deviation of a variable.) There are at
most rank(A) < min(m,n) non-zero singular values.
It can be shown that the eigenvectorsof A"A are the right singular vectors
(i.e., the columns of V), while the eigenvectorsof AAT are the left singular
vectors (i.e., the columns of U). The non-zero eigenvaluesof A"A and AA"
are the o|, i.e., the squares of the singular values. Indeed, the eigenvalue
decomposition of a square matrix can be regarded as a special caseof singular
value decomposition.
The singular value decomposition (SVD) of a matrix can also be expressed
with the following equation. Note that while u;vfl might look like a dot
product, it is not, and the result is a rank I mby n matrix.
rank(A)
^ \- 'l-
A: ) o;u;v; (A.16)
;-1
We can represent a data set as a data matrix, where each row is a data ob-
ject and each column is an attribute. (We can, with equal validity, have
attributes as rows and objects as columns.) Matrix representation provides a
compact and well-structured representation for our data and permits the easy
manipulation of the objects or attributes of the data through various matrix
operations.
Systemsof linear equations are one very common example of the usefulness
of the matrix representation of data. A system of linear equations can be
written as the matrix equation Ax : b and solved using matrix operations.
atrt*atzrzl...ta1nr, u1
:
a r n 1 " rl a
1 ^. 2 r 2 + . . . + a m n f i n : b*
D) require the solution of a least squares problem. It can be shown that the
least squaressolution of the equation Ax: b is x : (A"A)-1A"b.
Singular value and eigenvalue decomposition are also very useful in an-
alyzing data, particularly in the area of dimensionality reduction, which is
discussedin Appendix B. Note that noise reduction can also occur as a side
effect of dimensionality reduction.
While we have given a few examples of the application of linear algebra,
we have omitted many more. Examples of other areas where linear algebra is
important in the formulation and solution of problems include solving systems
of differential equations, optimization problems (such as linear programming),
and graph partitioning.
Bibliography
f521] J. W. Demmel. Applied Numerical Linear Algebra. SIAM Press, September 1997.
1522] G. H. Golub and C. F. Van Loan. Matrir Cornputat'ions. Johns Hopkins University
Press. 3rd edition. November 1996.
f523] G. Strang. L,inear Algebra anil Its Applications. Harcourt Brace & Company, Orlando,
FL, 3rd edition. 1986.
Dimensionality
Reduction
This appendix considersvarious techniques for dimensionality reduction. The
goal is to expose the reader to the issuesinvolved and to describe some of the
more common approaches. We begin with a discussion of Principal Compo-
nents Analysis (PCA) and Singular Value Decomposition (SVD). These meth-
ods are described in some detail since they are among the most commonly
used approaches and we can build on the discussion of linear algebra in Ap-
pendix A. However, there are many other approachesthat are also employed
for dimensionality reduction, and thus, we provide a quick overview of several
other techniques. We conclude with a short review of important issues.
Mathematical Details
In words, s;7 is the covariance of the i,th andjth attributes (columns) of the
data.
The covarianceof two attributes is defined in Appendix C, and is a measure
ofhowstronglytheattributesvarytogether.Ifi.:j,i.e.,theattributesarethe
same, then the covariance is the variance of the attribute. If the data matrix
D is preprocessedso that the mean of each attribute is 0, then S : D"D.
A goal of PCA is to find a transformation of the data that satisfies the
following properties:
2. The attributes are ordered with resoect to how much of the variance of
the data each attribute captures.
3. The first attribute captures as much of the variance of the data as pos-
sible.
B.1 PCA and SVD 703
A transformation of the data that has these properties can be obtained by using
eigenvalueanalysis of the covariancematrix. Let ,\1, . . . , \n be the eigenvalues
of S. The eigenvaluesare all non-negative and can be ordered such that
)1 ) A2 ) . . . \m-r > x^. (Covariance matrices are examples of what are
called positive semidefinite matrices, which, among other properties, have
non-negative eigenvalues.)Let U : [rr,. . . , ur] be the matrix of eigenvectors
of S. These eigenvectorsare ordered so that the ith eigenvector corresponds
to the ith largest eigenvalue. Finally, assume that data matrix D has been
preprocessedso that the mean of each attribute (column) is 0. We can make
the following statements.
o The data matrix D' : DU is the set of transformed data that satisfies
the conditions posed above.
o The sum of the variance of the original attributes is equal to the sum of
the variance of the new attributes.
o The new attributes are called principal components; i.e., the first new
attribute is the first principal component, the second new attribute is
the second principal component, and so on.
-1
-2
-3
-5
-2024 10 -6
thedata.
Figure8.1. UsingPCAto transform
Example B.2 (Iris Data). This example uses the Iris data set to demon-
strate the use of PCA for dimensionality reduction. This data set contains
150 data objects (flowers); there are 50 flowers from each of three different
Iris species: Setosa, Versicolour, and Virginica. Each flower is described by
four attributes: sepal length, sepal width, petal length, and petal width. See
Chapter 3 for more details.
Figure 8.2(a) shows a plot of the fraction of the overall variance accounted
for by each eigenvalue (principal component) of the covariance matrix. This
type of plot is known as a scree plot and is useful for determining how many
principal components need to be kept to capture most of the variability of the
data. For the Iris data, the first principal component accounts for most of
the variation (92.5%), the second for only 5.3T0,and the last two components
for just 2.2%0.Thuq keeping only the fi.rst two principal components preserves
most of the variability in the data set. Figure 8.2(b) showsa scatter plot of the
Iris data based on the first two principal components. Note that the Setosa
flowers are well separated from the Versicolour and Virginica flowers. The
latter two sets of flowers, while much closer to each other, are still relatively
well separated.
B.1 PCA and SVD 7O5
0.9
0.8
n '7
o
o
o
0.6
G
o AE
o
o 0.4
E
Lr
0.3
0.2
0.1
0
123
Eigenvalue
(a) Fractionof varianceaccounted
for by eachprincipalcomponent.
* * E o-
* -tr
**
**E
E
*
t-2-1012
FirstPrincipalComponet
Figure
8.2,PCAapplied
tothelrisdataset.
706 Appendix B Dimensionalitv Reduction
8.T.2 SVD
PCA is equivalent to an SVD analysis of the data matrix, once the mean
of each variable has been removed. Nonetheless,it is informative to look at
dimensionality reduction from the SVD point of view, since it is not always
desirable to remove the mean from data, especially if the data is relatively
sparse.
Mathematical Details
rank(A)
A- t oppf,:UEV". (B.2)
i:l
where oi is the ith singular value of A (the ith diagonal entry of )), u6 is the
ith left singular vector of A (the ith column of U), and the v; is the i.th right
singular vector of A (the frh column of V). (See Section A.2.5.) An SVD
decomposition of a data matrix has the following properties.
o Patterns among the attributes are captured by the right singular vectots,
i.e., the columns of V.
o Patterns among the objects are captured by the left singular vectors,
i.e., the columns of IJ.
articles from the Los Angeles T'imes. These articles come from 6 different sec-
tions: Entertainment, Financial, Foreign, Metro, National, and Sports. The
data matrix is a document-term matrix, where each row represents a docu-
ment and each column is a term (word). The value of the i,jth entry is the
number of times the jth term occurs in the iih document. The data was pro-
cessedusing standard techniques to remove common words, to adjust for the
different frequencieswith which terms appear?and to adjust for the different
lengths of documents. (See Section 2.3.7 for more details.)
An SVD analysis of the data was performed to find the first 100 singular
values and vectors. (For many data sets, it is too expensiveto find a full SVD
or PCA decomposition and often pointless since relatively few of the singular
values or eigenvaluesare required to capture the structure of the matrix.)
The largest singular value is associatedwith common terms that are frequent,
but not eliminated by the preprocessing. (It can happen that the strongest
patterns represent noise or uninteresting patterns.)
However, the patterns associated with other singular values were more
interesting. For example, the following are the top 10 terms (words) associated
with the strongest components in the second right singular vector:
These are all terms associatedwith sports. Not surprisingly, the documents
associatedwith the strongest components of the secondleft singular vector are
predominantly from the Sports section
The top 10 terms associated with the strongest components in the third
right singular vector are the following:
These are all financial terms, and, not surprisingly, the documents associated
with the strongest components in the third left singular vector are predomi-
nantly from the Financial section.
We reduced the dimensionality of the data using the second and third
singular vectors, i.e., D/: D x [vz,ve]. In other words, all documents were
expressedin terms of two attributes, one relating to Sports and one relating to
Finance. A scatter plot of documents is given by Figure B.3. For clarity, non-
Sports, non-Financial documents have been eliminated. The Sports documents
are shown in a lighter shade of gray, while the Financial documents are a
darker gray. The two different categories of documents are well separated for
708 Appendix B Dimensionality Reduction
0.6
Documents
E ot
c
E
o ne
E
f
a
.= v.1 a
a
a
c a'
,
"i.
the most part. Indeed, the Sports documents do not vary much with respect
to the Financial variable (component 3) and the Financial documents do not
vary much with respect to the Sports variable (component 2).
For PCA and SVD, the new attributes that are produced are linear combina-
tions of the original variables. With factor analysis, the goal is to expressthe
original variables as linear combinations of a small number of hidden or la-
tent attributes. The motivation is based on the following observation. Often
there are characteristics of data objects that are hard to measuredirectly, but
that seem to be related to measurable characteristics. One common example
is intelligence and performance on various types of IQ tests. Another common
8.2 Other Dimensionality Reduction Techniques 7Og
or equivalently by
example, there would be two latent factors: speed and strength. These corre-
spond to columns of F. Each athlete would be representedby a row of F with
entries recording the athlete's speed and strength. Each column of D would
correspond to one of the ten events of the decathlon, while each row again
corresponds to an athlete. The ijth entry of D is the performance of the i,th
athlete in the jth event. A would be a 10 by 2 matrix. If the first column of D
records the performance of the athletes on the 100-meter dash, then the per-
formanceof athlete i in the 100-meterdash is written as di1- \nft* \tzfn,
where fi1 is a value indicating the speed of athlete i, and f,;2 is a value indi-
cating the strength of athlete i. \tr and .\12 indicate how an athlete's speed
and strength, respectively, should be weighted to predict an athlete's perfor-
mance in the 100 meter dash. We would expect that .\11 would be relatively
large compared to )rz. Note that these weights are the same acrossall objects
(athletes).
Since all latent factors are involved in the determination of the value of any
original attribute, they are known as common factors. e is an error term
that accounts for the portion of the attributes that is not accounted for by the
common factors, and hence, the components of e are known as the specific
factors.
Example B.4 (Factor Analysis of Iris Data). This example is based on
the Iris data set. For this data, only a single factor could be found. The
flowers in the Iris data set are organized so that the first 50 flowers are of
speciesSetosa, the second 50 are Versicolour, and the last 50 are Virginica.
This single factor (attribute) is plotted against flower as shown in Figure B.4.
This factor seemsto capture the distinction among the three species.
()
:0
o
o
J
Setosa
I
I
I
Virginica
-1 i
50 100 150
Flower
Figure8.4. Plotoftheflower
ofthelrisdatasetversus
thesinglelatent
factor.
In step 2, the weight matrix W, whose entries are wij) is found by minimiz-
ing the squared approximation error as measured by the following equation.
W can be found by solving a least squares problem. (Such problems were
discussedin Appendix A.)
error(W): (B.5)
T
Step 3 performs the actual dimensionality reduction. Given the weight
matrix and a number of dimensiotrs,?, specified by the user, the algorithm
constructs a "neighborhood preserving embedding" of the data into the lower-
dimensional space. If y6 is the vector in the lower-dimensional space that
correspondsto x6 and Y is the new data matrix whose 'ith row is y;, then this
can be accomplished by finding a Y that minimizes the following equation.
o oo o @ o@.r6Doo@o& @@ooo o@
*
irx
EI
tr E
D D
-5-4-3-2-101234
First New Attribute
Figure8.5. Plotoftheflowers
ofthelrisdatasetbasedontwonewattributes
fromLLE.
Example B.5. the use of LLtr for dimensionality reduction is illustrated using
the Iris data set. Specifically, the data was projected to two dimensions. A
neighborhood of 30 points was used. A scatter plot of the projected data is
shown in Figure B.5. The data can also be projected to one dimension. In
that case, it looks much like Figure B.4.
distance between the objects after they have been transformed. ClassicalMDS
tries to assign each object to a p-dimensional point such that a quantity called
stress is minimized, where stress is defined as
t ,,2
Du \di, - ari)
stTess: (B.7)
FastMap
It is faster-linear complexity.
The FastMap algorithm identifies a pair of objects and then computes the
distance of each remaining object in this direction. This can be accomplished
using only pairwise distances by employing certain facts of geometry, namely,
the law of cosines. This distance is taken as the value of the first attribute. The
objects are then projected onto an (n - 1)-dimensional subspace. Again, this
can be performed using only pairwise distances. The processis then repeated.
The FastMap algorithm is initially applied to an entire data set. However,
if we keep track of the pairs of objects that are chosen at each step, then
we can incrementally apply FastMap to a new object. The only information
needed is the distance of the new object to the selectedpairs.
714 Appendix B Dimensionality Reduction
ISOMAP
MDS and PCA are not good at dimensionality reduction when the points have
a complicated, non-linear relationship to one another. (An exceptions is kernel
PCA-see bibliographic notes.) ISOMAP, which is an extension of traditional
MDS, was developedto handle such data sets. An example of the type of data
set that it can handle is given in Figure 8.6, which shows a plot of the "Swiss
roll" surface. A data set with this structure constitutes a two-dimensional
set of data in a three-dimensional space, but one that cannot be successfully
handled by PCA or MDS. However, ISOMAP can successfully analyze this
data set.
Algorithm B.2 outlines the basic ISOMAP algorithm. Nearest neighbors
**
o.4 * x*
lEn * * )t(
UU
n_ *
o u-z UN * * *
3
tr
D n *__. n *
tsn E
f
E
"n
tr
h#..#"
D* iF
2 -o.z tr tr-"E
r
.
1 F ^x x
ti.*x
x+*
c tr*
8 -0.+ ** *
o
a * It(
-0.6 tro
*
tr
-1.2
-4-3-2-101234
First New Attribute
example, the Euclidean distance between two cities on opposite sides of the
Earth is the length of a line segment that passesthrough the Earth, while the
geodesicdistance between two cities is the length of the shortest arc on the
surface of the Earth.
Example El.6. ISODATA was used to project the Iris data into two dimen-
sions. See Figure B.7. The result is similar to previous techniques.
interest include those by M. Belkin and P. Niyogi [525], Donoho and Grimes
[528],and Ye et al. [536, 537]
There are many other techniques that are often used for dimensionality
reduction or are strongly related to it. These areas include principal curves
and surfaces, non-linear PCA (including neural network approaches),vector
quantization, random projections, Independent Components Analysis (ICA),
Self-OrganizingMaps (SOM), projection pursuit, regression-basedapproaches,
genetic algorithms, and optimization-based approaches such as simulated or
deterministic annealing. Descriptions of these areas and additional references
can be found in two surveys on dimensionality reduction by Fodor [530] and
Carreira-Perpinan[526]. SOM is discussedin Section9.2.3.
Bibliography
1524] T. W. Anderson. An Introduct'ion to Multi,uariate Statistical Analysis. Wiley, 2nd
edition, July 2003.
15251 M. Belkin and P. Niyogi. Laplacian eigenmaps for dimensionality reduction and data
representation. Technical Report TR 2002-01, Department of Computer Science and
Statistics, University of Chicago, Jarluary 2002.
1526] M. A. Carreira-Perpinan. A Review of Dimension Reduction Techniques. Technical
Report CS-96 09, Dept. of Computer Science, University of Sheffield, January 1997.
15271J. W. Demmel. Appli,ed Numer,ical L,inear Algebra. SIAM Press, September 1997.
15281D. L. Donoho and C. Grimes. Hessian eigenmaps: Locally linear embedding techniques
for high-dimensional data. PNAS, 100(10):5591-5596, 2003.
[529] C. Faloutsos and K.-I. Lin. FastMap: A Fast Algorithm for Indexing, Data-Mining
and Visualization of Traditional and Multimedia Datasets. In Proc. of the 1995 ACM
SIGMOD IntI. Conf. on Management of Data, pages 163-174, San Jose, California,
June 1995.
[530] I. K. Fodor. A survey of dimension reduction techniques. Technical Report UCRL-ID-
t48494, LLNL, June 2002
f5311 L T. Jolliffe. Principal Component Anallls'is. Springer-Verlag, 2nd edition, October
2002.
[532] J. B. Kruskal and M. Wish. Multi.dzmensional Scali,ng. SAGE Publications, January
7978.
1533] S. T. Roweis and L. K. Saul. Nonlinear Dimensionality Reduction by Locally Linear
Embedding. Science, 290( 5500):2323-2326, 2000.
[534] B. Schcilkopf, A. J. Smola, and K.-R. Miiller. Nonlinear Component Analysis as a
Kernel Eigenvalue Problem. N eural Computat'ion, 10(5) : 1299-1319, 1998.
[535] J. B. Tenenbaum, V. d. Silva, and J. C. Langford. A Global Geometric Framework for
Nonlinear Dimensionality Reduction Science, 290(5500):2319-2323, 2OOO.
[536] J. Ye, R. Janardan, and Q. Li. GPCA: an efficient dimension reduction scheme for
image compression and retrieval. In Proc. of the 1Oth Intl. Conf. on Knowledge Discouery
and"Data Min'ing, pages 354 363, Seattle, Washington, August 2004. ACM.
[537] J. Ye, Q. Li, H Xiong, H. Park, R. Janardan, and V. Kumar. IDR/QR: an incremental
dimension reduction algorithm via QR decomposition. In Proc. of the 1Oth Intl. Conf.
on Knowledge Dzscouery and Data Mining, pages 364-373, Seattle, Washington, 2004.
ACM.
Probabilityand
Statistics
This appendix presentssome of the basic conceptsin probability and statistics
used throughout this book.
C.1 Probability
A random experirnent is the act of measuring a process whose outcome
is uncertain. Examples include rolling a die, drawing from a deck of cards,
and monitoring the types of traffic across a network router. The set of all
possible outcomes of a random experiment is known as the sample space,
f). For example,O: {1,2,3,4,5,6} is the samplespacefor rolling a die. An
event .D correspondsto a subset of these outcomes, i.e., E e f). For example
E : {2,4,6} is the event of observing an even number when rolling a die.
A probability P is a real-valued function defined on the sample space Q
that satisfiesthe following properties:
2. P(Q) :7.
kk
.p, Y
t l " ,I 'R
- . ' r: \ - p r\ n
u .t tr .
,?t
P ( X : u ) : P ( A : { e l ee Q ,X ( e ) : , } ) . (c.1)
X 0 1 2 3 4
P(X) rl76 4 l 1 6 6 1 7 6 4l16 1 1 1 6
For example, P(X - 2) :6/16 becausethere are six outcomesin which the
tail is observed twice during the four tosses. r
The function f (r) is known as the probability density function (pdf). Be-
cause / is a continuous distribution, the probability that X takes a particular
value r is always zero.
C.1 Probabilitv 72L
of probability
TableC.1. Examples (f (n + 1) : nf (n) andf (1) : 1)
functions.
Table C.1 shows some of the well-known discrete and continuous proba-
bility functions. The notion of a probability (mass or density) function can
be extended to more than one random variable. For example, 1f X and Y are
random variables, then p(X,Y) denotes their joint probability function. The
random variables are independent of each other if P(X,Y) : P(X) x P(Y).
If two random variables are independent, it means that the value for one vari-
able has no impact on the value for the other.
Conditional probability is another useful concept for understanding the
dependenciesamong random variables. The conditional probability for vari-
able Y given X, denoted as P()'lX), is defined as
P-(4J)
P f f t x 1, : (c.3)
P(X)
P( xlY) P( Y)
P(Ylx) : (c.4)
P(X)
expressedas follows:
kk
P(x): I P(x,Y): t P(xlV)P(Y). (c.5)
i:7 i:r
o 2 *: o 1 1 x- t t x ) ' l : \ ( r i - I r x ) 2P ( x : r i ) . (c.e)
t r x : 0 x 1 l 1 6 * 1 x 4 l L 6 + 2x 6 l 1 6 + 3x 4 1 1 6 -4t x r f 1 6 : 2 . (C.10)
Note that the variance of a random variable X is equivalent Cou(X, X). The
expected value of a function also has the following properties:
t. E[a]: a, if a is a constant.
2 . El a x l : a E l X l .
3. ElaX + bYl : aElXl + bElYl.
Based on these properties, Equations C.9 and C.11 can be rewritten as follows:
C.2 Statistics
To draw conclusionsabout a population, it is generally not feasible to gather
data from the entire population. Instead, we must make reasonableconclusions
about the population based on evidence gathered from sampled data. The
process of drawing reliable conclusions about the population based on sampled
data is known as statistical inference.
724 Appendix C Probability and Statistics
'\-r.
1N
(c.14)
N 'L"o
;-1
1 '\tr
r
.Sv : \-/ l-. - -t2 (c.15)
A/ - 1 /-t\1,x
i:I
Ewl:"[# # t : t,x,
Elxo]:f ' Nt,x (c.16)
\",):
where E[Xd - px since all the observationscome from the same distribution
with mean p76. This result suggeststhat the sample mean 7 approachesthe
population mearr p,x) especiaily when ly' is sufficiently large. In statistical
terms, the sample mean is called an unbiased estimator of the population
mean. It is possible to show that the variance of the sample mean is
P(h<g<9il:7-d., (c.18)
o4
0.3
0.25
o2
015
o.'r
0.05
-4 -3 -2-101234
Figure
C.1,Confidence ofa parameter.
interval
r-1"
Z:r-ltx x =N(0.1), (c.1e)
ox/t/N sx/{N
or equivalently,
3. Compute the value of 0 from the observeddata. Use the knowledgeof the
probability distribution to determine a quantity known as the p-value.
Z has a standard normal distribution with mean 0 and variance 1. The statistic
essentiallymeasuresthe differencebetween the observedsupport s(X) and the
m'insup threshold in units of standard deviations. Let ltr : 10000, s(X) :
17%o,and mi,nsup : 7070. The Z-statistic under the null hypothesis is Z :
(0.11 - 0.1)//0.09n0-000 : 3.33. From the probability table of a standard
normal distribution, a one-sided test witln Z : 3.33 correspondsto a p-value
of 4.34 x 10-4.
Suppose a : 0.001 is the desired significance level. a controls the prob-
ability of falsely rejecting the null hypothesis even though the hypothesis is
true (in the statistics literature, this is known as the Type 1 error). For ex-
ample, an a value of 0.01 suggeststhat there is one in a hundred chance the
discovered pattern is spurious. At each significance level a, there is a corre-
sponding threshold Zo, srch that when the Z value of a pattern exceeds the
threshold, the pattern is consideredstatistically significant. The threshold Zo
can be looked upin a probability table for the standard normal distribution.
For example, the choice of a :0.001 sets up a rejection region with Zo: 3.09.
Since p < o, or equivalently, Z ) Zo, lhe null hypothesis is rejected and the
pattern is consideredstatistically interesting.
Regression
Regression is a predictive modeling technique where the target variable to
be estimated is continuous. Examples of applications of regression include
predicting a stock market index using other economic indicators, forecasting
the amount of precipitation in a region based on characteristics of the jet
stream, projecting the total sales of a company based on the amount spent
for advertising, and estimating the age of a fossil according to the amount of
carbon-14 Ieft in the organic material.
D.1 Preliminaries
Let D denote a data set that contains ly' observations,
D : { ( x t , a t ) li : 1 , 2 , . . . ,l'r}.
Each xa correspondsto the set of attributes of the ith observation (also known
as the explanatory variables) and !, correspondsto the target (or response)
variable. The explanatory attributes of a regressiontask can be either discrete
or continuous.
Definition D.1 (Regression). Regressionis the task of learning a target
function / that maps each attribute set x into a continuous-valuedoutput 3t.
The goal of regression is to find a target function that can fit the input
data with minimum error. The error function for a regressiontask can be
73O Appendix D Regression
32.5
I
f
932
o
o
E
o
-
c 31.5
a
+
+T + .
3U.5
3 4 5 6 7 I 9 10 11
Heat Flux
where aJgand url are parameters of the model and are called the regression
coefficients. A standard approach for doing this is to apply the method of
least squares, which attempts to find the parameters (r,.16,&r1)
that minimize
the sum of the squared error
NN
:D[vo - a1r- u012,
ssE :Llou - f ("0)12 (D.4)
;-1 i:I
AI
OE - Z^ \\-.
lUr-arri-uo] :0
0uo ;-1
-lV
AE ^ S-.
-Z\[Ut - arri - ws]ri: Q (D.5)
0at
i:l
(::) : 1r,D::;,)
(d",?,u) (D.6)
Thus, the linear model that best fits the data in terms of minimizing the
SSEis
f (r) :33.17 - 0.22n-
Figure D.2 showsthe line corresponding
to this model.
q)
832
o
c
o)
F
.E 31.5
x
a
\.. .
30.5
678 I 10 11
Heat Flux
FigureD.2.A linearmodel
thatfitsthedatagiveninFigure
D.1.
We can show that the general solution to the normal equations given in
D.6 can be expressed as follow:
wu u-afx
onA
wl (D.7)
ort
w h e r e7 : D t q l N , y:Dryif N, and
\-r -\ /
ors : ) .\rt-r)\h-A) (D.8)
x
Thus, linear model that results in the minimum squared error is given by
Both measurement errors and errors in model specification have been absorbed
into a random noise term, e. The random noise present in data is typically
assumedto be independent and follow a certain probability distribution.
For example, if the random noise comes from a normal distribution with
zero mean and variance o2, then
1 - ts-J(**o)]2
P ( el x ,O ) ----: eXD 2oz (D.13)
Jhro2
1-
log[P(elx, o)] -:(u - f(x. Q))' * constant (D.14)
2',"
P ( e l x ,Q ) (x'ft) |
c exp-clu-"f (D.15)
Iog[P(e lx,0)] -clA - /(*, CI)l* constant (D.16)
where ,9^9? is known as the total sum of squares and SSM is known as the
regression sum of squares. S^97 represents the prediction error when the
average value g is used as an estimate for the response variable. SSM, on
the other hand, representsthe amount of error in the regressionmodel. The
relationship among SST, SSE, and SSM is derived as follows:
ssE : -T +T - f @)12
Dlro
: -s)2+DVI-S -sl2+z\(u, -r)@- f (re))
\W,
: Llro -vl2+Dlr(,,) -sl' - z\(u - fiay(r;-r)
ii1.
: -\lf @ r-)d 2
Dlr'-Tl2
it
: SST _ SSM ( D.1e)
-o.'l\ri/ - \ - I
T-f@r) )
-s)'
Dolf@u)
R2: -g)'
Dulao
Dolffi@-E))"
oaa
(D.22)
The above analysis shows that the correlation coefficient is equivalent to the
square root of the coefficient of determination (except for its sign, which de-
pends on the direction of the relationship, whether positive or negative).
It is worth noting that R2 increases as we add more explanatory variables
into the model. One way to correct for the number of explanatory variables
added to the model is by using the following adjusted fi2 measure:
R2: r- (ffi)
Adjusted $ - R2), (D.23)
736 Appendix D Regression
which is equivalent to the right-hand side matrix of the normal equation. Sub-
stituting Equations D.24 and D.25 into Equation D.6 we obtain the following
equation:
x"xe - x'y, (D.26)
where Q: (r0,c,,,1)". We can solve for the parameters in f) can as follows:
I rn rr2 r1.d
I rZt r22 r2d
(D.28)
1 rl,rt rN2 rNd.
A : / ( x , C l )* e (D.2e)
: ,o+Iuagi(x)le, (D.30)
and the random noise is normally distributed, then we can apply the same
methodology as before to determine the parameter vector O. The g6'scan be
any type of basis functions, including polynomial, kernel, and other nonlinear
functions.
For example, suppose x is a two-dimensional feature vector and the regres-
sion model is a polynomial function of degree 2
where r;7 is the jth attribute of the zth observation, then the regressionprob-
lem becomesequivalent to solving Equation D.26. The least-squaresolution to
the parameter vector Q is given by EquationD.27. By choosing the appropri-
ate design matrix, we can extend this method to any type of basis functions.
Optimization
Optimization is a methodology for finding the maximum or minimum value of
a function. It is an important topic in data mining because there are many
data mining tasks that can be cast as optimization problems. For example,
the K-means clustering algorithm described in Section 8.2.1 seeks to find a
set of clusters that minimizes the sum of the squared error (SSE). Similarly,
the method of least squares presented in Section D.2.1 is designed to learn
the regressioncoefficients that minimize the SSE of the model. This section
presents a brief overview of the various techniques used to solve optimization
problems.
dfl
o'
hl,__,.:
f (r*) can take a maximum or minimum value depending on the second-order
derivative of the function:
Pointof
Inflection
Minimum
Figure points
E.l. Stationary ofafunction.
(E.1)
a2f
"' }rt0rs
o'J
"' 0r20ra (8.2)
a2f
"' Ox40r4
A Hessian matrix H is positive definite if and only if xTHx > 0 for any
non-zero vector x. If H(x.) is positive definite, then x* is a minimum
stationary point.
E.1 Unconstrained Optimization 74I
Example E.1. Supposef (r,A) :3r2 *2A3 -2ry. Figtxe E.2 showsa plot of
this function. The conditions for finding the stationary points of this function
are
af 6r-2y:Q
0r
af 6 a '- 2 r : 0 (E.3)
0s
whosesolutionsaretr* : A* :0 or r* : L127,A* : Il9.
-2
v-
FigureE.2. f (",a):3r2 *2y3 -2ry.
Plotforthefunction
742 Appendix E Optimization
The Hessianof / is
H(r,a):
[j, ,;]
At r: A:0,
:
H(o,o)
lj, ?]
Since [r g] H(0,0) l" A]r :612 - 4rA :2r(3r _ 2A), which can be either
positive or negative, the Hessian is indefinite and (0,0) is a saddle point.
At r: I l 2 T ,y : I l g ,
: I u,
H(7l27,rlr)
L-a
Since[r y] H(I I 27,t I 9) [r a)r : 4r2- 2rs t +a2I J : 4(r - aI q2 + Ba2I 4 > 0
for non-zero z and y, the Hessianis positive definite. Therefore, (Il2T,1/g) is
a minimum stationary point. The minimum value of / is -0.0014. I
The preceding approach works if Equation E.l can be solved analytically for
x*. In many cases, finding analytical solutions is a very difficult problem,
thus necessitatingthe use of numerical methods to find approximate solutions.
Some of the numerical methods for finding the minimum value of a function
include golden search, Newton's method, and gradient descent search. While
the techniquespresentedhere are used to minimize the objective function /(x),
they are also applicable to maximization problems because a maximization
problem can be easily turned into a minimization problem by converting the
function /(x) to -/(").
(b - d) + (d - c) + (c - o)
1- :e-1 0+a,
b-a
E.l Unconstrained Optimization 743
ofa unimodalfunction.
FigureE.3.Example
or equivalently,
0:L-2a. (E.4)
The widths are also chosen to obey the following condition so that a re-
cursive procedure can be applied:
d-c c-a
r)
b-c o-a
or equivalently,
- - aa. (E.5)
l-a
Together, Equations E.4 and E.5 can be solved to yield c : 0.382 and B :
0.236. By comparing /(c) with /(d), it is possible to detect whether the mini-
mum value occurs in the interval (a,c,d) or (c,d,b). The interval that contains
the minimum value is then recursively partitioned until the interval width is
small enough to approximate the minimum value, as shown in Algorithm E.1.
The golden search method makes no assumption about the function, other
than it must be continuous and unimodal within the initial bracket [a,b]. lt
converges linearly to the solution for the minimum value.
Taking the derivative of the function with respect to r and setting it to zero
leads to the following equation:
x: x - r r - lv/( x) .
Hz: -V/(*)
to obtain the vector z. The iterative formula for finding the stationary point
ismodifiedtox:x*2.
x: x - )V/(x), (E.e)
'i: I,2,. ..
7 t ( x ): 0 , ,P.
Vi:1,2,...,d
#:0,
and
AL
V z:i I ' 2 " " ' P '
N:0'
3. Solve the (d * p) equations in step 2 to obtain the stationary point x*
and the corresponding values for )6's.
L ( r , A , , ) ): , I 2 y - t ) , ( r 2+ A 2- 4 ) ,
8.2 Constrained Optimization 747
AL :
L l2),r :0 (E.10)
0r
AL :
2+2^a:0 (E.11)
0y
AL :
, , + a ,- 4 : o
0^
SolvingtheseequationsyieldsS: +t/51a.7 :121t/5, andg : a4lJB.
WhenA: l|l4, f (-2lr/b,-4lr/6) : -r0l\/5.Similarly,when) : -t/614,
f (21'/5,41t/5): L\lt/5.Thus, the functionf(r,g) hasits minimumvalue
at r: -2lt/5 andg: -41'/5.
ht@)< 0, i: t,2,...,e.
The method for solving this problem is quite similar to the Lagrange method
described above. However, the inequality constraints impose additional con-
ditions to the optimization problem. Specifically, the optimization problem
stated above leads to the following Lagrangian
ri : ?,, 9,,,
f 8) + l\ihi$). (E.12)
i.:r
AL : ll Yi : I,2,...,d (E.13)
0u
hil*) V'i:1,2r...rQ (E.14)
),,i Y'i:1,2r...rQ (E.i5)
,\ah6(x) : 0, Y ' i : 7 , 2 , . . . r e . (E.16)
Notice that the Lagrange multipliers are no longer unbounded in the presence
of inequality constraints.
748 Appendix E Optimization
Ar.
(E.17)
#:2(r-i)+)r*)z:o
AT,
F :2(a-3)*)r-lz:o (E.18)
oa
)1(z*A-2):0 (E.1e)
^ z ( r - A ): 0 (E.20)
)r)0,,\z)0, r+A<2,U2r (E.21)
To solve the above equations, we need to examine all the possible casesof
Equations E.19 and E.20.
r - a : 0 , 2 (r- 1 )+ ) z : 0, 2( a- 3) - \z : 0,
L a k h a l ,L . , 4 0 L
Lakshmanan,L. V. S., 400
Lambert,D., 16
, 471,472, Landau, S., 557
558,559,645,646 Landeweerd,G., 197
Kasif, S., 796, I97 Landgrebe,D., 197,198
Kass,G. V., 196 Lane,T., 679
Kaufman, L., 87, 558 Langford,J. C., 315,717
Kegelmeyer,P., 15, 646 Langley.P., 86, 314, 645
Kegelmeyer,W. P., 312 Larsen,8., 558
Keim, D. A., 646 Lavrac,N., 314
Kelly, J., 645 Law, M. H. C., 16
Keogh, E., 678 Layman, 4., L4L
K e o g h ,E . J . , 8 7 Lazarevic,A., 398, 679
Kettenring, J. R., 678 Lee,S. D., 398
Khardon, R., 398 Lee, W., 400, 679
Kifer, D., 16 L e e ,Y . W . , 8 8
Kim, B., 197 Leese,M., 557
Kitsuregawa,M., 401 Lent, B., 472
Klawonn,F.,646 Leroy,A. M., 679
Kleinberg,J. M., 558, 645 Lewis,D. D., 314
Klemettinen,M., 399, 402 Lewis, T., 677
754 Author Index
Shawe-Taylor,J., 313 S u z u k iE
, .,402
Sheikholeslami, G., 646 S v e n s e nM, . , 6 4 4
Shekhar,S., 399, 40L,403,679 Swami,4., 397, 399,472
Shibayama,G., 401 Swaminathan,R., 646
S h i m ,K . , 4 7 I , 6 4 5 , 6 7 9 Sykacek,P., 680
Shinghal,R., 399 Szalay,A. S., 677
Shintani,T., 401
Shneiderman,8., 141 Takagi,T., 401
Shoshani, A., 141 Tan, C. L., 87
Shyu,M.-L., 680 Tan, P.-N., 647
Sibson,R., 558 Tan, P. N., 197,398,400-403,472
Siebes,A. P. J. M., 399 Tang, S., 401
Silberschatz,A., 400, 401 Taouil, R., 401
S i l v a ,V . d . , 7 L T Tax, D. M. J., 315
Silverstein,C., 397, 40I T a y ,S . H . , 4 0 3 , 4 7 2
Simovici,D., 399 Taylor,C. C., 197
Simpson,E.-H.,402 Taylor, W., 645
Singer,Y.,3I2 T e n e n b a u mJ,. 8 . , 7 1 7
Singh,K., 679 T e n g ,W . G . , 4 7 2
Singh,L., 402 Theodoridis,Y., 16
Singh,S., 679 Thomas,S., 401
Singh,V., 196 Thompson,K.,3I4
Sivakumar,K., 15, 16 Tibshirani,R., 15, 196,313,558
Smalley,C. T., 141 Tickle,A., 312
Smola,A. J., 315,717 Timmers, "I ., 197
Smyth,P., 15, 16, 313,315 Toivonen,H., 16, 88, 398, 402,472
Sneath,P. H. A., 88, 558 Tokuyama,T., 398, 400,47L
Soete,G. D., 557,558 Torregrosa,4., 402
Sokal,R. R., 88, 558 Tsur, S., 397,40L,402
Soparkar,N., 398 T\rcakov,V.,679
Spence,R., 141 Tufte, E. R., 141
Spiegelhalter, D. J., 197 T\rkey,J. W., 88, L4L,679
Spiliopoulou,M., 398 T\rng, A., 402,558
Spd,th,H., 558 T\rzhilin, 4., 40I, 403,472
Srikant,R., 14,88, 397,400,402,477,472 Tversky,A., 87, 88
Srivastava, J., 398, 402,472,679
Steinbach, M., 197,401 403,51i9,64Et,647 U l l m a n ,J . , 3 9 7 , 4 0 2
S t e p p ,R . 8 . , 6 4 6 , 6 4 7 Uslaner,E. M., 87
S t e v e n sS, . S . , 8 8 Utgoff, P. E., 198
Stolfo,S. J., 313, 400,677,671) Uthurusamy,R., 15
Stone,C. J., 196
Stork,D. G., 15, 196,313,557' Vaidya, J., 15
Strang,G., 700 van Rijsbergen,C. J., 315
S t r e h l ,4 . , 6 4 7 van Zomeren,B. C., 679
Struyf,L.,679 Van Loan, C. F., 700
S t u t z ,J . , 6 4 5 Vapnik, V., 315
Suen,C. Y., 198 Vazirgiannis,M., 557
S:ln,2.,397 Velleman,P., 141
Suppes,P., 87, 88 Vempala,5.,677
Author fndex 757
Xiang,D., 679
Xiong,H., 399,402,403,717
X u , X . , 5 5 7 ,5 5 8
Yamamura,Y., 401
Y a n ,X . , 1 5 ,4 0 3 ,4 7 L , 4 7 2
Yang, C., 403
Yang,Y., 400,472
Yao, Y. Y., 403
Y e ,J . , 7 I 7
Ye, N., 88, 645,680
Yesha,Y., 15
Yin, Y., 399
SubjectInclex
accuracy, 149,208 rare class, 654
activation function, 248 relative density, 669 670
AdaBoost, 288 algorithm, 669
adjacency matrix, 448 example, 669-670
aggregation, 45-47 semi-supervised, 656
anomaly detection statistical, 658-665
applications, 651-652 Gaussian, 659
approaches, 655-656 Grubbs, 681
semi-supervised, see anomal;r de- likelihood approach, 662
tection, semi-supervised multivariate, 661
supervised, see anornaly detection, strengths and weaknesses, 665
supervised strengths and weaknesses, 670
unsupervised, see anomaly detec- supervised, 655
tion, unsupervised techniques, 654-655
causes of, 653-654 unsupervised, 656, 658-675
clustering-based, 671-675 Apriori
definition, 671 algorithm, 335
example, 672 principle, 333
impact of outliers, 674 association
membership in a cluster, 672 analysis, 327
number of clusters, 674 categorical attributes, 415
strengths and weaknesses, 67 4 continuous attributes, 418
definitions, 654 655 indirect, 467
density-based, 655 pattern, 328
distance-based, 655 rule, see rule
model-based, 654 attribtfte,22-29
density-based, 668-670 definition of, 23
deviation detection, 651 number of values, 28
distance based set, 146
definition, 666 type,23 27
exception mining, 651 asymmetric, 28-29
issues, 656-658 binary, 28
outliers, 651 continuous, 26, 28
proximity-based, 666-668 discrete, 28
distance-based, see anomaly detec- interval, 25, 26
tion, distance-based nominal, 25, 26
strenghts and weaknesses, 666 ordinal,25, 26
Subject Index 759
qualitative, 26 classifier
quantitative, 26 bagging, 283
ratio, 25 base,277
axon,246 Bayes,227
Bayesian belief, 240
back-propagation, 254 boosting, 285
bagging, see classifier combination, 276
Bayes decision tree, 150
classifier, s€e classifier ensemble, 276
error, 238 maximal margin, 259
naive, see classifier naive-Bayes, 231
network, see classifier nearest-neighbor, 223
theorem, 228 neural networks,246
bias, 281 perceptron,24T
bias variance decomposition, 281 random forest, 290
binarization, see discretization, binariza- Rote, 223
tion, 416, 419 rule-based, 207
BIRCH, 633-635 support vector machine, 256
boosting, see classifier unstable, 280
bootstrap, 188 climate indices, 630
box plot, see visualization, box plot cluster analysis
Bregman divergence, 79-80 algorithm characteristics, 575-576
mapping to another domain, 576
c4.lniles,2I2 nondeterminism, 575
candidate optimization, 576
elimination, 448 order dependence, 575
generation, 337, 338, 433,448 parameter selection, see parame-
itemset, 332 ter selection
pruning, 338, 435, 453 scalability, s€e scalability
rule, 350 applications, 487-489
sequence,433 as an optimization problem, 576
subgraph, 445 chameleon, see chameleon
capacity, 258 choosing an algorithm, 639-642
case, see object cluster characteristics, 57 3-57 4
chameleon, 616*622 data distribution, 574
algorithm, 620-621 densrty, c/4
graph partitioning, 621 poorly separated, 574
merging strategy, 618 relationships, 574
relative closeness,618 shape, 574
relative intereconnectivity, 619 size, 574
self-similarity, 613, 6l-8, 620, 62I subspace, 574
strengths and limitatiorts, 622 cluster density, 574
characteristic, se€ attribute cluster shape, 510, 574
city block distance, see distance, city block cluster size,574
class data characteristics, 571-573
imbalance, 294 attribute types, 573
Iabel, 146 data types, 573
classification high-dimensionality, 572
model, 146 mathematical properties, 573
760 Subject Index
accuracy,149 object, 22
performance, 149 objective function, 261
min-Apriori, 425 observation, see object
mingap, see constraint Occam's razor, 181
minimum description length, see MDL OLAP, 46, 131-139
missing values, see data quality, errors, computing aggregates, 135-137
missing values cross tabulation, 137
mixture models, 583-59- data cube, 135-139
advantages and limitations, 591 dicing, 135, L38
definition of, 583-585 dimensionality reduction, 135, 138
EM algorithm, 587-591 drill-down, 135, 138-139
maximum likelihood estimation, 585- fact table, 134
D6/ MOLAP, 139
model, 146 multidimensinal data, 131-135
comparison, 188 multidimensional data analysis, 135-
descriptive, l46 139
evaluation, 136 pivoting, 138
overfitting, 165, I72 ROLAP, 139
predictive, 147 roll-up, 135, 138-139
selection, 186 slicing, 135, 138
monotone, 258 online analytical processing, see OLAP
monotonicity, 334 opposum, 616
multiclass, 306 algorithm, 616
multidimensional data analysis, see OLAP, strengths and weaknesses,616
multidimensional data analysis outliers, see data quality
multidimensional scaling, see dimension- overfitting, see modeI, I74
ality reduction, multidimensional oversampling, 305
scaling
multiple comparison, 178 pattern
mutual exclusive, 210 cross-support, 387
hyperclique, 390
nearest-neighbor classifier, see classifier infrequent, 457
network negative, 458
Bayesian, see classifier negatively correlated, 458, 460
feed-forward, 251 sequential, see sequential
multilayer, see classifier subgraph, see subgraph
neural, see classifier PCA, TOL_704
recurrent, 251 examples, 704
topology, 243 mathematics, 702-703
neuron, 246 perceptron, see classifier
node learning, 248
hidden, see hidden pie cha,rt, see visualization, pie chart
internal, 150 point, see object
Ieaf, 150 precision, 297
non-terminal, 150 precondition, 208
root, 150 preprocessing, 19, 44 -65
terminal, 150 aggregation, see aggregation
noise, 175, 227,281 binarization, see discretization, bina-
rization
766 Subject Index
Copyright Permissions
Some figures and part of the text of Chapter 9 originally appeared in the
article "Finding Clusters of Different Sizes, Shapes, and Densities in Noisy,
High Dimensional Data," Levent Ertoz, Michael Steinbach, and Vipin Kumar,
Proceedingsof the Thi,rd SIAM International Conference on Data Mi,ning, San
FYancisco,CA, May 1-3, 2003, SIAM. @2003, SIAM. The material is reprinted
here by permission of the publisher, SIAM.
Some figures and part of the text of Chapter 7 appeared in the article "select-
ing the Right Objective Measure for Association Analysis," Pang-Ning Tan,
Vipin Kumar, and Jaideep Srivastava, Informati,on Systems,29(4), 293-313,
2004, Elsevier. @2004, Elsevier. The material is reprinted here by permission
of the publisher, Elsevier.
Someof the figures and text of Chapters 9 appearedin the article "Discovery of
Climate Indices Using Clustering," Michael Steinbach, Pang-Ning Tan, Vipin
Kumar, Steven Klooster, and Christopher Potter, KDD '03: Proceedi,ngs of the
Ni,nth ACM SIGKDD International Conferenceon Knowledge Di,scoueryand
Data Mi,ni,ng,446-455, Washington, DC, August 2003, ACM. @)2003,ACM,
INC. The material is reprinted here by permission of the publisher, ACM. DOI
: http : / / aoi. acm.orgl10 . IL45/956750.956801
Some of the figures (1-7,13) and text of Chapter 8 originally appeared in the
chapter "The Challenge of Clustering High-Dimensional Data," Levent Ertoz,
Michael Steinbach, and Vipin Kumar in New Di,rectzonsi,n Stati,sti.calPhysi,cs,
E conophysi,cs,Bi,oi,nformat'ics,and P attern Recogni,ti,on,
273-312, Editor, Luc
Wille, Springer, ISBN 3-540-43182-9.@)2004,Springer-Verlag. The material
is reprinted here by permission of the publisher, Springer-Verlag.
Some of the figures and text of Chapter 9 originally appeared in the article
"Chameleon: Hierarchical Clustering Using Dynamic Modeling," by Geogre
Karypis, Eui-Hong (Sam) Han, and Vipin Kumar, IEEE Computer, Volume
32(8), 68-75, August, 1999, IEEE. @1999, IEEE. The material is reprinted
here by permission of the publisher, IEEE.
l#||$f
l;T