Data Mining Concepts and Pre-Processing
Data Mining Concepts and Pre-Processing
Terminology
1
10/20/2022
What is a concept?
Styles of learning:
Classification learning:
understanding/predicting a discrete class
Association learning:
detecting associations between features
Clustering:
grouping similar instances into clusters
Numeric estimation:
understanding/predicting a numeric quantity
Concept: thing to be learned
Concept description:
output of learning scheme
3
Classification learning
Example problems: weather data, medical
diagnosis, contact lenses, irises, labor negotiations,
etc.
Can you think of others?
Classification learning is supervised
Algorithm is provided with actual outcomes
Outcome is called the class attribute of the example
Measure success on fresh data for which class
labels are known (test data, as opposed to training
data)
In practice success is often measured subjectively
How acceptable the learned description is to a human
user
4
2
10/20/2022
Association learning
Can be applied if no class is specified and any kind
of structure is considered “interesting”
Difference from classification learning:
Unsupervised
I.e., not told what to learn
Can predict any attribute’s value, not just the class, and
more than one attribute’s value at a time
Hence: far more association rules than classification rules
Thus: constraints are necessary
Minimum coverage and minimum accuracy
Clustering
Finding groups of items that are similar
Clustering is unsupervised
The class of an example is not known
Success often measured subjectively
Sepal length Sepal width Petal length Petal width Type
1 5.1 3.5 1.4 0.2 Iris setosa
2 4.9 3.0 1.4 0.2 Iris setosa
…
51 7.0 3.2 4.7 1.4 Iris versicolor
52 6.4 3.2 4.5 1.5 Iris versicolor
…
101 6.3 3.3 6.0 2.5 Iris virginica
102 5.8 2.7 5.1 1.9 Iris virginica
…
3
10/20/2022
Numeric estimation
Variant of classification learning where the
output attribute is numeric (also called
“regression”)
Learning is supervised
Algorithm is provided with target values
Measure success on test data
Outlook Temperature Humidity Windy Play-time
Sunny Hot High False 5
Sunny Hot High True 0
Overcast Hot High False 55
Rainy Mild Normal False 40
… … … … …
• Example:
rules
fever or
swollen glands diagnosis
tree
headache or…
…
4
10/20/2022
What’s in an example?
Instance: specific type of example
Thing to be classified, associated, or clustered
Individual, independent example of target concept
Characterized by a predetermined set of attributes
Input to learning scheme: set of independent
instances dataset
Represented as a single relation/flat file
Note difference from relational database
Rather restricted form of input
No relationships between objects/instances
Most common form in practical data mining
9
Anna Nikki
F F
10
5
10/20/2022
11
6
10/20/2022
13
7
10/20/2022
Multi‐instance Concepts
Each individual example comprises a set of instances
multiple instances may relate to the same example
individual instances are not independent
“bag” of instances in training data have same class
All instances are described by the same attributes
One or more instances within an example may be
responsible for its classification
Goal of learning is still to produce a concept description
Examples
multi‐day game activity (the weather data)
classification of computer users as experts or novices
response of users to multiple credit card promotions
performance of a student over multiple classes
15
What’s in an attribute?
Each instance is described by a fixed predefined
set of features, its “attributes”
But: number of relevant attributes may vary
Example: table of baseball statistics
Possible solution: “irrelevant value” flag
Related problem: value of an attribute may depend
on value of another one
Potential impact on learning beyond prior discussion
Possible solution: methods of data reduction
Possible attribute types (“levels of measurement”):
Nominal, ordinal, interval and ratio
Simplifies to nominal and numeric 16
8
10/20/2022
Types of attributes
• Nominal attributes have values that are "names" of categories.
– there is a small set of possible values
attribute possible values
Fever {Yes, No}
Diagnosis {Allergy, Cold, Strep Throat}
Outlook {sunny, overcast, raining}
• In classification learning, the output attribute is always nominal.
• Nominal comes from the Latin word for name
• No relation is implied among nominal values
• No ordering or distance measure
• Can only test for equality
• Numeric attributes have values that come from a range of numbers.
attribute possible values
Body Temp any value in 96.0‐106.0
Salary any value in $15,000‐250,000
– you can order their values (definition of “ordinal” type)
$210,000 > $125,000
98.6 < 101.3
Types of attributes
• What about this one?
attribute possible values
Product Type {0, 1, 2, 3}
• If numbers are used as IDs or names of categories,
the corresponding attribute is actually nominal.
• Note that it doesn't make sense to order the values of
such attributes.
– example: product type 2 > product type 1
doesn't have any meaning
• Also note that some nominal values can be ordinal:
– hot > mild > cool
– young < old
– freshman < sophomore < junior < senior
9
10/20/2022
Ordinal quantities
Impose order on values
But no distance between values defined
Example:
attribute “temperature” in weather data
Values: “hot” > “mild” > “cool”
Note: addition and subtraction don’t make sense
Example rule:
temperature < hot play = yes
Distinction between nominal and ordinal not always
clear (e.g. attribute “outlook” – is there an
ordering?)
19
20
10
10/20/2022
23
11
10/20/2022
Missing values
Frequently indicated by out-of-range entries
E.g. -999, “?”
Types: unknown, unrecorded, irrelevant
Reasons:
malfunctioning equipment
changes in experimental design (e.g., new survey questions)
collation of different datasets
measurement not possible
user refusal to answer survey question
Missing value may have significance in itself (e.g.
missing test in a medical examination)
Most schemes assume that is not the case: “missing”
may need to be coded as additional value 26
12
10/20/2022
Inaccurate values
Reason: data has not been collected for the purpose of
mining
Result: errors and omissions that don’t affect original
purpose of data but are critical to mining
E.g. data on hobbies of university students and faculty
Typographical errors in nominal attributes values need
to be checked for consistency
Typographical, measurement, rounding errors in numeric
attributes outliers need to be identified
What facility of Weka did we learn in lab that might be useful here?
Errors may be deliberate
E.g. wrong zip codes
27
Unbalanced data
• Suppose the diagnosis dataset had 97
instances of allergy, 2 of cold, and 1 of strep
– Consequences?
• Another lesson about raw accuracy
percentages not telling the whole story
– Recall our prior discussion of the importance of
evaluation
• Predicting the majority outcome rarely says
anything interesting about the data
13
10/20/2022
Other problems
Duplicate / redundant data
Instances
Attributes (already discussed: “What’s in an attribute?”)
Necessity of reduction as a data preparation step
Outliers
Stale data
Different formats
2022‐09‐13 vs. Sep. 13, 2022
Noise
• Noisy data is meaningless data
– Not useful for prediction
• The term has often been used as a synonym
for corrupt data
• Its meaning has expanded to include any
data that cannot be understood and
interpreted correctly by machines
– unstructured text for example
• Distinguishing signal from noise is the task at
the heart of data mining
14
10/20/2022
15
10/20/2022
@data
sunny, 85, 85, false, no
sunny, 80, 90, true, no
overcast, 83, 86, false, yes
...
33
16
10/20/2022
Sparse data
In some applications most attribute values in a
dataset are zero
word counts in a text categorization problem
product counts in market basket analysis
ARFF supports sparse data
0, 26, 0, 0, 0 ,0, 63, 0, 0, 0, “class A”
0, 0, 0, 42, 0, 0, 0, 0, 0, 0, “class B”
35
Finding datasets
• Many sources:
– Google’s Public Data Explorer
– UCI Machine Learning Repository
([Link]
– FedStats ([Link]
– U.S. Census Bureau
– UNdata ([Link]
– National Space Science Data Center
– Journal of Statistics Education data archive
– KDnuggets dataset repository
– [Link] (feel like winning some money?)
– Search for “dataset” and the subject you’re interested in
– Tools for data scraping from the web
– Web APIs give access to data with a little programming knowledge
17
10/20/2022
Applied Pre‐Processing
• Review: The Data Mining Process
• Key steps:
– assemble the data in the format needed for data
mining
• typically a text file
• referred to as pre‐processing:
– Major tasks: extraction, integration, transformation, cleaning,
reduction
– perform the data mining
– interpret/evaluate the results
– apply the results
18
10/20/2022
19
10/20/2022
Data Extraction
• Ready‐made downloads
– See prior discussion
• Web scraping
– Requires some programming ability
• Web APIs
– I want some data from service X. Does service X have an API?
– Look at the API documentation. Figure out if there is a URL that
retrieves the kind of data you’re looking for.
– Sign up for an API key if one is required.
– Figure out what parameters you need to include in the URL in order to
get the exact data you want.
– Load the URL, parameters included, into your browser. Get back a
response.
– Take the JSON or XML data and unpack it.
Data Integration
• Combines data from multiple sources into a
coherent store
• In designing a database, we try to avoid
redundancies by normalizing the data
• As a result, the data for a given entity (e.g., a
customer) may be:
– spread over multiple tables
– spread over multiple records within a given table
20
10/20/2022
Data Integration
• Combines data from multiple sources into a
coherent store
• In designing a database, we try to avoid
redundancies by normalizing the data.
• As a result, the data for a given entity (e.g., a
customer) may be:
– spread over multiple tables
– spread over multiple records within a given table
• To prepare for data warehousing and/or data
mining, we often need to denormalize the data.
– multiple records for a given entity a single record
Data Integration
• Example: a simple database design
– Normalized
21
10/20/2022
22
10/20/2022
23
10/20/2022
24
10/20/2022
25
10/20/2022
26
10/20/2022
27
10/20/2022
28
10/20/2022
29
10/20/2022
30
10/20/2022
Discretization in Weka
• In Weka, you can discretize an attribute by
applying the appropriate filter to it
• After loading in the dataset in the Preprocess tab,
click the Choose button in the Filter portion of
the tab
Discretization in Weka
• In Weka, you can discretize an attribute by
applying the appropriate filter to it
• After loading in the dataset in the Preprocess tab,
click the Choose button in the Filter portion of
the tab
• For equal‐width or equal‐height, you choose the
Discretize option in the
filters/unsupervised/attribute folder
– by default, it uses equal‐width binning
– to use equal‐frequency binning instead, click on the
name of the filter and set the useEqualFrequency
parameter to True
31
10/20/2022
Discretization in Weka
• In Weka, you can discretize an attribute by
applying the appropriate filter to it
• After loading in the dataset in the Preprocess tab,
click the Choose button in the Filter portion of
the tab
• For supervised discretization, choose the
Discretize option in the
filters/supervised/attribute folder
Normalization
• Values scaled to fall within a small, specified
range
• Review: when is this transformation
necessary?
32
10/20/2022
33
10/20/2022
Data Cleaning
• Fill in missing values,
• smooth noisy data,
• identify or remove outliers,
• correct inconsistent data,
• balance unbalanced data,
• resolve redundancies caused by data integration
• Importance
– “Data cleaning is the number one problem in data warehousing”
34
10/20/2022
35
10/20/2022
Data Reduction
• Data can be too big to work with
– A database/data warehouse may store terabytes of data
– Complex data analysis/mining may take a very long time to run
on the complete data set
• Data reduction
– Obtain a reduced representation of the data set that is much
smaller in volume but yet produce the same (or almost the
same) analytical results
• Data reduction strategies
– Dimensionality reduction — remove unimportant attributes
– Aggregation and clustering
– Sampling (and oversampling, the opposite of reduction)
36
10/20/2022
Dimensionality Reduction
• Feature selection (i.e., attribute subset selection):
– Select a minimum set of attributes (features) that is sufficient
for the data mining task.
• Heuristic methods (due to exponential # of choices):
– step‐wise forward selection
– step‐wise backward elimination
– combining forward selection and backward elimination
– select top N fields using 1R or decision tree algorithm
(information gain ranker – Lab 6)
• rule of thumb: keep top 50 fields
– etc
Dimensionality Reduction
• Problematic attributes include:
– irrelevant attributes: ones that don't help to predict
the class
• despite their irrelevance, the algorithm may erroneously include
them in the model
• sometimes want to remove because data is simply too big
37
10/20/2022
Dimensionality Reduction
• Problematic attributes include:
– irrelevant attributes: ones that don't help to predict
the class
• despite their irrelevance, the algorithm may erroneously include
them in the model
– attributes that cause overfitting
• dependencies between attributes
• also called false predictors or information leakers
• example: a unique identifier such as Patient ID
Dimensionality Reduction
• Problematic attributes include:
– irrelevant attributes: ones that don't help to predict
the class
• despite their irrelevance, the algorithm may erroneously include
them in the model
– attributes that cause overfitting
• example: a unique identifier such as Patient ID
– redundant attributes: those that offer basically the
same information as another attribute
• example: in many problems, date‐of‐birth and age
provide the same information
• some algorithms may end up giving the information from
these attributes too much weight
38
10/20/2022
Dimensionality Reduction
Reducing instances
• For efficiency of processing, we sometimes
may also want to reduce the number of
instances (rows)
• Techniques include aggregation, clustering
and sampling
39
10/20/2022
Aggregation
• Example: voting feature intervals
Construct intervals for each attribute
Discretize numeric attributes
Treat each value of a nominal attribute as an
“interval”
Count number of times class occurs in interval
Prediction is generated by letting intervals “vote”
(those that contain the test instance)
• Age: 44, Sex: Female, Income: 30‐40K, CCI: No Prediction for Life Insurance?
40
10/20/2022
Clustering
• Partition data set into clusters, and can store
cluster representation only
• Can be very effective if data is clustered but
not if data is “smeared”
• There are many choices of clustering
definitions and clustering algorithms. We will
discuss them later
41
10/20/2022
Clustering
Sampling
• Sampling
– Choose a representative subset of the data
• Simple random sampling may have poor performance in the presence of
skew
– Adaptive sampling methods
• Stratified sampling:
– Approximate the percentage of each class (or subpopulation
of interest) in the overall database
– Used in conjunction with skewed data (when clustering isn’t a
good option)
– Oversampling methods
• Techniques for adding instances to counter imbalance
• Alternatively, can also be addressed with cost sensitive classification
42
10/20/2022
Data Reduction
43
10/20/2022
44
10/20/2022
Summary
• Data preparation is a big issue for data mining
• Data preparation includes
– Data extraction (collection, scraping, API, etc.)
– Data integration
– Data transformation (discretization, normalization, etc.)
– Data cleaning
– Data reduction and feature selection
• Many methods have been proposed but still an active
area of research
45