CS699-无代写
时间:2023-09-27
CS699
Lecture 3
Data Preprocessing
2Data Quality: Why Preprocess the Data?
• Measures for data quality: A multidimensional view
– Accuracy: correct or wrong, accurate or not
– Completeness: not recorded, unavailable, …
– Consistency: some modified but some not, dangling, …
– Timeliness: timely update? 
– Believability: how trustable the data are correct?
– Interpretability: how easily the data can be understood?
3Major Tasks in Data Preprocessing
• Data cleaning
– Fill in missing values, smooth noisy data, identify or remove outliers, 
and resolve inconsistencies
• Data integration
– Integration of multiple databases, data cubes, or files
• Data reduction
– Dimensionality reduction
– Numerosity reduction
– Data compression
• Data transformation and data discretization
– Normalization 
– Concept hierarchy generation
4Data Cleaning
• Data in the Real World Is Dirty: Lots of potentially incorrect data, e.g., 
instrument faulty, human or computer error, transmission error
– incomplete: lacking attribute values, lacking certain attributes of interest, 
or containing only aggregate data
• e.g., Occupation=“ ” (missing data)
– noisy: containing noise, errors, or outliers
• e.g., Salary=“−10” (an error)
– inconsistent: containing discrepancies in codes or names, e.g.,
• Age=“42”, Birthday=“03/07/2010”
• Was rating “1, 2, 3”, now rating “A, B, C”
• discrepancy between duplicate records
– Intentional (e.g., disguised missing data)
• Jan. 1 as everyone’s birthday?
5Incomplete (Missing) Data
• Data is not always available
– E.g., many tuples have no recorded value for several 
attributes, such as customer income in sales data
• Missing data may be due to 
– equipment malfunction
– inconsistent with other recorded data and thus deleted
– data not entered due to misunderstanding
– certain data may not be considered important at the time 
of entry
– not register history or changes of the data
• Missing data may need to be inferred
6How to Handle Missing Data?
• Ignore the tuple: usually done when class label is missing (when 
doing classification)—not effective when the % of missing values 
per attribute varies considerably
• Fill in the missing value manually: tedious + infeasible?
• Fill in it automatically with
– a global constant : e.g., “unknown” 
– the attribute mean
– the attribute mean for all samples belonging to the same 
class: smarter
– the most probable value: inference‐based such as Bayesian 
formula or decision tree
7How to Handle Missing Data?
• R example
Dataset: mv_demo.csv 
ClassA3A2A1
0low236.515
1high45236
0mediumNA8
1low28529
1high13563
1medium216.545
0medium46753
0low440.227
1NA51235
1low23111
0medium467NA
0low361.928
1low51231
1medium23140
0low17251
8How to Handle Missing Data?
• R example
# read mv_demo.csv into df
sum(is.na(df)) # number of missing values in the whole dataset
Output: 3
sapply(df, function(x) sum(is.na(x))) # missing values in individual columns
Output:
A1     A2    A3   Class 
1       1       1        0 
# replace NA in A1 with median
df$A1[is.na(df$A1)] <‐ median(df$A1, na.rm=TRUE)
# replace NA in A2 with mean
df$A2[is.na(df$A2)] <‐ mean(df$A2, na.rm=TRUE)
9How to Handle Missing Data?
• R example
# replace NA in A3 with mode
# use clue and modeest packages 
library(clue)
library(modeest)
df$A3[is.na(df$A3)] <‐ mfv(df$A3)
10
How to Handle Missing Data?
• Result
ClassA3A2A1
0low236.515
1high45236
0medium337.07868
1low28529
1high13563
1medium216.545
0medium46753
0low440.227
1low51235
1low23111
0medium46733
0low361.928
1low51231
1medium23140
0low17251
11
Noisy Data
• Noise: random error or variance in a measured 
variable
• Incorrect attribute values may be due to
– faulty data collection instruments
– data entry problems
– data transmission problems
– technology limitation
– inconsistency in naming convention 
12
How to Handle Noisy Data?
• Binning
– first sort data and partition into bins
– then can smooth by bin means,  smooth by bin median, 
smooth by bin boundaries, etc.
• Regression
– smooth by fitting the data into regression functions
• Clustering
– detect and remove outliers
• Combined computer and human inspection
– detect suspicious values and check by human (e.g., deal 
with possible outliers)
13
Binning Methods for Data Smoothing
• Equal‐width (distance) partitioning
– Divides the range into N intervals of equal size: uniform grid
– if A and B are the lowest and highest values of the attribute, the width of 
intervals will be:W = (B –A)/N.
– The most straightforward, but outliers may dominate presentation
– Skewed data is not handled well
• Equal‐depth (frequency) partitioning
– Divides the range into N intervals, each containing approximately same 
number of samples
– Good data scaling
• Note: Binning, especially manually binning, causes loss of information.
14
Binning Methods for Data Smoothing
• Sorted data: 4, 8, 9, 15, 21, 21, 24, 25, 26, 28, 29, 36
• Partition into equal‐width bins: (36 – 4) / 3 = 10.67
• Bin intervals are: [4, 14.67), [14.67, 25.34), [25.34, 36]
‐ Bin 1: 4, 8, 9
‐ Bin 2: 15, 21, 21, 24, 25
‐ Bin 3: 26, 28, 29, 36
• Smoothing by bin means:
‐ Bin 1: 7, 7, 7
‐ Bin 2: 21.2, 21.2, 21.2, 21.2, 21.2
‐ Bin 3: 29.75, 29.75, 29.75, 29.75
• Smoothing by bin boundaries:
‐ Bin 1: 4, 9, 9
‐ Bin 2: 15, 25, 25, 25, 25
‐ Bin 3: 26, 26, 26, 36
15
Binning Methods for Data Smoothing
• Sorted data: 4, 8, 9, 15, 21, 21, 24, 25, 26, 28, 29, 36
• Partition into equal‐depth bins:
‐ Bin 1: 4, 8, 9, 15
‐ Bin 2: 21, 21, 24, 25
‐ Bin 3: 26, 28, 29, 36
• Smoothing by bin means:
‐ Bin 1: 9, 9, 9, 9
‐ Bin 2: 22.75, 22.75, 22.75, 22.75
‐ Bin 3: 29.75, 29.75, 29.75, 29.75
• Smoothing by bin boundaries:
‐ Bin 1: 4, 4, 4, 15
‐ Bin 2: 21, 21, 25, 25
‐ Bin 3: 26, 26, 26, 36
16
16
Data Integration
• Data integration: 
– Combines data from multiple sources into a coherent store
• Schema integration: e.g., A.cust‐id  B.cust‐#
– Integrate metadata from different sources
• Entity identification problem: 
– Identify real world entities from multiple data sources, e.g., Bill Clinton = 
William Clinton
• Detecting and resolving data value conflicts
– For the same real world entity, attribute values from different sources are 
different
– Possible reasons: different representations, different scales, e.g., metric 
vs. British units
17
17
Handling Redundancy in Data Integration
• Redundant data occur often when integration of multiple 
databases
– Object identification:  The same attribute or object may 
have different names in different databases
– Derivable data: One attribute may be a “derived” attribute 
in another table, e.g., annual revenue
• Redundant attributes may be detected by correlation analysis 
and covariance analysis
• Careful integration of the data from multiple sources may help 
reduce/avoid redundancies and inconsistencies and improve 
mining speed and quality
18
Correlation Analysis (Nominal Data)
• There are different ways of analyzing the strength of 
association between two nominal variables.
• We will discuss Chi‐square test of independence 
19
Chi‐square Test
• Chi‐square test of independence
• Null hypothesis: Two variables are independent (or there is no 
correlation)
• Prepare a contingency table
• Calculate expected values and chi‐square test statistic, Χ2
• Pick significance level, α
• Determine degrees of freedom, df
• Get critical value from distribution table, X2α,df
• If Χ2 > X2α,df , then we reject the null hypothesis and conclude there is 
a correlation.
• Otherwise, we cannot reject the null hypothesis and conclude there 
is no correlation
20
Chi‐Square Test
• Heart disease dataset: 14 attributes and 270 tuples
• Predictor attributes: age, sex, and medical conditions
• Class attribute: whether a person has a heart disease (1) or not (2)
• A part of the dataset
• Want to know whether there is a correlation between chest_pain and 
heart_disease.
21
Chi‐Square Test 
• Construct a contingency table for chest_pain and heart_disease.        
Sum21Heart disease (HD)
Chest pain (CP)
201551
423572
7962 173
12938 914
270150120Sum
22
Chi‐Square Test 
• Calculate expected values
• Calculate chi‐square test statistic
  ExpectedExpectedObserved
2
2 )(
23
Chi‐Square Test 
• Calculate expected values
(numbers in parentheses are expected values)
89.8
270
12020)2()1(
12  n
HDcountCPcounte
Sum21Heart disease (HD)
Chest pain (CP)
205 (8.89)15 (11.11)1
427 (18.67)35 (23.33)2
7917 (35.11)62 (43.89)3
12991 (57.33)38 (71.67)4
270120150Sum
89.43
270
15079)1()3(
31  n
HDcountCPcounte
24
Chi‐Square Test
• Calculate X2 test statistic

67.71
)67.7138(
89.43
)89.4362(
33.23
)33.2335(
11.11
)11.1115( 22222
Sum21heart disease (HD)
Chest pain (CP)
205 (8.89)15 (11.11)1
427 (18.67)35 (23.33)2
7917 (35.11)62 (43.89)3
12991 (57.33)38 (71.67)4
270120150Sum
59.68
33.57
)33.5791(
11.35
)11.3517(
67.18
)67.187(
89.8
)89.85( 2222 
25
Chi‐square Test
• Choose α = 0.05
• degrees of freedom 
= (num_rows – 1) * (num_cols – 1) = 3 * 1 = 3
• Look up the chi‐square distribution table (see the next 
slide)
• Since Χ2 > X2df,α , we reject the null hypothesis and 
conclude there is a correlation between chest_pain
and heart_disease.
81.73,05.02 
26
Chi‐square Test
81.73,05.02 
27
Chi‐square Test
• Note
– What we described is Pearson’s chi‐square test.
– One assumption is that expected count is 5 or more 
in at least 80% of cells.
– For a 2 x 2 contingency table with small 
frequencies, we can use Pearson’s chi‐square test 
with Yate’s correction.
28
Chi‐square Test
• R example
# read the hear disease dataset  (heart_disease_L3.csv) into df
ct <‐ table(df$chest_pain, df$class)
chisq.test(ct)
Output
Pearson's Chi‐squared test
data:  ct
X‐squared = 68.588, df = 3, p‐value = 8.561e‐15
– Note: In R, Yate’s correction is automatically done for a 2 x 2 
contingency table. If you don’t want it to be done, you need to set the 
argument to FALSE.
29
Correlation Analysis (Numeric Data)
• Correlation coefficient (also called Pearson’s product moment 
coefficient)
஺,஻
௜ ௜

௜ୀଵ
஺ ஻
௜ ௜

௜ୀଵ
஺ ஻
where n is the number of tuples,       and      are the respective means of A 
and B, σA and σB are the respective standard deviation of A and B, and 
Σ(aibi) is the sum of the AB cross‐product.
• rA,B = 0: uncorrelated (no correlation)
• rA,B > 0: positively correlated, rAB < 0: negatively correlated
A B
30
Visually Evaluating Correlation
Scatter plots
showing the
similarity from
–1 to 1.
31
Correlation Analysis
• Example with Auto MPG dataset
– From UCI Repository and slightly modified.
–9 attributes and 406 tuples
– First 10 tuples
32
Correlation Analysis
• Want to know correlation among displacement, 
horsepower, and weight
• Calculate correlation coefficients:
• Shows strong positive correlations.
weighthorsepowerdisplacement
1.0000displacement
1.00000.8978Horsepower
1.00000.86220.9325weight
33
Correlation Analysis
• Scatterplots
34
Independence and Correlation
• If two numeric variables are independent, then 
they are not correlated.
• However, two numeric variables can be 
dependent even if they are not correlated. 
35
Causality
• Correlation does not imply causality
• Causal association between X and Y (X is a cause 
of Y):
– X must exist before Y (in time).
– There must be an association between X and Y.
– There should not be a third variable Z on which both 
X and Y are dependent (or Z is a common cause of 
both X and Y).
36
Causality
• Example: 
– X = # of hospitals in a city, Y = # of car‐thefts in a city
– There is an association (or correlation) between X and Y 
– But:
• Both X and Y are causally linked to a third variable, 
which is the population of a city.
– So, there is no causal relationship between X and 
Y. (X does not cause Y and Y does not cause X.)
37
Data Reduction 
• Data reduction: Obtain a reduced representation of the 
data set that is much smaller in volume but yet produces 
the same (or almost the same or often better) analytical 
results
• Data reduction strategies
– Dimensionality reduction, e.g., remove unimportant 
attributes
• Wavelet transforms
• Principal Components Analysis (PCA)
• Feature subset selection, feature creation
– Numerosity reduction (some simply call it: Data Reduction)
• Regression and Log‐Linear Models
• Histograms, clustering, sampling
• Data cube aggregation
– Data compression
38
Data Reduction
• Dimensionality reduction
– When dimensionality increases, data becomes 
increasingly sparse
– Density and distance between points, which is critical to 
clustering, outlier analysis, becomes less meaningful
– The possible combinations of subspaces will grow 
exponentially
– Computational cost may become prohibitively high
– Referred to as "curse of dimensionality."
– Example: A database/data warehouse may store 
terabytes of data.  Complex data analysis may take a very 
long time to run on the complete data set
39
Data Reduction 
• Dimensionality reduction
– Avoid the curse of dimensionality
– Help eliminate irrelevant features and reduce noise
– Reduce time and space required in data mining
– Allow easier visualization
40
Data Reduction 
• Remove irrelevant attributes (e.g., tuple id, sample date)
• Remove duplicate attributes.
• Remove zero‐variance or near zero‐variance attributes.
• Remove attributes to avoid collinearity. 
• Feature (attribute) selection methods:
– Many algorithms and methods exist for feature selection.
– Some classification algorithms output importance of 
attributes. Then, we can use this information to select 
attributes.
– Packages in R for feature selection: Fselector, Caret, Rweka, 
Boruta, . . .
41
Data Reduction 
• Zero‐variance or near zero‐variance attributes.
– An attribute has the same value for all samples.
– The number of unique values of an attribute is very small and 
the frequency distribution of the unique values is extremely 
skewed. 
• No concrete criteria; Usually use heuristics:
• One example: 
n: number of tuples, u: number of unique values
f1: frequency of the most frequent value
f2: frequency of the second most frequent value
If (u / n) < 1% and (f1 / f2) > 20, then the attribute is removed.
• R has nearZeroVar function to do this.
42
Data Reduction 
• One heuristic algorithm of removing collinearity
Goal: Remove the minimum number of predictor attributes in such a way that 
all pairwise correlations in the remining attributes are less than or equal to a 
certain, predetermined threshold.
– Step 1: Calculate correlation matrix of all predictors.
– Step 2: Identify two attributes, A and B, which have the largest absolute 
correlation.
– Step 3: 
• Calculate average correlation between A and all other predictors.
• Calculate average correlation between B and all other predictors.
• Remove the one with higher average correlation.
– Repeat Step 2 and Step 3 until no pairwise absolute correlation is above 
the threshold.
• R has findCorrelation function to do this.
43
Data Reduction 
• R examples
# near zero variance
df <‐ read.csv('./Data/Frogs_MFCCs_numeric.csv’)
nearZeroVar(df, names = TRUE)
Output: "MFCCs_.1“
# collinearity
corr <‐ cor(df[c(1:22)])
highCorr <‐ findCorrelation(corr, cutoff = 0.7, names = TRUE)
highCorr
Output:
[1] "MFCCs_22" "MFCCs_17" "MFCCs_11" "MFCCs_.9" "MFCCs_15" "MFCCs_14" "MFCCs_12" 
"MFCCs_.5"
44
Data Reduction 
• R examples
# cfs
df <‐ read.csv('./Data/bone_marrow.csv’)
subset <‐ cfs(survival_status ~., df)
bone.marrow.cfs <‐ as.simple.formula(subset, "survival_status")
bone.marrow.cfs
Output:
survival_status ~ Recipientage + Relapse + PLTrecovery
45
Data Reduction 
• R examples
# Boruta
bone.marrow.boruta <‐ Boruta(survival_status ~ ., data=df)
bone.marrow.boruta
Output:
4 attributes confirmed important: extcGvHD, PLTrecovery, Relapse, survival_time;
28 attributes confirmed unimportant: ABOmatch, aGvHDIIIIV, Alel, Antigen, CD3dCD34 
and 23 more;
4 tentative attributes left: ANCrecovery, CD34kgx10d6, Recipientage, Riskgroup;
46
Data Reduction 
• R examples
# information gain
df <‐ as.data.frame(unclass(df), stringsAsFactors = TRUE)
df$survival_status <‐ factor(df$survival_status)
bone.marrow.infogain <‐ InfoGainAttributeEval(survival_status ~ . , data = df)
sorted.features <‐ sort(bone.marrow.infogain, decreasing = TRUE)
sorted.features[1:10] # top 10
Output:
CD3dCD34       CD3dkgx10d8   survival_time Rbodymass extcGvHD PLTrecovery Relapse 
0.97472732    0.87705533      0.77731261        0.68400792      0.25549420    0.11134785       0.07236687 
Disease           ANCrecovery RecipientRh
0.05886589    0.03742036      0.02408891
47
Data Reduction 
• PCA Example with R
1. Perform all necessary preprocessing. Assume the dataset is in df now
2. Split df into training dataset and test dataset, training and test
3. Run PCA on training (use only predictor attributes, i.e., exclude the class
attribute)
4. Map the training dataset to new training dataset, tr
5. Map the test dataset to new test dataset, ts
6. Determine how many principal components you want to use
7. Build a model from tr using only the selected principal components
8. Test the model on ts and collect performance measures
48
Data Reduction 
• R example (PCA)
# read ThoracicSurgery1.csv dataset into df
# split dataset
set.seed(123)
flag <‐ sample(2, nrow(df), replace = TRUE, prob = c(0.66, 0.34))
training <‐ df[flag==1, ]
test <‐ df[flag==2, ]
# build Weka’s J48 decision tree model using all attributes
library(RWeka)
model <‐ J48(diagnosis ~ . , data=training)
# test the model on the test dataset
predicted <‐ data.frame(predict(model, test[‐14]))
49
Data Reduction 
• R example (PCA)
# create confusion matrix and calculate accuracy 
colnames(predicted)[1] <‐ "predicted“
head(predicted)
cm <‐ table(predicted$predicted, test$diagnosis)
round((sum(diag(cm))/sum(cm))*100,3)
Accuracy = 0.804
10reference
predicted
11440
3481
50
Data Reduction 
• R example (PCA)
# apply PCA on the training dataset
pc <‐ prcomp(training[, ‐14], center = TRUE, scale = TRUE) # exclude class attribute
summary(pc)
Importance of components :
PC1  PC2  PC3  PC4  PC5  PC6 PC7  PC8  PC9  PC10 PC11 PC12 PC13
Stddev 1.73 1.28 1.13 1.05 1.00 0.93 0.91 0.86 0.83 0.73 0.67 0.63 0.61
Var pro   0.23 0.12 0.09 0.08 0.07 0.06 0.06 0.05 0.05 0.04 0.03 0.03 0.02
Cum pro   0.23 0.35 0.45 0.54 0.61 0.68 0.75 0.80 0.86 0.90 0.93 0.97 1.00
If we take the first 10 principal components, we can preserve 90% of the total
variability.
If we take the first 6 principal components, we will keep 68% of the total variability
51
Data Reduction 
• R example (PCA)
# Let’s use only first six
# first map (project) original attributes to new attributes (using the projection matrix)
# created by PCA
tr <‐ predict(pc, training)
tr <‐ data.frame(tr, training[14])
ts <‐ predict(pc, test)
ts <‐ data.frame(ts, test[14])
52
Data Reduction 
• R example (PCA)
# Build model using only the first 6 attributes, test, get confusion matrix and accuracy
model <‐ J48(diagnosis~., data=tr[c(1:6, 14)])
predicted <‐ data.frame(predict(model, ts[c(1:6)]))
colnames(predicted)[1] <‐ "predicted"
cm <‐ table(predicted$predicted, ts$diagnosis)
round((sum(diag(cm))/sum(cm))*100,3)
Accuracy = 0.742
10reference
predicted
15420
30101
53
Data Reduction 
• R example (PCA)
• In this example, the performance decreased when we used only 
the first 6 principal components. 
• In general, we may get better, worse, or comparable 
performance when we use only a subset of principal 
components. 
• Note that if you repeat this same experiment, your result could 
be different.
54
Data Reduction: Sampling
• Sampling
– Simple random sample without replacement (SRSWOR)
– Simple random sample with replacement (SRSWR)
– Cluster sample
– Stratified sample
55
Data Reduction: Sampling
• R example
x <‐ c(1:20)
srswor <‐ sample(x, 10, replace=FALSE)
output; 17  4  8  7 19 14 13 11 16  1
srswr <‐ sample(x, 10, replace=TRUE)
output: 14  8  2 18 17 17  4  9  7  3
56
Data Reduction: Sampling
• R example
# stratified data split (by class attribute)
# read ThoracicSurgery1 data into df
dim(df)
table(df$diagnosis)
library(rsample)
set.seed(31)
split <‐ initial_split(df, prop = 0.8, strata = diagnosis)
tr <‐ training(split)
ts <‐ testing(split)
dim(tr)
dim(ts)
table(tr$diagnosis)
table(ts$diagnosis)
57
Data Transformation
• A function that maps the entire set of values of a given attribute to a new 
set of replacement values s.t. each old value can be identified with one of 
the new values
• Methods
– Smoothing: Remove noise from data
– Attribute/feature construction
• New attributes constructed from the given ones
– Aggregation: Summarization, data cube construction
– Normalization: Transform all variables to the same scale
• min‐max normalization
• z‐score normalization
• normalization by decimal scaling
– Discretization: Concept hierarchy climbing
58
Normalization
• Min‐max normalization: to [new_min, new_max]
Example:  Normalize income range $12,000 to $98,000 to [0.0, 1.0].  
Then $73,600 is mapped to  
• Z‐score normalization (μ: mean, σ: standard deviation):
– Ex. Let μ = 54,000, σ = 16,000.  Then
716.00)00.1(
000,12000,98
000,12600,73 


 vv '
225.1
000,16
000,54600,73 
59
Normalization
• Z‐score normalization using mean absolute deviation 
– When there are outliers, σ may not accurately represent 
the spread of the data.
– Use mean absolute deviation, S, instead of σ
Here, xi is a data item.
|)|...|||(|1
21
  nxxxns
S
vv '
60
Normalization
• Example
Data = (5, 8, 3, 12, 7)
μ = 7, s = 3.391
S = (|5 – 7| + |8 – 7| + |3 – 7| + |12 – 7| + |7 – 7|) / 5 = 2.4
Standardizing 5 and 8 using standard deviation:
(5 – 7) / 3.391 = – 0.590,     (8 – 7) / 3.391 = 0.295
Standardizing 5 and 8 using mean absolute deviation:
(5 – 7) / 2.4 = – 0.833,     (8 – 7) / 2.4 = 0.417
61
Normalization
• R example
# min‐max normalization
# define a function
min_max_scale <‐ function(x, new_min, new_max) {  
new_min + (x ‐ min(x)) * ((new_max ‐ new_min) / (max(x) ‐ min(x)))}
x = sample(1:100, 20)
x1<‐ min_max_scale(x,  0, 1)
x2<‐ min_max_scale(x,  1, 100)
62
Normalization
• R example
# z‐score standardization
# read iris dataset into df
# standardize all four predictors
df_scaled <‐ df
df_scaled[1:4] <‐ scale(df_scaled[1:4])
head(df_scaled)
# standardize only sepallength
df_scaled <‐ df
df_scaled$sepallength <‐ scale(df_scaled$sepallength)
head(df_scaled)
63
Discretization
• Discretization: Divide the range of a continuous attribute into intervals
– Interval labels can then be used to replace actual data values 
– Reduce data size by discretization
– Supervised vs. unsupervised
– Split (top‐down) vs. merge (bottom‐up)
– Discretization can be performed recursively on an attribute
– Prepare for further analysis, e.g., classification
64
Data Discretization Methods
• Typical methods: All the methods can be applied recursively
– Binning  
• top‐down split, unsupervised
– Histogram analysis
• Top‐down split, unsupervised
– Clustering analysis (unsupervised, top‐down split or bottom‐
up merge)
– Using entropy (supervised)
– Etc.
65
Data Discretization Methods
• R example (binning method)
# read iris dataset into df
library(arules)
# dscritize all numeric attributes to {small, large}
# use method = "interval“ for equal width
# use method = "frequency“ for equal frequency
iris_1 <‐ discretizeDF(df, default = list(method = "interval", breaks = 2,
labels = c("small", "large")))
head(iris_1)
summary (iris_1)
66
Data Discretization Methods
• R example (binning method)
# discretize only sepallengh to {short, medium, long}
iris_2 <‐ discretizeDF(df, methods = 
list(sepallength = list(method = "interval", breaks = 3, 
labels = c("short", "medium", "long"))),  
default = list(method = "none"))
head(iris_2)
summary (iris_2)
67
References
• Han, J., Kamber, M., Pei, J., “Data mining: concepts and 
techniques,” 3rd Ed., Morgan Kaufmann, 2012
• http://www.cs.illinois.edu/~hanj/bk3/
essay、essay代写