Lecture: Lecture 08 - Data Preprocessing

Why preparation is needed

Algorithms learn from the data they receive. If the data contains errors, missing values or irrelevant fields, the output can be inaccurate even when the algorithm is working correctly.

Common quality problems

  • Noise: unwanted distortion in a value or signal.
  • Outlier: an object very different from most others; it may be an error or the target of analysis.
  • Missing value: no value was collected, applicable, supplied or preserved.
  • Duplicate: two records represent the same object or event.
  • Wrong value: a value violates the domain or collection rules.

Never delete every outlier automatically. A strange credit-card payment may be a sensor error or a fraud case; the purpose of the analysis determines the response.

Reduction and transformation methods

Aggregation

Combine detail into a higher-level summary, such as daily sales into monthly sales. This reduces variation and volume, but discards detail.

Sampling

Analyze a smaller subset when the full dataset is too expensive. A sample should be representative of the property being studied. Stratified sampling protects important subgroups by sampling from each partition.

Dimensionality reduction

Reduce the number of attributes to limit the curse of dimensionality, lower computation and improve visualization. PCA creates new axes that preserve variation; SVD provides a related matrix factorization useful for compact representations.

Feature selection and creation

Feature selection removes irrelevant or redundant attributes. Feature creation builds better attributes from existing data, such as attendance hours / available hours = attendance rate.

Feature selection keeps original columns. PCA creates new combined columns.

Discretization

Convert continuous values into ordered categories, such as age into young/adult/older. Equal-width, equal-frequency, clustering and label-guided methods choose the boundaries.

Binarization

Convert categories into binary indicators. One-hot encoding maps low, medium, high to 100, 010, 001.

Normalization

Put attributes on comparable scales before distance-based methods.

Min-max normalization:

v' = (v - min) / (max - min)

If ages range from 20 to 60, age 40 becomes (40-20)/(60-20) = 0.5.

Z-score normalization:

v' = (v - mean) / standard deviation

The result shows how many standard deviations a value lies above or below the mean.

Example: preparing student data

  1. Remove duplicate registration records.
  2. Investigate an attendance value of 900% as a likely error.
  3. Treat a missing attendance value according to its cause rather than inserting an arbitrary zero.
  4. Create attendance rate from attended and available sessions.
  5. Remove Student ID before calculating student similarity.
  6. Normalize age, study hours and income before using Euclidean distance.

Retrieval questions

Why can aggregation improve stability? Short-term fluctuations may cancel when values are summarized over a larger period.

Why is a representative sample important? A biased sample can produce patterns that do not describe the original population.

How do feature selection and PCA differ? Selection keeps a subset of original features; PCA replaces many features with new components.

Why normalize before distance calculations? Otherwise a large-unit attribute can dominate the distance.

Source

Elena Baralis and Tania Cerquitelli, Data preprocessing, PDF pages 20-57. Added student workflow and examples are study explanations.