Source: 2_DM_preprocessing.pdf.
This follows the lecture: data and attributes -> why preprocessing -> cleaning -> integration/transformation -> reduction -> discretization. Every method states both what it does and when/why it is used.
1. Data sets, objects, and attributes
A data set commonly corresponds to one database table or statistical data matrix. A row is a data object - for example, a customer, sales record, patient, student, professor, course, or product. A column describes an attribute of each object.
Attribute types
| Type | Definition | Example |
|---|---|---|
| Nominal | Unordered names/symbols | hair_colour, marital_status |
| Binary | Nominal attribute with two states, usually 0/1 | smoker; symmetric when both states have equal importance, asymmetric otherwise |
| Ordinal | Ordered categories but unknown distance between ranks | grades; satisfaction from very dissatisfied to very satisfied |
| Interval-scaled | Equal-size units, arbitrary zero | temperature in Celsius |
| Ratio-scaled | Numeric scale with meaningful zero and ratios | weight, price, age |
| Discrete | Finite/countably infinite values | number of children, ZIP code |
| Continuous | Any value in a range up to measurement precision | height, temperature |
Quantitative attributes represent measurable quantities. Qualitative attributes describe a characteristic without a numerical magnitude; nominal, binary, and ordinal attributes are qualitative.
Explain nominal, ordinal, numeric and discrete attributes with examples.
Nominal values have no order (colour); ordinal values have order (low/medium/high); numeric values measure quantities (temperature); discrete values have countable possible values (number of visits). Numeric and discrete are not mutually exclusive.
Data types and forms
The usual representation is attribute-value data. Data may be numeric/categorical and static/dynamic (temporal). Mining must also deal with distributed data, text/Web/metadata, and image/audio/video data.
Differentiate a data set and a data object with examples.
A data set is a collection of objects; a data object is one entity described by attributes. A student table is a data set; one student’s row is an object.
2. Why data preprocessing?
Real data is frequently:
- incomplete: values/attributes are missing or only aggregated data is present, e.g.
occupation = ""; - noisy: it contains random error, variance, or outliers, e.g.
salary = -10; and - inconsistent: codes, names, or related fields conflict, e.g.
age = 42inconsistent with a birthday, or ratings stored as both1,2,3andA,B,C.
Poor data quality produces poor mining results and misleading statistics. Cleaning and transformation can account for about 90% of the work in a data-mining application, so preprocessing is not an optional cosmetic step.
Data quality
Assess data using accuracy, completeness, consistency, timeliness, believability, value added, interpretability, and accessibility.
3. The preprocessing workflow
- Data cleaning: handle missing values, noise, outliers, inconsistency, and duplicates.
- Data integration: combine multiple databases/files.
- Data transformation: normalize, aggregate, construct attributes, or smooth data.
- Data reduction: preserve a similar analytical result with less data.
- Data discretization: replace continuous values by intervals and form concept hierarchies.
Describe methods used in the four levels of preprocessing with examples.
The four major preprocessing tasks and examples are:
- Cleaning: handle missing or erroneous values and smooth noise. For example, impute missing age using an appropriate median, or inspect an implausible age.
- Integration: combine sources and resolve schema, entity and value conflicts. For example, reconcile
customer_idacross billing and support tables. - Transformation: change data into a suitable form. Min–max normalization maps a value to when the range is nonzero; aggregation combines daily sales into monthly totals.
- Reduction: make the data smaller while preserving useful information. Feature selection drops irrelevant attributes; aggregation or sampling reduces the amount of data.
The suitable technique depends on the data and analysis objective; preprocessing choices can introduce bias or information loss.
4. Data cleaning
Missing data
Values can be missing because equipment failed, entry was omitted/misunderstood, a value conflicted and was removed, history was not registered, or the field seemed unimportant at collection time.
| Method | How it works | Main limitation |
|---|---|---|
| Ignore tuple | Drop the record | Wasteful/biasing if many records are affected |
| Fill manually | Ask/check original source | Accurate but infeasible at scale |
| Global constant | Use unknown or another marker | Can create an artificial category |
| Mean | Use attribute mean, preferably class-conditional mean when labels exist | Reduces variance; poor for skew/outliers |
| Most probable value | Infer with decision tree, Bayesian method, regression, or EM | Needs a reliable model |
Describe two methods for handling missing values for some attributes in real-world data. Discuss about the various types of patterns which can be mined for some business applications. Describe the measures of multidimensional data model.
Method 1 - mean/class-conditional mean: replace a missing numeric value with the attribute mean, or the mean for the tuple’s class. It is fast, but can hide variation and be distorted by skewed data.
Method 2 - most-probable-value imputation: use a decision tree, Bayesian classifier, regression, or EM to predict the missing value from other attributes. It uses relationships in data but depends on the model being valid.
Business patterns include characterization (profile profitable customers), discrimination (buyers versus non-buyers), association/correlation (bread -> butter), classification (likely churn), regression (future sales), clustering (customer segments), outlier detection (fraud), and sequential/evolution patterns (purchase order/trends).
A data-cube measure is a numeric value at a cube cell, e.g. sales or units sold. Distributive measures (SUM, COUNT, MIN, MAX) combine partition aggregates directly. Algebraic measures (AVG, standard deviation) use a fixed number of distributive summaries. Holistic measures (median, mode, rank) have no fixed-size exact summary.
Describe two methods for handling missing values.
Delete affected records where appropriate, or impute a value such as a median or a model prediction; consider missingness and potential bias.
Noisy data and smoothing
Noise is random error or variance in a measured variable. Causes include faulty collection instruments, data-entry mistakes, and transmission errors. The lecture gives three responses:
- Binning: sort values, partition into equal-depth bins, then smooth by bin mean, median, or nearest boundary.
- Clustering: sparse/distant objects can be recognized as outliers.
- Computer + human inspection: flag suspicious values and check them with a person.
For sorted prices 4,8,9,15 | 21,21,24,25 | 26,28,29,34, smoothing by means gives 9,9,9,9 | 22.75,22.75,22.75,22.75 | 29.25,29.25,29.25,29.25. Boundary smoothing gives 4,4,4,15 | 21,21,25,25 | 26,26,26,34.
(i) What is entropy-based binning method? (ii) Consider . Use smoothing by bin means, with bin depth 3.
(i) Entropy-based binning is supervised discretization. Sort attribute-value/class pairs, test cuts between consecutive values, and choose the cut with maximum information gain (minimum weighted class entropy). Repeat when a further split is useful, producing relatively pure class intervals.
(ii) Sort first: 3,4,5 | 5,5,6 | 7,7,7 | 8,8,9 | 12,12,12 | 12,13,13 | 13,19.
| Bin | Mean | Smoothed bin |
|---|---|---|
3,4,5 | 4,4,4 | |
5,5,6 | 5.33,5.33,5.33 | |
7,7,7 | 7,7,7 | |
8,8,9 | 8.33,8.33,8.33 | |
12,12,12 | 12,12,12 | |
12,13,13 | 12.67,12.67,12.67 | |
13,19 | 16,16 |
Final smoothed sorted sequence: 4,4,4,5.33,5.33,5.33,7,7,7,8.33,8.33,8.33,12,12,12,12.67,12.67,12.67,16,16.
2024 CT1 Q4: Smooth the given sorted ages by bin means, using a bin depth of 3.
Split the 27 sorted ages into nine successive bins of three, then replace every value by its own bin mean.
| Bin | Mean | Smoothed values |
|---|---|---|
| 13, 15, 16 | 14.67 | 14.67, 14.67, 14.67 |
| 16, 19, 20 | 18.33 | 18.33, 18.33, 18.33 |
| 20, 21, 22 | 21 | 21, 21, 21 |
| 22, 25, 25 | 24 | 24, 24, 24 |
| 25, 25, 30 | 26.67 | 26.67, 26.67, 26.67 |
| 33, 33, 35 | 33.67 | 33.67, 33.67, 33.67 |
| 35, 35, 35 | 35 | 35, 35, 35 |
| 36, 40, 45 | 40.33 | 40.33, 40.33, 40.33 |
| 46, 52, 70 | 56 | 56, 56, 56 |
Smooth the cricket scores shown below by bin means using a bin depth of four.
Sort the 20 scores and divide into five bins of four. Replace every score in a bin by that bin’s mean.
| Sorted bin | Calculation | Smoothed values |
|---|---|---|
| 30, 125, 130, 133 | 104.5, 104.5, 104.5, 104.5 | |
| 136, 150, 160, 165 | 152.75, 152.75, 152.75, 152.75 | |
| 195, 200, 205, 210 | 202.5, 202.5, 202.5, 202.5 | |
| 220, 225, 235, 235 | 228.75, 228.75, 228.75, 228.75 | |
| 240, 245, 250, 313 | 262, 262, 262, 262 |
Smooth the supplied twelve values by equal-frequency bin means and bin boundaries.
The question does not specify the number of bins. Assume three bins of depth four: 4, 8, 9, 15 | 21, 21, 24, 25 | 26, 28, 29, 34.
Means: The bin means are , and . Replacing each value with its bin mean gives 9, 9, 9, 9 | 22.75, 22.75, 22.75, 22.75 | 29.25, 29.25, 29.25, 29.25.
Boundaries: Replace each value with the closest endpoint of its bin. The result is 4, 4, 4, 15 | 21, 21, 25, 25 | 26, 26, 26, 34. Different bin counts produce different answers.
Outliers
An outlier is a point inconsistent with most data. It may be valid (a CEO salary) or noisy (age 200). Detection/removal methods include clustering, curve fitting, and hypothesis testing; investigate before removal because an unusual point may be a fraud signal.
Explain noisy data. What is an outlier? Find out outliers in using boxplots or histogram analysis.
Noise is random error/variance caused by collection, entry, or transmission problems. An outlier is an observation exceptionally far from/general behaviour.
Sorted : 0.11,0.18,0.23,0.51,1.19,1.30,1.32,1.73,2.06,2.16,2.37,2.91,4.50,4.51,4.66,14.68,14.82,27.44,39.41,41.04,49.09,60.05.
With 22 values, , , and . The fences are and . Every value lies inside the fences, so the standard 1.5-IQR boxplot rule finds no formal outlier. A histogram has a long right tail; high values such as 39.41,41.04,49.09,60.05 should be investigated, but are not boxplot outliers under this rule.
Use a boxplot to identify outliers in the 2022 dataset shown below and in the 2026 marks 12, 12, 15, 18, 20, 22, 25, 27, 28, 35. Give an application of outlier analysis.
Use the median-of-halves convention, excluding the overall median when the sample size is odd. For the 2022 data, , and . The fences are and ; hence 6.98, 49.15, 50.57 and 60.05 are outliers.
For the 2026 marks, , and . The fences are and ; no marks are outliers under this rule. Different quartile conventions can change the fences.
An application is detecting unusual credit-card transactions for fraud investigation; an outlier is a flag, not proof of fraud.
5. Data integration
Data integration combines data from multiple sources. Its central issues are:
- schema integration: reconcile names/types/structures, e.g.
A.cust_idandB.cust_no; - entity identification: decide whether source records refer to the same real entity;
- redundancy/correlation: remove attributes derivable from others and avoid duplicated information;
- duplicate tuples: find repeated records created by merging; and
- data-value conflicts: standardize units, currencies, dates, codes, scales, and conventions.
For redundancy analysis, the lecture uses a chi-square test for nominal attributes and correlation coefficient/covariance for numeric attributes. These identify attributes that carry overlapping information before modelling.
Discuss issues to be considered during data integration. What is the curse of dimensionality? How can it be reduced?
The integration issues are schema integration, entity identification, redundancy/correlation, duplicate-tuple detection, and data-value conflicts, as listed above.
The curse of dimensionality occurs when many attributes make the space sparse: distance/similarity becomes less meaningful, computation/storage grows, and far more data is needed to represent the space. Reduce it using attribute-subset selection, dimensionality reduction/projection, aggregation, discretization, sampling, or removal of redundant/irrelevant attributes.
Explain data integration with an example.
Combine data from multiple sources into a consistent view, resolving entity identity, schema differences and duplicates; for example, merge customer records from sales and support using a shared customer ID.
6. Data transformation
- Smoothing: remove noise.
- Attribute/feature construction: derive a new useful attribute from existing ones.
- Aggregation: summarize data, e.g. daily sales -> monthly sales.
- Generalization: replace low-level values with higher-level concepts.
Normalization
| Method | Formula | Use |
|---|---|---|
| Min-max | Map values to a specified range. | |
| Z-score | Centre at 0 and scale by standard deviation. | |
| Decimal scaling | , smallest with $\max( | v’ |
7. Data reduction
Reduction obtains a much smaller representation while preserving the same or a similar analysis result.
- Dimensionality reduction: feature/attribute subset selection removes irrelevant attributes. Forward selection, backward elimination, stepwise methods, and combinations are common heuristics.
- Histograms: divide a range into buckets and store aggregate values per bucket.
- Clustering: retain cluster representations/centroids instead of all objects when suitable.
- Sampling: choose a representative subset. Simple random sampling can miss skewed minorities; stratified sampling preserves class/subpopulation proportions.
What is dimensionality reduction?
Reduce the number of features while preserving useful information, using feature selection or feature extraction such as PCA.
8. Discretization and concept hierarchy
Discretization divides a continuous attribute range into intervals and replaces actual values by interval labels. It reduces the number of values/noise and prepares numeric data for algorithms that accept categorical input.
| Technique | Rule |
|---|---|
| Equal-width binning | Same numerical width per interval. |
| Equal-frequency/equi-depth binning | Approximately the same number of values per interval. |
| Entropy-based binning | Select cut with maximum information gain. |
For values 0,4,12,16,16,18,24,26,28, width 10 gives [-∞,10), [10,20), [20,+∞). Equi-depth bins of three give [-∞,14), [14,21), [21,+∞): each interval contains approximately three observations.
Entropy-based binning
This is a supervised discretization method: each numeric value has a class label. For the lecture data
(0,P), (4,P), (12,P), (16,N), (16,N), (18,P), (24,N), (26,N), (28,N),
try candidate cuts at midpoints between consecutive distinct values. A cut at produces and . Choose the cut with the greatest information gain:
Lower entropy means a purer bin; zero means all values in that bin have one class. In the example, gives . Examine all candidate cuts and select the one with maximum gain (equivalently, minimum weighted information).
A concept hierarchy generalizes a detailed value to a higher-level value: age -> young/middle-aged/senior or street -> city -> province_or_state -> country. It supports data reduction, roll-up, and generalized mining. At schema level, the hierarchy can be declared as the total ordering street < city < province_or_state < country.
Discuss about discretization and concept hierarchy generation for numerical data.
Discretization replaces many continuous numeric values with a few interval labels. Explain equal-width, equal-frequency, and entropy-based splitting, and note that it reduces noise/data size and enables categorical algorithms. A concept hierarchy replaces low-level values with higher-level concepts, e.g. 23 -> young and street -> city -> state -> country; it supports roll-up/generalized mining.
What is discretization? When is it used?
Discretization converts a continuous numerical attribute into labelled intervals. Use it to reduce data/noise, form concept levels, improve interpretability, and prepare numeric data for a mining/classification algorithm requiring categorical input.
Why is discretization used?
It replaces numerical values with intervals, simplifying models and enabling methods that use categorical attributes; information may be lost.
9. Summary
Prepare data before mining: clean it, integrate sources, transform values, reduce size/dimensions, and discretize where appropriate. These choices directly affect the correctness, efficiency, and interpretability of every later mining result. Many preprocessing methods exist, and the area remains active research.


























