Getting to Know Your Data
Data Objects and Attribute Types
Basic Terminology
- Data set: a collection of data objects (records, points, examples, instances).
- Data object: described by a set of attributes (features, variables, dimensions, fields).
- Attribute (feature, variable): a data field representing a characteristic of an object. A value of an attribute can be numerical or symbolic.
Attribute Types by Scale
| Scale | Meaning | Operations | Examples |
|---|---|---|---|
| Nominal | categories/names, no order | color, gender, zip code | |
| Binary (nominal with 2 states) | symmetric (both equally important) or asymmetric (one state rarer/more important) | gender (symmetric), medical test +/− (asymmetric) | |
| Ordinal | meaningful order but unknown spacing | $<, >, $ median, percentile | rank, grade, size (S/M/L) |
| Numeric | |||
| — Interval | equal-spaced, no true zero | $+, -, $ mean, std | temperature (°C), calendar |
| — Ratio | true zero, ratios meaningful | $\times, \div, $ geometric mean | weight, length, counts |
- Discrete vs continuous: discrete attributes have finite/countable domains; continuous (numeric) take real values (often represented as floating-point).
- Many attributes can be of mixed type; type determines which similarity/distance and statistics apply.
Describing Data: Central Tendency
- Mean (average):
. Sensitive to outliers. - Trimmed mean: drop highest/lowest
% then average — robust to outliers. - Weighted mean:
. - Median: the middle value when sorted. Robust to outliers. For
ordered values, position . More robust than mean for skewed data. - Mode: the most frequent value. A data set can be unimodal, bimodal, or multimodal.
- Midrange:
. - Skewness measures asymmetry:
- Negative skew (left): tail to the left, mean
median. - Positive skew (right): tail to the right, mean
median.
- Negative skew (left): tail to the left, mean
Describing Data: Dispersion
- Range:
. - Interquartile range (IQR):
(spread of middle 50%). Outlier rule: or . - Variance (population):
. - Variance (sample):
. - Standard deviation:
. Same units as data. - Mean absolute deviation (MAD):
. - Five-number summary:
; visualized by a boxplot. - Data visualization: histograms, boxplots, scatter plots, quantile plots, q-q plots, Lorenz curve (for unequal distribution / Gini).
Graphic Displays
- Histogram: bar chart of value frequencies; bin width matters.
- Boxplot: compactly shows median, IQR, whiskers, and outliers.
- Scatter plot: shows correlation/relationship between two numeric attributes.
- Loess / smoothed curve: local regression to reveal trend.
- Quantile plot (q-q plot): compare empirical distribution to a theoretical one.
- Parallel coordinates: each object is a polyline across axes — good for high-dimensional numeric data.
Data Quality
| Problem | Description | Example |
|---|---|---|
| Noise | random error / distortion in a measured value | sensor jitter, typos |
| Outliers | data objects that deviate markedly from the rest | fraud, sensor fault |
| Missing values | not recorded / unavailable / "not applicable" | blank field |
| Duplicate data | repeated records (data integration) | same person twice |
| Inconsistent | conflicting values from different sources | units differ |
Handling Missing Values
- Ignore the tuple (if many attributes missing) — risks losing data.
- Fill manually (expensive).
- Use a global constant (e.g., "Unknown").
- Use the attribute mean / mode.
- Use the most probable value (e.g., regression / Bayesian inference).
Handling Noisy Data
- Binning: sort and partition into bins; smooth by bin mean/median/boundaries.
- Regression: fit a function to smooth (linear/ multiple regression).
- Clustering: detect and remove outliers, smooth within clusters.
- Machine learning / human inspection for correction.
Similarity and Dissimilarity
Definitions
- Similarity: numerical measure of how alike two objects are. Usually in
, higher = more similar. - Dissimilarity (distance): numerical measure of how different. Often in
; 0 = identical. - Proximity = similarity or dissimilarity.
Distance for Numeric (Interval/Ratio) Data
For data vectors
- Minkowski distance (metric family):
Manhattan ( ): . Euclidean ( ): . Most common. Supremum / Chebyshev ( ): .
Properties of a metric distance: non-negativity, identity (
Weighted and Other Distances
- Weighted Euclidean:
, . - Mahalanobis distance:
, where is the covariance matrix — accounts for correlation & scale.
Similarity for Binary / Nominal Data
- Binary (asymmetric) similarity — Jaccard coefficient:
where = both 1, = one 1; ignore (both 0). Used for market-basket / asymmetric binary. - Simple matching coefficient (symmetric) includes
: . - Nominal with
states: similarity . - Ordinal: map to ranks
then treat as interval/ratio (often normalize to by ) and apply numeric distances. - Cosine similarity (for high-dimensional sparse, e.g., text/doc vectors):
Useful for TF-IDF document vectors; angle-based, ignores magnitude.
Correlation
- Pearson correlation for numeric
: perfect positive, perfect negative, no linear correlation.
Data Matrix vs Dissimilarity Matrix
- Data matrix (
): rows = objects, columns = attributes — the raw data we usually start with. - Dissimilarity matrix (
, symmetric, zero diagonal): = proximity of objects and . Many algorithms (clustering, MDS, some classifiers) consume only this matrix. - Converting data → dissimilarity is the first step for distance-based methods; the choice of measure defines what "similar" means and can dominate results.
Proximity for Mixed-Type Data
When a record mixes attribute types (numeric + nominal + binary), combine per-attribute normalized contributions:
if or is missing/incomparable, else . - numeric:
. - binary/nominal:
if equal, if different. - ordinal: map to ranks then treat as numeric.
Worked Example
Two customers
- numeric age:
. - math (binary): differ ⇒
; sports (binary): differ ⇒ . - mixed distance
(higher = more different).
Choosing a Statistic — When to Use Which
| Statistic | Outlier-sensitive? | Use when |
|---|---|---|
| Mean | yes | symmetric, clean data |
| Median | no | skewed / noisy data |
| Mode | no (categorical) | nominal data |
| Std / variance | yes | scale matters, near-normal |
| IQR / MAD | no | robust spread |
Noise vs Outlier (Reminder)
Noise = random error in a recorded value (handled by smoothing); an outlier is a genuine, often meaningful deviation. Not all outliers are noise and not all noise is an outlier — deciding which is a modeling choice that precedes cleaning.
Text & High-Dimensional Similarity (TF-IDF + Cosine)
For documents, represent each as a vector over terms with TF-IDF weights:
where
Data Quality Dimensions (Summary)
| Dimension | Meaning |
|---|---|
| Accuracy | close to the true value |
| Completeness | no missing values |
| Consistency | agrees across sources |
| Timeliness | up to date |
| Validity | conforms to schema/type |
| Uniqueness | no duplicates |
Choosing the Right Proximity (Guide)
- Numeric, same scale → Euclidean / Manhattan.
- Numeric, different scales → z-score first, then Euclidean; or Mahalanobis.
- Asymmetric binary (market basket) → Jaccard.
- Sparse high-D (text) → cosine.
- Mixed types → per-attribute weighted formula.
- Correlation question → Pearson
.
Summary
Understanding your data is the prerequisite for every later step. Know attribute scales (nominal/binary/ordinal/interval/ratio; discrete vs continuous) because they dictate valid statistics and proximity measures. Summarize central tendency (mean/median/mode) and dispersion (range/IQR/variance). Recognize and treat data-quality problems (noise, outliers, missing, duplicate, inconsistent). Choose proximity carefully: Minkowski/Euclidean for numeric, Jaccard for asymmetric binary, cosine for sparse high-dimensional vectors, Pearson for correlation.