∑GATE DA Atlas

Data Types and Data Transformation — Normalization, Discretization, Sampling, Compression

Attribute types (nominal, binary, ordinal, interval, ratio; discrete vs continuous), data quality issues, and the preprocessing steps the syllabus names — normalisation (min-max, z-score, decimal scaling), smoothing and binning, discretisation (equal-width, equal-frequency, entropy-based, concept hierarchies), sampling (simple random, stratified, cluster, systematic, reservoir) and data reduction and compression (lossless vs lossy, dimensionality and numerosity reduction).

Section 511 practice questions

Real data is messy: values on different scales, continuous attributes where categories are needed, too many rows or columns, noise and missing entries. Preprocessing turns raw data into a form that mining and machine learning algorithms can use.

Data types (attribute types)

TypeMeaningExamplesMeaningful operations
Nominal (categorical)names/labels, no ordercolour, PIN code, blood group==, ≠\ne, mode
Binarytwo states; symmetric or asymmetricgender, test positive/negativeas nominal
Ordinalordered categories, unknown gapsrating, grade, size S/M/L<<, median, percentiles
Intervalnumeric, equal units, no true zero°C, calendar year++, −-, mean, s.d.
Rationumeric with a true zeroheight, income, kelvin, countsall, including ratios
  • Discrete attributes take countable values (counts, categories); continuous ones take real values.
  • In databases, the physical data types are INT, DECIMAL(p, s), FLOAT, CHAR(n), VARCHAR(n), DATE, TIMESTAMP, BOOLEAN, BLOB — choosing exact DECIMAL for money avoids floating-point error.

Data quality and cleaning

  • Missing values: ignore the tuple, fill with a constant, the mean/median (or class-conditional mean), or a predicted value.
  • Noise: smooth by binning, regression or clustering; detect outliers with z-scores (∣z∣>3\lvert z\rvert > 3), the IQR rule (<Q1−1.5 IQR< Q_1 - 1.5\,\text{IQR} or >Q3+1.5 IQR> Q_3 + 1.5\,\text{IQR}) or clustering.
  • Inconsistencies and duplicates: reconcile codes and units, deduplicate records.

Normalisation (feature scaling)

Distance-based methods (k-NN, k-means, SVM) and gradient descent are distorted when attributes have different scales.

MethodFormulaResult
Min-maxv′=v−min⁡Amax⁡A−min⁡A(new_max−new_min)+new_minv' = \dfrac{v - \min_A}{\max_A - \min_A}(\text{new\_max} - \text{new\_min}) + \text{new\_min}range [0,1][0, 1] (or any target); sensitive to outliers; out-of-range values for new data
Z-scorev′=v−AˉσAv' = \dfrac{v - \bar A}{\sigma_A}mean 0, s.d. 1; preferable with outliers or unknown range
Decimal scalingv′=v/10jv' = v / 10^j, smallest jj with max⁡∣v′∣<1\max\lvert v'\rvert < 1shifts the decimal point
Robust scaling(v−median)/IQR(v - \text{median})/\text{IQR}resistant to outliers

Other transformations: smoothing, aggregation (daily → monthly sales), attribute construction (area from length × width), log transforms for skewed data, one-hot encoding of nominal attributes.

Discretisation

Convert a continuous attribute into intervals (labels), reducing noise and enabling algorithms that need categorical inputs.

MethodHowSupervised?
Equal-width binningkk intervals of width (max⁡−min⁡)/k(\max - \min)/kno
Equal-frequency (equal-depth) binningeach bin gets about n/kn/k valuesno
Clustering-basedcluster values; clusters become intervalsno
Entropy-basedchoose split points maximising information gain about the classyes
ChiMergemerge adjacent intervals whose class distributions are similar (χ2\chi^2 test)yes
Histogram analysissplit at valleys of the histogramno

Smoothing by binning: after binning, replace values by the bin mean, bin median, or the nearer bin boundary.

Concept hierarchies generalise discretised or categorical values to higher levels (street < city < state < country; age → young/middle-aged/senior) and are central to data warehouses — see data warehousing.

Sampling

MethodDescriptionWhen useful
SRSWORsimple random sample without replacementdefault
SRSWRwith replacement (an item can be picked twice)bootstrap
Stratifiedpartition into strata (e.g. classes), sample each proportionallyskewed/imbalanced data
Clustersample whole groups (pages, households)when data is naturally grouped
Systematicevery kk-th record after a random startordered lists, simple; beware periodicity
Reservoiruniform sample of kk from a stream of unknown length in one passstreams, big data
Python
import random

def reservoir(stream, k):
    sample = []
    for i, x in enumerate(stream):        # i = 0, 1, 2, ...
        if i < k:
            sample.append(x)
        else:
            j = random.randint(0, i)      # inclusive
            if j < k:
                sample[j] = x             # keep x with probability k/(i+1)
    return sample

Every item ends up in the sample with probability k/nk/n. Sampling cost scales with the sample size, not the data size — the key to mining very large data sets.

Data reduction and compression

Dimensionality reduction (fewer attributes):

  • feature selection (filter, wrapper, embedded methods);
  • feature extraction: PCA, wavelet transforms, random projections — see PCA.

Numerosity reduction (fewer or smaller data representations):

  • parametric: regression or log-linear models store only parameters;
  • non-parametric: histograms, clustering (store centroids), sampling, data cubes (pre-aggregation).

Compression:

Lossless (exact reconstruction)Lossy (approximate)
run-length encoding, Huffman coding, LZ77/gzip, dictionary encodingtruncated PCA/SVD, wavelet thresholding, JPEG, quantisation

Columnar databases combine dictionary encoding, run-length encoding of sorted columns and bit-packing to compress analytical data many-fold.

Quick revision

Practice questions

GATE-style questions: 3 one-mark and 8 two-mark. Wrong MCQs cost ⅓ of their marks in the real exam; MSQ and NAT have no negative marking. Attempt each before opening the solution.

Q1NAT1 mark

Income values range from 12,000 to 98,000. Using min-max normalisation to [0,1][0, 1], the value 73,600 maps to ______ (round to two decimals).

Q2NAT2 marks

Income has mean 54,000 and standard deviation 16,000. The z-score normalised value of 73,600 is ______ (round to two decimals).

Q3NAT2 marks

An attribute takes values from −986-986 to 917917. Normalisation by decimal scaling divides every value by 10j10^j, with jj the smallest integer such that all scaled absolute values are below 1. The value of jj is ______.

Q4NAT2 marks

The sorted values 4, 8, 15, 21, 21, 24, 25, 28, 34 are discretised into 3 equal-width bins over [4,34][4, 34] (widths of 10; the last bin includes 34). The number of values in the third (highest) bin is ______.

Q5NAT2 marks

The same values 4, 8, 15, 21, 21, 24, 25, 28, 34 are split into 3 equal-frequency (equal-depth) bins and smoothed by bin means. The value assigned to every element of the second bin is ______.

Q6MCQ1 mark

A survey records customer satisfaction as poor, fair, good or excellent. This attribute is

Q7MSQ2 marks

Which statements about measurement scales are correct?

One or more options are correct.

Q8MCQ2 marks

A data set has 95% records from class A and 5% from class B. Which sampling method best guarantees that a 1% sample still contains class B records in proportion?

Q9NAT2 marks

Reservoir sampling selects k=10k = 10 items uniformly at random from a stream of n=1000n = 1000 items in one pass. The probability that any particular item ends up in the sample is ______.

Q10NAT2 marks

The string AAAABBBCCD is compressed with run-length encoding into (symbol, count) pairs. The number of pairs produced is ______.

Q11MCQ1 mark

Which of the following is a lossy data reduction technique?