Data Mining and Feature Engineering

Chapter 2
Data Understanding, Measurement and Exploratory Analysis

Post Graduate Diploma in Data Science
Data Mining and Feature Engineering   •   Post Graduate

2. Data Understanding, Measurement and Exploratory Analysis

Introduction and Context

Data mining begins long before an algorithm is selected. A model can be mathematically sophisticated and still produce misleading results if the data is poorly understood, incorrectly measured, unrepresentative, or interpreted without regard to context. Data understanding is therefore not a preliminary administrative task; it is an analytical discipline that determines what can legitimately be learned from data.

In organizational settings, data may originate from transaction systems, customer relationship platforms, sensors, surveys, application logs, social media, public registers, or manually maintained spreadsheets. These sources differ in purpose, structure, completeness, accuracy, update frequency, and ownership. The analyst must establish what each variable represents, how it was produced, which observations are included, and what limitations affect interpretation.

Exploratory data analysis (EDA) provides a systematic way to investigate these issues. Through summaries, visualizations, comparisons, and carefully framed questions, EDA helps analysts identify distributions, associations, anomalies, missingness, and potential explanations. It also supports the translation of a broad business concern into an analytically tractable problem and testable hypotheses.

Learning Objectives

By the end of this chapter, the reader should be able to:

1. Distinguish major data sources, structures, and analytical units.

2. Select appropriate measurement scales and summarize variables correctly.

3. Interpret distributions using numerical and graphical techniques.

4. Examine associations without confusing correlation with causation.

5. Explain sampling, uncertainty, bias, and generalizability.

6. Diagnose important forms of data quality failure.

7. Formulate business questions and hypotheses suitable for analysis.

8. Apply exploratory analysis responsibly in professional and organizational contexts.

From Business Records to Analytical Data

A dataset is not simply a collection of numbers. It is a representation of events, entities, attributes, and relationships created for a particular purpose. A row may represent a customer, a purchase, a web session, an insurance claim, or a monthly observation for a region. This row-level meaning is the analytical unit, sometimes called the observational unit. Confusing units is a common source of error. For example, joining customer-level data to transaction-level data without accounting for repeated transactions can unintentionally give frequent purchasers greater weight.

Variables describe attributes of observations. A variable may be numeric, categorical, temporal, textual, spatial, or multimedia. Data may be:

  • Structured, organized into rows and columns with defined fields;
  • Semi-structured, containing tags or flexible fields, as in JSON or XML;
  • Unstructured, such as free text, images, audio, or video.

A data source may be internal or external, primary or secondary, static or streaming. Primary data is collected for the current investigation, whereas secondary data was originally collected for another purpose. Administrative data, for example, may be valuable but reflect operational processes rather than the phenomenon of interest. A customer complaint database may reveal dissatisfaction among people who complain, not among all customers.

Before analysis, the analyst should document provenance: who created the data, when and how it was collected, what transformations occurred, and who is responsible for its interpretation. A data dictionary should define field names, units, permitted values, coding schemes, and missing-value conventions. Without such documentation, apparently simple fields can be misunderstood. A value of “0” might mean no activity, not applicable, or a data-entry default.

Measurement: What Does a Value Mean?

Measurement is the assignment of values to attributes according to rules. The scale of measurement determines which comparisons and mathematical operations are meaningful.

Nominal measurement

Nominal variables classify observations into categories without an intrinsic order. Examples include payment method, browser type, country, and product category. Numeric codes assigned to categories do not make them quantitative. Computing an average of product-category codes has no substantive meaning. Suitable summaries include frequencies, proportions, and the mode.

Ordinal measurement

Ordinal variables have an ordered arrangement, but the distances between categories are not necessarily equal. Examples include satisfaction ratings such as dissatisfied, neutral, and satisfied; risk levels; and education categories. Medians, percentiles, and rank-based methods are often appropriate. Treating ordinal responses as equally spaced numerical measurements may be acceptable in some models, but it requires justification rather than automatic assumption.

Interval measurement

Interval scales have ordered values with approximately equal differences, but zero does not represent a complete absence of the quantity. Temperature measured in Celsius is a familiar example. Differences can be interpreted, but ratios cannot: 20°C is not meaningfully twice as warm as 10°C.

Ratio measurement

Ratio scales possess equal intervals and a meaningful zero. Revenue, distance, duration, weight, and number of purchases are examples. Both differences and ratios can be interpreted. A revenue of 200 monetary units is twice a revenue of 100 units, assuming the same currency and measurement conditions.

Measurement also concerns operational definitions. “Customer loyalty” is a theoretical construct, not a directly observed fact. It may be operationalized as repeat-purchase rate, share of wallet, tenure, or a survey score. Different operationalizations can produce different conclusions. Analysts should state how abstract concepts have been translated into measurable variables.

Describing Data Distributions

A distribution describes how values are arranged. Understanding the distribution is essential for identifying unusual observations, selecting summaries, evaluating assumptions, and communicating results.

For a quantitative variable, the mean is the arithmetic average, while the median is the middle ordered value. The mean uses every observation and is sensitive to extreme values; the median is more resistant to skewness and outliers. The mode is the most frequent value and is particularly useful for categorical data.

Measures of spread include the range, variance, standard deviation, interquartile range (IQR), and median absolute deviation. The IQR is the difference between the third and first quartiles and describes the central half of observations. Standard deviation is useful when the mean is an appropriate center and extreme values are not dominating the analysis.

Distributional shape matters. A right-skewed income distribution has a long upper tail and often requires the median or a logarithmic transformation for effective description. A bimodal distribution may indicate two underlying populations, such as individual and corporate customers. Heavy tails suggest that extreme outcomes occur more often than a normal model would predict.

Histograms show the frequency of numerical values across intervals, but their appearance depends on bin width. Density plots provide a smoothed representation and are useful for comparing groups, although excessive smoothing can conceal meaningful structure. Box plots display the median, quartiles, and potential extreme values efficiently. A time plot is more suitable when order and temporal dependence matter.

Standardization is often expressed through a z-score:

z = (x − mean) / standard deviation

It indicates how far an observation lies from the mean in standard-deviation units. A z-score is not automatically evidence of an error. A large value may be a genuine and important case, and its interpretation depends on the population and context.

Exploring Relationships and Associations

Univariate analysis examines one variable at a time. Bivariate and multivariate analysis examine relationships among variables. For two categorical variables, cross-tabulations, conditional proportions, and mosaic plots are informative. For a numerical variable and a categorical grouping variable, side-by-side box plots or group summaries can reveal differences. For two numerical variables, scatterplots and correlation measures are common.

The Pearson correlation coefficient measures linear association and ranges from −1 to +1. A value near zero indicates little linear association, but nonlinear dependence may still exist. Spearman’s rank correlation is less dependent on the original scale and is useful for monotonic relationships or ordinal data. Correlation can be distorted by outliers, restricted ranges, aggregation, and nonlinear patterns.

Association is not causation. A relationship between advertising expenditure and sales may reflect a genuine effect, reverse causation, seasonal planning, or a third factor such as market demand. Confounding occurs when an additional variable is related to both the proposed cause and the outcome. Simpson’s paradox illustrates how an association observed in aggregated data can reverse after stratification by a relevant variable.

Exploratory findings are valuable for generating hypotheses, but they should not automatically be treated as confirmatory evidence. When many variables and comparisons are examined, some apparently strong patterns may arise by chance. Analysts should distinguish exploratory discovery from pre-specified testing and, where possible, validate findings using new data or a holdout sample.

Sampling, Uncertainty and Generalization

A population is the complete set of units about which a conclusion is intended. A sample is the subset actually observed. A sampling frame is the operational list or mechanism from which the sample is drawn. These concepts are distinct: a company may intend to study all customers, possess only an email list, and obtain responses from a self-selected subset.

Probability sampling methods include simple random sampling, stratified sampling, cluster sampling, and systematic sampling. Stratification can ensure representation of important subgroups, while cluster sampling may reduce collection costs. Non-probability approaches include convenience, quota, and voluntary-response sampling. They may be practical but can limit generalizability.

Sampling variability means that different samples from the same population produce different estimates. A confidence interval expresses uncertainty under specified assumptions; it is not a guarantee that a fixed percentage of future observations will fall within the interval. A prediction interval concerns the uncertainty of an individual future value and is generally wider.

Bias is systematic error rather than random fluctuation. Coverage bias arises when the sampling frame omits part of the target population. Nonresponse bias occurs when those who do not respond differ meaningfully from respondents. Survivorship bias appears when analysis includes only entities that remain observable, such as successful firms or active users. Selection bias can also enter through business rules, platform usage, or data generated only after a prior decision.

The effective sample size may be smaller than the number of rows when observations are repeated for the same entity, clustered, or serially dependent. Analysts must therefore consider independence and the data-generating process rather than relying only on row counts.

Data Quality as an Analytical Concern

Data quality is multidimensional. Important dimensions include accuracy, completeness, consistency, validity, uniqueness, timeliness, and fitness for purpose. A dataset can be complete but inaccurate, or accurate but too old for the decision being made.

Missing data may be missing completely at random, missing at random conditional on observed variables, or missing not at random. These assumptions cannot be established merely by inspecting blank cells. Missingness itself may carry information: a missing income value could be associated with privacy concerns or financial difficulty. Common responses include deletion, simple imputation, model-based imputation, or treating missingness as an explicit category. Each choice can alter distributions and relationships.

Outliers require investigation rather than automatic removal. They may result from typographical errors, unit mismatches, sensor failures, fraud, rare but valid behavior, or a different population. Duplicate records may be exact duplicates or repeated legitimate events. Inconsistent dates, currencies, categories, and identifiers can create silent errors during integration.

A practical quality audit asks: What proportion of records is affected? Are errors concentrated in a source, time period, branch, or demographic group? Could cleaning change the representation of particular groups? Are the rules for correction reproducible? Data preparation decisions should be logged so that results can be audited and reproduced.

Designing an Exploratory Analysis

A disciplined EDA process combines domain understanding with statistical investigation. It is iterative rather than strictly linear.

First, define the decision context and unit of analysis. Next, inspect the schema, data types, ranges, categories, timestamps, and missingness. Then calculate appropriate summaries and visualize distributions. Examine important subgroups and time periods, investigate anomalies, and compare plausible explanations. Finally, formulate hypotheses and identify analyses that can evaluate them.

A business problem should be translated into a precise analytical question. “Improve retention” is a managerial aim, not yet an analytical specification. A more tractable question might be: “Among customers who made at least one purchase during the first quarter, which observable behaviors are associated with making a repeat purchase within 90 days?” This formulation defines a population, an outcome, a time window, and a possible unit of analysis.

A hypothesis should state a directional or testable expectation when appropriate. For example: “Customers who receive a product-use tutorial within seven days of purchase have a higher 90-day repeat-purchase rate than comparable customers who do not receive it.” The hypothesis identifies an exposure, outcome, comparison, and timeframe. It does not, by itself, establish a causal claim.

An Illustrative Case: Diagnosing Declining Customer Retention

Background

A fictional subscription software company, Northstar Analytics, reports that its quarterly retention rate has declined. Management requests a predictive model to identify customers likely to cancel.

Situation and initial problem

The available data contains subscription records, login events, support tickets, plan type, billing history, and customer characteristics. The first apparent challenge is to build a classifier. However, preliminary inspection reveals that cancellation is recorded at the subscription level, while login data contains multiple rows per customer per day. A direct join would duplicate subscription records and distort customer-level summaries.

Exploratory analysis

The team first defines the observational unit as the customer-subscription-period. It checks whether the outcome is cancellation within the 30 days following an observation date. Missing cancellation dates are distinguished from active subscriptions and from records with incomplete system migration.

A time plot shows that the reported decline is concentrated in customers acquired during a recent marketing campaign. Stratified analysis indicates that these customers are disproportionately on a low-priced plan and have shorter tenure. Login frequency is strongly right-skewed: most customers log in occasionally, while a small group logs in very often. The mean therefore overstates typical usage, so the median and selected percentiles are reported.

A box plot suggests lower activity among customers who later cancel, but a scatterplot and grouped summaries show substantial overlap. Support-ticket volume is positively associated with cancellation, yet investigation finds that some tickets are created by customers seeking help during onboarding. This illustrates why association must be interpreted in temporal and operational context.

The missingness audit shows that industry sector is absent more often for small customers. Removing all incomplete records would disproportionately exclude this group. The team retains a missing category for descriptive analysis and evaluates whether the field should be used in a model.

Approach and solution

The analysts formulate two distinct objectives: a descriptive question about how retention differs across acquisition cohorts, and a predictive question about whether early engagement variables improve risk identification. They create customer-level features using only information available before the prediction date, avoiding data leakage. They compare retention rates across cohorts and plan a time-based validation design rather than a random split, because future predictions will concern later periods.

Outcome

The investigation shows that the headline decline is partly a cohort-mix effect and partly associated with weak onboarding engagement. Management introduces an onboarding experiment rather than treating the predictive model as proof that low login frequency causes cancellation. The final analysis is more useful because it separates measurement problems, descriptive patterns, prediction, and causal intervention.

Learning points

The case demonstrates the importance of defining the unit of analysis, checking temporal order, accounting for skewed distributions, examining missingness by subgroup, preventing leakage, and distinguishing an association from a causal explanation. EDA did not merely prepare data for modeling; it changed the business question itself.

Professional and Ethical Considerations

Exploratory analysis can influence resource allocation, customer treatment, hiring, credit decisions, and public policy. Analysts should therefore examine whether variables act as proxies for protected characteristics or reproduce historical disadvantage. Group comparisons should consider privacy, sample size, and the risk of stigmatizing interpretations.

Data minimization is preferable to collecting or retaining irrelevant personal information. Access controls, secure storage, retention policies, and appropriate de-identification are part of responsible analysis. Analysts must communicate uncertainty and avoid presenting a visually persuasive pattern as established fact. Reproducible code, documented transformations, versioned datasets, and review by domain experts support accountability.

Automated EDA tools and AI assistants can rapidly generate summaries, charts, anomaly flags, and natural-language interpretations. They can also select inappropriate statistics, overlook sampling bias, or produce confident explanations unsupported by the data. Automation should accelerate inspection, not replace human judgment about meaning, provenance, fairness, and consequences.

Common Errors and Best Practices

Frequent errors include averaging nominal codes, using the mean for heavily skewed data without explanation, deleting outliers automatically, treating missing values as zero, joining tables without checking cardinality, interpreting correlation as causation, and testing many hypotheses without validation. Another serious error is allowing information from the future to enter a feature used to predict the past.

Sound practice includes:

  • Begin with the decision and define the analytical unit.
  • Maintain a data dictionary and provenance record.
  • Use summaries and visualizations suited to measurement scale.
  • Inspect distributions overall and within relevant subgroups.
  • Treat missingness, duplicates, and outliers as questions requiring investigation.
  • Distinguish descriptive, predictive, and causal objectives.
  • Record cleaning and transformation decisions.
  • Check temporal order and possible leakage.
  • Report uncertainty, limitations, and alternative explanations.
  • Validate important findings on new data or through appropriately designed studies.

Current Developments

Modern data understanding increasingly involves high-volume event streams, cloud data warehouses, feature stores, and automated data-quality monitoring. Data observability systems can track freshness, schema changes, volume anomalies, and unexpected distributions. In machine-learning operations, monitoring must continue after deployment because populations, behaviors, and measurement processes change. Concept drift occurs when the relationship between predictors and outcomes changes; data drift occurs when the predictor distribution changes.

Privacy-preserving methods, synthetic data, fairness auditing, and responsible AI governance are becoming integral to exploratory practice. These developments do not remove the need for statistical reasoning. Rather, they make careful measurement, documentation, and interpretation more important as data systems become larger and more automated.

Chapter Summary

Data understanding establishes what data represents, how it was generated, and what conclusions it can support. The analytical unit, data structure, provenance, and operational definitions must be clarified before modeling. Measurement scales determine valid summaries and comparisons. Exploratory analysis uses numerical summaries, visualizations, subgroup comparisons, and temporal investigation to reveal distributions, anomalies, associations, and possible explanations.

Sampling design, missingness, selection bias, and uncertainty determine whether findings can be generalized. Data quality must be assessed across accuracy, completeness, consistency, validity, uniqueness, timeliness, and fitness for purpose. A strong analyst converts broad business aims into precise questions and hypotheses while separating descriptive, predictive, and causal claims. Ethical practice requires attention to privacy, fairness, reproducibility, uncertainty, and the consequences of automated analysis.

Key Terms

Analytical unit: The entity or event represented by one observation in a dataset.

Association: A statistical relationship between variables.

Bias: Systematic error that causes estimates or conclusions to differ from the target truth.

Correlation: A measure of the strength and direction of association, commonly for two numerical variables.

Data dictionary: Documentation describing variables, formats, meanings, and permitted values.

Data provenance: The history and origin of data, including collection and transformation processes.

Distribution: The pattern of values and their frequencies in a variable.

Exploratory data analysis: The systematic use of summaries and visualizations to investigate data.

IQR: The difference between the third and first quartiles.

Measurement scale: The level of meaning and permissible operations associated with a variable.

Missingness: The condition in which a value is unavailable, unrecorded, or intentionally withheld.

Observational unit: See analytical unit; the row-level entity being studied.

Outlier: An observation unusually distant from the main pattern of data.

Population: The complete set of units to which an inference is intended to apply.

Sampling frame: The practical list or mechanism from which a sample is selected.

Selection bias: Distortion caused by how observations enter or remain in a dataset.

Standard deviation: A measure of dispersion around the mean.

Variable: An attribute that can take different values across observations.

Review Questions

Short Answer Questions

1. Why must the analytical unit be defined before tables are joined?

2. Distinguish nominal, ordinal, interval, and ratio measurement scales.

3. Why is the median often preferred for a strongly right-skewed variable?

4. What is the difference between sampling variability and sampling bias?

5. Why should missing values not automatically be replaced with zero?

Long Answer Questions

1. Explain how data provenance and a data dictionary support reliable exploratory analysis.

2. Discuss the role of histograms, box plots, scatterplots, and time plots in understanding distributions and relationships.

3. Explain why correlation does not establish causation, using confounding and temporal order in your discussion.

4. Describe major dimensions of data quality and propose an audit procedure for a newly received dataset.

5. Explain how a broad business objective can be converted into an analytical question and a testable hypothesis.

Analytical / Application Questions

1. A dataset contains one row per transaction but a marketing report treats each row as one customer. Identify the likely analytical problem and describe how you would correct the analysis.

2. A company observes that customers who contact support cancel more often. Propose at least two alternative explanations and an exploratory analysis to distinguish them.

3. A survey has high response rates among older customers and very low response rates among younger customers. Explain the likely threat to inference and recommend strategies for analysis and reporting.

22. Multiple Choice Questions with Answers

Question 1

A dataset contains several rows for each customer because each row represents a purchase. What is the main risk of calculating the average customer revenue directly across rows?

A. The data will necessarily contain no missing values

B. Customers with more purchases will receive greater weight

C. Nominal variables will become interval variables

D. The median will always equal the mean

Correct Answer: B. Customers with more purchases will receive greater weight

Question 2

Which summary is generally most resistant to extreme values in a strongly right-skewed distribution?

A. Arithmetic mean

B. Range

C. Median

D. Variance

Correct Answer: C. Median

Question 3

A variable records satisfaction as dissatisfied, neutral, and satisfied. Which measurement scale best describes it?

A. Nominal

B. Ordinal

C. Interval

D. Ratio

Correct Answer: B. Ordinal

Question 4

Why can a correlation between advertising expenditure and sales not by itself establish that advertising caused the sales increase?

A. Correlation cannot be negative

B. Sales and advertising are always measured nominally

C. A third variable or reverse causation may explain the association

D. Correlation is valid only for categorical variables

Correct Answer: C. A third variable or reverse causation may explain the association

Question 5

Which situation is an example of coverage bias?

A. A survey sample excludes people without internet access

B. A sensor records a value twice

C. A value is rounded to two decimal places

D. A histogram uses wide bins

Correct Answer: A. A survey sample excludes people without internet access

Question 6

In the Northstar Analytics case, why was a time-based validation design preferable to a purely random split?

A. It guarantees perfect prediction

B. The intended predictions concern future periods

C. It removes all missing values

D. It converts categorical variables into numerical variables

Correct Answer: B. The intended predictions concern future periods

Question 7

Replacing a missing income value with zero is potentially misleading because zero may represent:

A. A valid absence of income only

B. A different measurement scale

C. A value that has a substantive meaning different from missingness

D. A confidence interval

Correct Answer: C. A value that has a substantive meaning different from missingness

Question 8

Which visualization is most directly suited to examining the relationship between two numerical variables?

A. Scatterplot

B. Pie chart

C. Single bar chart of category counts

D. Frequency table of one variable

Correct Answer: A. Scatterplot

Question 9

An analyst removes every unusually large transaction without investigation. What is the principal danger?

A. All variables become ordinal

B. Valid rare events or fraud signals may be discarded

C. The sample becomes a population

D. The IQR becomes impossible to calculate

Correct Answer: B. Valid rare events or fraud signals may be discarded

Question 10

Which statement best distinguishes exploratory analysis from confirmatory analysis?

A. Exploratory analysis can generate hypotheses, whereas confirmatory analysis evaluates specified claims

B. Exploratory analysis never uses visualizations

C. Confirmatory analysis cannot use samples

D. Exploratory analysis proves causation by definition

Correct Answer: A. Exploratory analysis can generate hypotheses, whereas confirmatory analysis evaluates specified claims

Data Mining and Feature Engineering
Chapter 2 of 15