IDS Unit 2
IDS Unit 2
Data Mining 4
A Data Object
Data Mining 5
Attributes
• Attribute (or dimensions, features, variables): a data field, representing a
characteristic or feature of a data object.
– E.g., customer _ID, name, address
• Attribute values are numbers or symbols assigned to an attribute
Data Mining 6
Attribute Types
Four main types of attributes
Nominal: Categorical (Qualitative)
– categories, states, or “names of things”
• Hair color, marital status, occupation, ID numbers, zip codes
– An important nominal attribute: Binary
• Nominal attribute with only 2 states (0 and 1)
Ordinal: Categorical (Qualitative)
– Values have a meaningful order (ranking) but magnitude between successive values is
not known.
• Size = {small, medium, large}, grades, army rankings
Interval: Numeric (Quantitative)
– Measured on a scale of equal-sized units
– Values have order:
• temperature in C˚ or F˚, calendar dates
– No true zero-point: ratios are not meaningful
Ratio: Numeric (Quantitative)
– Inherent zero-point: ratios are meaningful
• temperature in Kelvin, length, counts, monetary quantities
Data Mining 7
Attribute Types
Four main types of attributes: Nominal Attributes
• The values of a nominal attribute are symbols or names of things.
– Each value represents some kind of category, code, or state,
• Nominal attributes are also referred to as categorical attributes.
• The values of nominal attributes do not have any meaningful order.
• Example: The attribute marital_status can take on the values single, married,
divorced, and widowed.
• Because nominal attribute values do not have any meaningful order about them and
they are not quantitative.
– It makes no sense to find the mean (average) value or median (middle) value for such an
attribute.
– However, we can find the attribute’s most commonly occurring value (mode).
Data Mining 8
Attribute Types
Four main types of attributes: Nominal Attributes
• A binary attribute is a special nominal attribute with only two states: 0 or 1.
• A binary attribute is symmetric if both of its states are equally valuable and carry the
same weight.
– Example: the attribute gender having the states male and female.
• A binary attribute is asymmetric if the outcomes of the states are not equally
important.
– Example: Positive and negative outcomes of a medical test for HIV.
– By convention, we code the most important outcome, which is usually the rarest one, by 1
(e.g., HIV positive) and the other by 0 (e.g., HIV negative).
Data Mining 9
Attribute Types
Four main types of attributes: Ordinal Attributes
• An ordinal attribute is an attribute with possible values that have a meaningful order
or ranking among them, but the magnitude between successive values is not known.
• Example: An ordinal attribute drink_size corresponds to the size of drinks available at
a fast-food restaurant.
– This attribute has three possible values: small, medium, and large.
– The values have a meaningful sequence (which corresponds to increasing drink size);
however, we cannot tell from the values how much bigger, say, a medium is than a large.
• The central tendency of an ordinal attribute can be represented by its mode and its
median (middle value in an ordered sequence), but the mean cannot be defined.
Data Mining 10
Attribute Types
Four main types of attributes: Interval Attributes
• Interval attributes are measured on a scale of equal-size units.
– We can compare and quantify the difference between values of interval attributes.
• Example: A temperature attribute is an interval attribute.
– We can quantify the difference between values. For example, a temperature of 20oC is five
degrees higher than a temperature of 15oC.
– Temperatures in Celsius do not have a true zero-point, that is, 0oC does not indicate “no
temperature.”
– Although we can compute the difference between temperature values, we cannot talk of
one temperature value as being a multiple of another.
• Without a true zero, we cannot say, for instance, that 10oC is twice as warm as 5oC . That is, we
cannot speak of the values in terms of ratios.
• The central tendency of an interval attribute can be represented by its mode, its
median (middle value in an ordered sequence), and its mean.
Data Mining 11
Attribute Types
Four main types of attributes: Ratio Attributes
• A ratio attribute is a numeric attribute with an inherent zero-point.
• Example: A number_of_words attribute is a ratio attribute.
– If a measurement is ratio-scaled, we can speak of a value as being a multiple (or ratio) of
another value.
• The central tendency of an ratio attribute can be represented by its mode, its median
(middle value in an ordered sequence), and its mean.
Data Mining 12
Properties of Attribute Values
• The type of an attribute depends on which of the following properties it possesses:
– Distinctness: =
– Order: < >
– Addition: + -
– Multiplication: * /
Data Mining 13
Properties of Attribute Values
Attribute Description Examples
Type
Nominal The values of a nominal attribute are just zip codes, employee ID
different names, numbers, eye color, sex:
i.e., nominal attributes provide only enough {male, female}
information to distinguish one object from
another. (=, )
Ordinal The values of an ordinal attribute provide hardness of minerals, {good,
enough information to order objects. (<, >) better, best}, grades, street
numbers
Interval For interval attributes, the differences calendar dates, temperature
between values are meaningful, in Celsius or Fahrenheit
i.e., a unit of measurement exists. (+, - )
Ratio For ratio variables, both differences and ratios temperature in Kelvin,
are meaningful. (*, /) monetary quantities, counts,
age, mass, length,
Data Mining 14
Attribute Types
Categorical (Qualitative) and Numeric (Quantitative)
• Nominal and Ordinal attributes are collectively referred to as categorical or
qualitative attributes.
– qualitative attributes, such as employee ID, lack most of the properties of numbers.
– Even if they are represented by numbers, i.e. , integers, they should be treated more like
symbols .
– Mean of values does not have any meaning.
Data Mining 15
Discrete vs. Continuous Attributes
• Discrete Attribute
– Has only a finite or countably infinite set of values
• zip codes, profession, or the set of words in a collection of documents
– Sometimes, represented as integer variables
– Note: Binary attributes are a special case of discrete attributes
– Binary attributes where only non-zero values are important are called asymmetric
binary attributes.
• Continuous Attribute
– Has real numbers as attribute values
• temperature, height, or weight
– Practically, real values can only be measured and represented using a finite number of
digits
– Continuous attributes are typically represented as floating-point variables
Data Mining 16
Types of data sets
• Record • Ordered
– Relational records – Video data: sequence of images
– Data matrix, e.g., numerical matrix, – Temporal data: time-series
crosstabs – Sequential Data: transaction
– Document data: text documents: sequences
term-frequency vector – Genetic sequence data
– Transaction data • Spatial, image and multimedia:
• Graph and network – Spatial data: maps
– World Wide Web – Image data:
– Social or information networks – Video data:
– Molecular Structures
Data Mining 17
Record Data
• Data that consists of a collection of records, each of which consists of a fixed set of
attributes
Data Mining 18
Data Matrix
• If data objects have the same fixed set of numeric attributes, then the data objects can
be thought of as points in a multi-dimensional space, where each dimension
represents a distinct attribute
• Such data set can be represented by an m by n matrix, where there are m rows, one for
each object, and n columns, one for each attribute.
• A data matrix is a variation of record data, but because it consists of numeric
attributes, standard matrix operation can be applied to transform and manipulate the
data.
Data Mining 19
Document (Text) Data
• Each document becomes a term vector,
– each term is a component (attribute) of the vector,
– the value of each component is the number of times the corresponding term occurs in the
document
• Convert text documents to record data by counting word frequencies (document-term
matrix).
Data Mining 20
Transaction Data
• Transaction data is a special type of record data, where
– each record (transaction) involves a set of items.
– Example: The set of products purchased by a customer constitute a transaction, while the
individual products that were purchased are the items.
Data Mining 21
Transaction Data
Convert to Record Data
Data Mining 22
• Data Objects and Attribute Types
• Basic Statistical Descriptions of Data
• Measuring Data Similarity and Dissimilarity
Data Mining 23
Basic Statistical Descriptions of Data
• Basic statistical descriptions can be used to identify properties of the data and
highlight which data values should be treated as noise or outliers.
• For data preprocessing tasks, we want to learn about data characteristics regarding
both central tendency and dispersion of the data.
• Measures of central tendency include mean, median, mode, and midrange.
• Measures of data dispersion include quartiles, interquartile range (IQR), and
variance.
• These descriptive statistics are of great help in understanding the distribution of the
data.
Data Mining 24
Measuring Central Tendency: Mean
• The most common and most effective numerical measure of the “center” of a set of
data is the arithmetic mean.
1 n
Arithmetic Mean: x xi
n i 1
w x i i
Weighted Arithmetic Mean: x i 1
n
w
i 1
i
Data Mining 25
Measuring Central Tendency: Mean
• Although the mean is the single most useful quantity for describing a data set, it is not
always the best way of measuring the center of the data.
– A major problem with the mean is its sensitivity to extreme (outlier) values.
– Even a small number of extreme values can corrupt the mean.
• To offset the effect caused by a small number of extreme values, we can instead use
the trimmed mean,
• Trimmed mean can be obtained after chopping off values at the high and low
extremes.
Data Mining 26
Measuring Central Tendency: Median
• Another measure of the center of data is the median.
• Suppose that a given data set of N distinct values is sorted in numerical order.
– If N is odd, the median is the middle value of the ordered set;
– If N is even, the median is the average of the middle two values.
• In probability and statistics, the median generally applies to numeric data; however,
we may extend the concept to ordinal data.
– Suppose that a given data set of N values for an attribute X is sorted in increasing order.
– If N is odd, then the median is the middle value of the ordered set.
– If N is even, then the median may not be not unique.
• In this case, the median is the two middlemost values and any value in between.
Data Mining 27
Measuring Central Tendency: Mode
• Another measure of central tendency is the mode.
• The mode for a set of data is the value that occurs most frequently in the set.
– It is possible for the greatest frequency to correspond to several different values, which
results in more than one mode.
– Data sets with one, two, or three modes: called unimodal, bimodal, and trimodal.
– At the other extreme, if each data value occurs only once, then there is no mode.
Data Mining 28
Measuring Central Tendency -
Mean, Median, Mode
Median, mean and mode of symmetric, positively and negatively skewed data
Data Mining 29
Measuring Central Tendency: Example
What are central tendency measures (mean, median, mode)for the following attributes?
attr1 = {2,4,4,6,8,24}
attr2 = {2,4,7,10,12}
attr3 = {xs,s,s,s,m,m,l}
Data Mining 30
Measuring Central Tendency: Example
What are central tendency measures (mean, median, mode)for the following attributes?
attr1 = {2,4,4,6,8,24}
mean = (2+4+4+6+8+24)/6 = 8 average of all values
median = (4+6)/2 = 5 avg. of two middle values
mode = 4 most frequent item
attr2 = {2,4,7,10,12}
mean = (2+4+7+10+12)/5 = 7 average of all values
median = 7 middle value
mode = any of them (no mode) all of them has same freq.
attr3 = {xs,s,s,s,m,m,l}
mean is meaningless for categorical attributes.
median = s middle value
mode = s most frequent item
Data Mining 31
Measuring Dispersion of Data
• The degree to which numerical data tend to spread is called the dispersion, or
variance of the data.
Data Mining 33
Measuring Dispersion of Data: Outliers
• Outliers can be identified by the help of interquartile range or standard deviation
measures.
– Suspected outliers are values falling at least 1.5xIQR above the third quartile or below the
first quartile.
– Suspected outliers are values that fall outside of the range of μ–Nσ and μ+Nσ where μ is
mean and σ is standard deviation. N can be chosen as 2.5.
Data Mining 34
Measuring Dispersion of Data: Boxplot Analysis
• Five-number summary of a distribution: Minimum, Q1, Median, Q3, Maximum
• Boxplots are a popular way of visualizing a distribution and a boxplot incorporates
five-number summary:
– The ends of the box are at the quartiles Q1 and Q3, so that the box length is the
interquartile range, IQR.
– The median is marked by a line within the box. (median of values in IQR)
– Two lines outside the box extend to the smallest and largest observations (outliers are
excluded). Outliers are marked separately.
• If there are no outliers, lower extreme line is the smallest observation (Minimum) and upper
extreme line is the largest observation (Maximum).
. . .
outliers outliers
Data Mining 35
Measuring Dispersion of Data: Example
Consider following two attribute values:
attr1: {2,3,4,5,6,7,8,9} attr2: {1,5,9,10,11,12,18,30}
Which attribute has biggest standard deviation? Do not compute standard deviations.
Data Mining 36
Measuring Dispersion of Data: Example
Consider following two attribute values:
attr1: {2,3,4,5,6,7,8,9} attr2: {1,5,9,10,11,12,18,30}
Which attribute has biggest standard deviation? Do not compute standard deviations.
attr2
Data Mining 37
Graphic Displays of Basic Statistical Descriptions
• Boxplot: graphic display of five-number summary
• Quantile plot: each value xi is paired with fi indicating that approximately 100 fi %
of data are xi
• Scatter plot: each pair of values is a pair of coordinates and plotted as points in the
plane.
Data Mining 38
Boxplot: Example in R
Boxplot: graphic display of five-number summary
Data Mining 39
Boxplot: Example in R
Data Mining 40
Boxplot: Example in R
Data Mining 41
Bar Chart: Example in R
Data Mining 42
Histogram: Example in R
Data Mining 43
Histograms Often Tell More than Boxplots
Data Mining 44
Quantile Plot
• Displays all of the data (allowing the user to assess both the overall
behavior and unusual occurrences)
• Plots quantile information
– For a data xi data sorted in increasing order, fi indicates that
approximately 100 fi% of the data are below or equal to the value xi
Data Mining 45
Quantile-Quantile (Q-Q) Plot
• Graphs the quantiles of one univariate distribution against the corresponding quantiles
of another
The Quantile-Quantile Plot in Programming Language, or (Q-Q Plot) is defined as a
value of two variables that are plotted corresponding to each other and check whether
the distributions of two variables are similar or not with respect to the locations.
Data Mining 46
Scatter Plot
• A scatter plot is one of the most effective graphical methods for determining if there
appears to be a relationship, pattern, or trend between two numeric attributes.
– To construct a scatter plot, each pair of values is treated as a pair of coordinates in an
algebraic sense and plotted as points in the plane.
• The scatter plot is a useful method for providing a first look at bivariate data to see
clusters of points and outliers, or to explore the possibility of correlation relationships.
• Two attributes, X, and Y, are correlated if one attribute implies the other.
• Correlations can be positive, negative, or null (uncorrelated).
Data Mining 47
Scatter Plot: Example in R
Data Mining 48
Scatter Plot: Example in R
Data Mining 49
Scatter Plot:
Positively and Negatively Correlated Data
Negatively Correlated
Positively Correlated
Uncorrelated
Uncorrelated
Data Mining 50
Scatter Plot:
Positively and Negatively Correlated Data
Data Mining 51