Professional Documents
Culture Documents
16 Marks
16 Marks
Preprocessing
2.2. Suppose that the values for a given set of data are grouped into intervals. The intervals and corresponding
frequencies are as follows.
age frequency
1-5 200
5-15 450
15-20 300
20-50 1500
50-80 700
80-110 44
Compute an approximate median value for the data.
Answer:
Using Equation,
Median = L 1+ ¿(∑ freq ¿ ¿l)/ Freq median ) width
we have L1 = 20, N = 3194, (f req)l = 950, f reqmedian = 1500, width = 30, median = 32.94 years.
2.3. Give three additional commonly used statistical measures (i.e., not illustrated in this chapter) for the
characterization of data dispersion, and discuss how they can be computed efficiently in large databases.
Answer:
Data dispersion, also known as variance analysis, is the degree to which numeric data tend to spread and can
be characterized by such statistical measures as mean deviation, measures of skewness, and the coefficient
of variation.
The mean deviation is defined as the arithmetic mean of the absolute deviations from the means and is
calculated as:
mean
where x¯ is the arithmetic mean of the values and N is the total number of values. This value will be greater
for distributions with a larger spread.
A common measure of skewness is:
x¯ − mode
s ,
which indicates how far (in standard deviations, s) the mean (¯x) is from the mode and whether it is greater
or less than the mode.
The coefficient of variation is the standard deviation expressed as a percentage of the arithmetic mean
and is calculated as:
The variability in groups of observations with widely differing means can be compared using this measure.
Note that all of the input values used to calculate these three statistical measures are algebraic measures.
Thus, the value for the entire database can be efficiently calculated by partitioning the database, computing
the values for each of the separate partitions, and then merging theses values into an algebraic equation
that can be used to calculate the value for the entire database.
The measures of dispersion described here were obtained from: Statistical Methods in Research and Produc-
tion, fourth ed., edited by Owen L. Davies and Peter L. Goldsmith, Hafner Publishing Company, NY:NY,
1972.
2.4. Suppose that the data for analysis includes the attribute age. The age values for the data tuples are (in
increasing order) 13, 15, 16, 16, 19, 20, 20, 21, 22, 22, 25, 25, 25, 25, 30, 33, 33, 35, 35, 35, 35, 36, 40, 45,
46, 52, 70.
(a) What is the mean of the data? What is the median?
(b) What is the mode of the data? Comment on the data’s modality (i.e., bimodal, trimodal, etc.).
(c) What is the midrange of the data?
(d) Can you find (roughly) the first quartile (Q1) and the third quartile (Q3) of the data?
(e) Give the five-number summary of the data.
(f) Show a boxplot of the data.
(g) How is a quantile-quantile plot different from a quantile plot?
Answer:
(a) What is the mean of the data? What is the median?
The (arithmetic) mean of the data is
= 809/27 = 30.The median (middle
value of the ordered set, as the number of values in the set is odd) of the data is: 25.
(b) What is the mode of the data? Comment on the data’s modality (i.e., bimodal, trimodal, etc.).
This data set has two values that occur with the same highest frequency and is, therefore, bimodal.
The modes (values occurring with the greatest frequency) of the data are 25 and 35.
(c) What is the midrange of the data?
The midrange (average of the largest and smallest values in the data set) of the data is: (70 + 13)/2 =
41.5
(d) Can you find (roughly) the first quartile (Q1) and the third quartile (Q3) of the data?
The first quartile (corresponding to the 25th percentile) of the data is: 20. The third quartile (corre-
sponding to the 75th percentile) of the data is: 35.
(e) Give the five-number summary of the data.
The five number summary of a distribution consists of the minimum value, first quartile, median value,
third quartile, and maximum value. It provides a good summary of the shape of the distribution and
for this data is: 13, 20, 25, 35, 70.
2.5. In many applications, new data sets are incrementally added to the existing large data sets.
Thus an important consideration for computing descriptive data summary is whether a measure can be computed
efficiently in incremental manner. Use count, standard deviation, and median as examples to show that a
distributive or algebraic measure facilitates efficient incremental computation, whereas a holistic measure
does not.
Answer:
· Count: The current count can be stored as a value, and when x number of new values are added,
we can easily update count with count + x. This is a distributive measure and is easily updated for
incremental additions.
· Standard deviation: If we store the sum of the squared existing values and the count of the existing
values, we can easily generate the new standard deviation using the formula provided in the book.
We simply need to calculate the squared sum of the new numbers, add that to the existing squared
sum, update the count of the numbers, and plug that into the calculation to obtain the new standard
deviation. All of this is done without looking at the whole data set and is thus easy to compute.
· Median: To accurately calculate the median, we have to look at every value in the dataset. When we
add a new value or values, we have to sort the new set and then find the median based on that new
sorted set. This is much harder and thus makes the incremental addition of new values difficult.
2.6. In real-world data, tuples with missing values for some attributes are a common occurrence. Describe
various methods for handling this problem.
Answer:
The various methods for handling the problem of missing values in data tuples include:
(a) Ignoring the tuple: This is usually done when the class label is missing (assuming the mining task
involves classification or description). This method is not very effective unless the tuple contains several
attributes with missing values. It is especially poor when the percentage of missing values per attribute
varies considerably.
(b) Manually filling in the missing value: In general, this approach is time-consuming and may not
be a reasonable task for large data sets with many missing values, especially when the value to be filled
in is not easily determined.
(c) Using a global constant to fill in the missing value: Replace all missing attribute values by
the same constant, such as a label like “Unknown,” or −∞. If missing values are replaced by, say,
“Unknown,” then the mining program may mistakenly think that they form an interesting concept,
since they all have a value in common — that of “Unknown.” Hence, although this method is simple,
it is not recommended.
(d) Using the attribute mean for quantitative (numeric) values or attribute mode for categor-
ical (nominal) values: For example, suppose that the average income of AllElectronics customers is
$28,000. Use this value to replace any missing values for income.
(e) Using the attribute mean for quantitative (numeric) values or attribute mode for categor-
ical (nominal) values, for all samples belonging to the same class as the given tuple: For
example, if classifying customers according to credit risk, replace the missing value with the average
income value for customers in the same credit risk category as that of the given tuple.
(f) Using the most probable value to fill in the missing value: This may be determined with
regression, inference-based tools using Bayesian formalism, or decision tree induction. For example,
using the other customer attributes in the data set, we can construct a decision tree to predict the
missing values for income.
2.7. Using the data for age given in Exercise 2.4, answer the following.
(a) Use smoothing by bin means to smooth the above data, using a bin depth of 3. Illustrate your steps.
Comment on the effect of this technique for the given data.
(b) How might you determine outliers in the data?
(c) What other methods are there for data smoothing?
Answer:
(a) Use smoothing by bin means to smooth the above data, using a bin depth of 3. Illustrate your steps.
Comment on the effect of this technique for the given data.
The following steps are required to smooth the above data using smoothing by bin means with a bin
depth of 3.
·
Step 1: Sort the data. (This step is not required here as the data are already sorted.)
· Step 2: Partition the data into equal-frequency bins of size 3
(b) How might you determine outliers in the data?
Outliers in the data may be detected by clustering, where similar values are organized into groups, or
“clusters”. Values that fall outside of the set of clusters may be considered outliers. Alternatively, a
combination of computer and human inspection can be used where a predetermined data distribution
is implemented to allow the computer to identify possible outliers. These possible outliers can then be
verified by human inspection with much less effort than would be required to verify the entire initial
data set.
(c) What other methods are there for data smoothing?
Other methods that can be used for data smoothing include alternate forms of binning such as smooth-
ing by bin medians or smoothing by bin boundaries. Alternatively, equal-width bins can be used to
implement any of the forms of binning, where the interval range of values in each bin is constant.
Methods other than binning include using regression techniques to smooth the data by fitting it to a
function such as through linear or multiple regression. Classification techniques can be used to imple-
ment concept hierarchies that can smooth the data by rolling-up lower level concepts to higher-level
concepts.
2.8. Discuss issues to consider during data integration.
Answer:
Data integration involves combining data from multiple sources into a coherent data store. Issues that must
be considered during such integration include:
· Schema integration: The metadata from the different data sources must be integrated in order to
match up equivalent real-world entities. This is referred to as the entity identification problem.
· Handling redundant data: Derived attributes may be redundant, and inconsistent attribute naming
may also lead to redundancies in the resulting data set. Duplications at the tuple level may occur and
thus need to be detected and resolved.
· Detection and resolution of data value conflicts: Differences in representation, scaling, or encod-
ing may cause the same real-world entity attribute values to differ in the data sources being integrated.
2.9. Suppose a hospital tested the age and body fat data for 18 randomly selected adults with the following
Result
(a) Calculate the mean, median and standard deviation of age and %fat.
(b) Draw the boxplots for age and %fat.
(c) Draw a scatter plot and a q-q plot based on these two variables.
(d) Normalize the two variables based on z-score normalization.
(e) Calculate the correlation coefficient (Person’s product moment coefficient). Are these two variables
positively or negatively correlated?
Answer:
(a) Calculate the mean, median and standard deviation of age and %fat.
For the variable age the mean is 46.44, the median is 51, and the standard deviation is 12.85. For the
variable %fat the mean is 28.78, the median is 30.7, and the standard deviation is 8.99.
(b) Draw the boxplots for age and %fat.
See Figure 2.1.
60
Values
Values
40
55
35
50
30
45
25
40
20
35
15
30
25 10
1 1
age %fat
Figure 2.1: A boxplot of the variables age and %fat in Exercise 2.9.
(c) Draw a scatter plot and a q-q plot based on these two variables.
See Figure 2.2.
qq plot scatter plot
45 45
fat
fat
40 40
35 35
30 30
25 25
20 20
15 15
10 10
520 25 30 35 40age45 50 55 60 65 520 25 30 35 40 45 50 55 60 65
age
(d) Normalize the two variables based on z-score normalization.
(e) Calculate the correlation coefficient (Pearson’s product moment coefficient). Are these two variables
positively or negatively correlated?
The correlation coefficient is 0.82. The variables are positively correlated.
2.10. What are the value ranges of the following normalization methods?
(a) min-max normalization
(b) z-score normalization
(c) normalization by decimal scaling
Answer:
(a) min-max normalization
The rage is [new min, new max]
(b) z-score normalization
The range is [(old min−mean)/stddev, (old max−mean)/stddev]. In general the range for all possible
data sets is (−∞, +∞).
(c) normalization by decimal scaling
The range is (−1.0, 1.0).
original data 200 300 400 600 1000
2.11. Use the two methods below to normalize the following group of data:
[0,1] normalized 0 0.125 0.25 0.5 1
200, 300, 400, 600, 1000
(a) min-max normalization by setting min = 0 and max = 1
(b) z-score normalization
original data 200 300 400 600 1000
Answer:
z-score -1.06 -0.7 -0.35 0.35 1.78
(a) min-
max normalization by setting mi
n = 0 and max = 1
(b) z-score normalization
2.12. Using the data for age given in Exercise 2.4, answer the following:
(a) Use min-max normalization to transform the value 35 for age onto the range [0.0, 1.0].
Answer:
(a) Use min-max normalization to transform the value 35 for age onto the range [0.0, 1.0].
For readability, let A be the attribute age. Using Equation (2.11) with minA = 13, maxA = 70,
new minA = 0, new maxA = 1.0, then v = 35 is transformed to v = 0.39.
(b) Use z-score normalization to transform the value 35 for age, where the standard deviation of age is
12.94 years.
Using Equation (2.12) where A = 809/27 = 29.96 and σA = 12.94, then v = 35 is transformed to
v = 0.39.
(c) Use normalization by decimal scaling to transform the value 35 for age.
Using Equation (2.13) where j = 2, v = 35 is transformed to v = 0.35.
(d) Comment on which method you would prefer to use for the given data, giving reasons as to why.
Given the data, one may prefer decimal scaling for normalization because such a transformation would
maintain the data distribution and be intuitive to interpret, while still allowing mining on specific age
groups. Min-max normalization has the undesired effect of not permitting any future values to fall
outside of the current minimum and maximum values without encountering an “out of bounds error”.
As such values may be present in future data, this method is less appropriate. [new Both min-max and
Z-score normalization change the original data quite a bit.] Z-score normalization transforms values
into measures that represent their distance from the mean, in terms of standard deviations. This type
of transformation may not be as intuitive to the user in comparison with decimal scaling.
(a) stepwise forward selection
(b) stepwise backward elimination
(c) a combination of forward selection and backward elimination
Answer:
(a) Stepwise forward selection
(b) Stepwise backward elimination
(c) A combination of forward selection and backward elimination
bin 1 5,10,11,13,15
2.14. Suppose a group of 12 sales pr bin 2 35,50,55,72,92 ice records has been sorted as follows:
(a) equal-frequency partitioning
(b) equal-width partitioning
(c) clustering
Answer:
(a) equal-frequency partitioning
bin 1 5,10,11,13
bin 2 15,35,50,55
bin 3 72,92,204,215
(b) equal-width partitioning
The width of each interval is (215 − 5)/3 = 70.
(c) clustering
We will use a simple clustering technique: partition the data along the 2 biggest gaps in the data.
2.15. Using the data for age given in Exercise 2.4,
(a) Plot an equal-width histogram of width 10.
(b) Sketch examples of each o f the following sampling techniques: SRSWOR, S
bin 1 5,10,11,13,15,35,50,55,72
RSWR, cluster sampling,
bin 2 92
stratified sampling. Use sam ples of size 5 and the strata “youth”, “middle-
aged”, and “senior”. bin 3 204,215
Answer:
(a) Plot an equal-width histogram of width 10.
(b) Sketch examples of each of the following sampling techniques: SRSWOR, SRSWR, cluster sampling,
stratified sampling. Use samples of size 5 and the strata “youth”, “middle-aged”, and “senior”.
2.16. [Contributed by Chen Chen] The median is one of the most important holistic measures in data analysis.
Propose several methods for median approximation. Analyze their respective complexity under different
parameter settings and decide to what extent the real value can be approximated. Moreover, suggest a
heuristic strategy to balance between accuracy and complexity and then apply it to all methods you have
given.
Answer:
This question can be dealt with either theoretically or empirically, but doing some experiments to get the
result is perhaps more interesting.
Given are some data sets sampled from different distributions, e.g., uniform, Gaussian, exponential, and
gamma. (The former two distributions are symmetric, whereas the latter two are skewed). For example, if
using Equation (2.3) to do approximation as proposed in the chapter, the most straightforward approach is
to partition all of the data into k equal-length intervals.
A1 A2
x1 1.5 1.7
x2 2 1.9
x3 1.6 1.8
x4 1.2 1.5
x5 1.5 1.0
2.17. [Contributed by Deng Cai] It is important to define or select similarity measures in data analysis. However,
there is no commonly accepted subjective similarity measure. Using different similarity measures may
deduce different results. Nonetheless, some apparently different similarity measures may be equivalent after
some transformation.
Suppose we have the following two-dimensional data set:
(a) Consider the data as two-dimensional data points. Given a new data point, x = (1.4, 1.6) as a query,
rank the database points based on similarity with the query using (1) Euclidean distance (Equation 7.5),
and (2) cosine similarity (Equation 7.16).
(b) Normalize the data set to make the norm of each data point equal to 1. Use Euclidean distance on the
transformed data to rank the data points.
Answer:
Based on the Euclidean distance of the normalized points, the order is x1, x3, x4, x2, x5, which is the same
as the cosine similarity order.
(a) Briefly describe how ChiMerge works.
The basic algorithm of chiMerge is:
begin
sort values in ascending order
assign a separate interval to each distinct value
while stopping criteria not met
begin
compute χ2 of every pair of adjacent intervals
merge the two intervals with smallest χ2 value
end
end
(b) Take the IRIS data set, obtained from http://www.ics.uci.edu/∼mlearn/MLRepository.html (UC-Irvine
Machine Learning Data Repository), as a data set to be discretized. Perform data discretization for
each of the four numerical attributes using the ChiMerge method. (Let the stopping criteria be: max-
interval = 6). You need to write a small program to do this to avoid clumsy numerical computation.
Submit your simple analysis and your test results: split points, final intervals, and your documented
source program.
The final intervals are:
Sepal length: [4.3 - 4.8],[4.9 - 4.9], [5.0 - 5.4], [5.5 - 5.7], [5.8 - 7.0], [7.1 - 7.9].
Sepal width: [2.0 - 2.2], [2.3 - 2.4], [2.5 - 2.8], [2.9 - 2.9], [3.0 - 3.3], [3.4 - 4.4].
Petal length: [1.0 - 1.9], [3.0 - 4.4], [4.5 - 4.7], [4.8 - 4.9], [5.0 - 5.1], [5.2 - 6.9].
Petal width: [0.1 - 0.6], [1.0 - 1.3], [1.4 - 1.6], [1.7 - 1.7], [1.8 - 1.8], [1.9 - 2.5].
The split points are:
Sepal length: 4.3, 4.9, 5.0, 5.5, 5.8, 7.1
Sepal width: 2.0, 2.3, 2.5, 2.9, 3.0, 3.4
Petal length: 1.0, 3.0, 4.5, 4.8, 5.0, 5.2
Petal width: 0.1, 1.0, 1.4, 1.7, 1.8, 1.9
2.20. Robust data loading poses a challenge in database systems because the input data are often dirty. In many cases, an input
record may have several missing values and some records could be contaminated (i.e., with some data values out of range or of a
di®erent data type than expected). Work out an automated data cleaning and loading algorithm so that the erroneous data will be
marked and contaminated data will not be mistakenly inserted into the database during data loading.
Answer:
begin
for each record r
begin
check r for missing values
If possible, ¯ll in missing values according to domain knowledge
(e.g. mean, mode, most likely value, etc.).
check r for out of range values
If possible, correct out of range values according to domain knowledge
(e.g. min or max value for the attribute).
check r for erroneous data types
If possible, correct data type using domain knowledge
If r could not be corrected, mark it as bad and output it to a log,
otherwise load r into the database.
end
end
The domain knowledge can be a combination of manual and automatic work. We can, for example, use the data in the database to
construct a decision tree to induce missing values for a given attribute, and at the same time have human-entered rules on how to
correct wrong data types.