Programming for Data Science (Python/R)

Chapter 7
Exploratory Data Analysis and Analytical Reasoning

Post Graduate Diploma in Data Science
Programming for Data Science (Python/R)   •   Post Graduate

7. Exploratory Data Analysis and Analytical Reasoning

Introduction: From Data to Questions

Exploratory Data Analysis (EDA) is the disciplined process of examining data before formal modelling or decision-making. It combines statistical summaries, visual reasoning, programming techniques, and domain knowledge to understand what a dataset contains, how its variables behave, and which patterns deserve further investigation. EDA is not merely the production of charts. It is a way of asking better questions and testing whether the available evidence is suitable for answering them.

In data science, analysis usually begins with an imperfect question such as: “Why are customers leaving?”, “Which patients are at higher risk?”, or “What explains differences in sales?” Such questions must be transformed into measurable analytical questions. The analyst must identify the population, outcome, explanatory variables, time period, unit of analysis, and decision that may be affected by the results.

EDA occupies an important position between data preparation and statistical or machine-learning modelling. It can reveal missing values, unusual observations, data-entry errors, skewed distributions, confounding variables, sampling bias, and relationships that may otherwise be hidden. It also helps determine whether the assumptions of later methods are reasonable. However, exploratory findings are usually provisional. A visible association may suggest a hypothesis without proving that one variable causes another.

Python and R provide extensive support for EDA. In Python, analysts commonly use pandas, NumPy, Matplotlib, Seaborn, and Plotly. In R, data frames, dplyr, ggplot2, tidyr, and summary tools serve similar purposes. The programming language is valuable not only because it produces graphs efficiently, but because code makes analysis reproducible, inspectable, and easier to revise.

Learning Objectives

After studying this chapter, students should be able to:

1. Convert broad organizational problems into precise analytical questions.

2. Describe the purpose and workflow of exploratory data analysis.

3. Perform and interpret univariate, bivariate, and multivariate exploration.

4. Identify patterns, anomalies, missingness, skewness, and possible data-quality problems.

5. Distinguish association and correlation from causation.

6. Recognize sampling bias, confounding, leakage, and violations of analytical assumptions.

7. Use Python or R to construct reproducible exploratory analyses.

8. Translate exploratory findings into decision-relevant hypotheses and next steps.

Analytical Questions Before Analytical Code

A useful EDA begins with a question rather than a visualization library. A business, public-sector, or scientific problem should be decomposed into several elements:

  • Unit of analysis: customer, transaction, patient, employee, household, or time period.
  • Outcome variable: the event or quantity to be explained or predicted.
  • Explanatory variables: characteristics that may be associated with the outcome.
  • Population and sample: the larger group of interest and the observed subset.
  • Time frame: the period during which observations were collected.
  • Decision context: the action that might follow from the analysis.

For example, “How can we reduce customer churn?” is too broad for immediate analysis. A stronger formulation is: “Among customers active at the beginning of the quarter, how does monthly usage relate to cancellation within the following 90 days, after accounting for contract type and tenure?” This question identifies a population, outcome, time horizon, explanatory variable, and potential controls.

Analytical questions may be descriptive, diagnostic, predictive, or prescriptive. Descriptive questions ask what happened; diagnostic questions investigate why patterns may have occurred; predictive questions estimate what may happen; and prescriptive questions consider what action should be taken. EDA is most directly descriptive and diagnostic, but it often supplies the evidence from which predictive or prescriptive hypotheses are developed.

A sound question also requires careful operationalization. “Income,” for example, might mean annual gross income, monthly disposable income, or reported income at application. Different definitions produce different analyses. Ambiguous variables create apparently precise but substantively weak conclusions.

A Working Framework for EDA

EDA is best understood as an iterative cycle rather than a rigid sequence:

1. Clarify the decision and question. Define what must be learned and why.

2. Inspect the data structure. Examine rows, columns, data types, identifiers, dates, and measurement units.

3. Assess data quality. Investigate missingness, duplicates, invalid values, inconsistent categories, and impossible records.

4. Explore variables individually. Study distributions, frequencies, central tendency, spread, and unusual observations.

5. Explore relationships. Compare variables using appropriate numerical summaries and visualizations.

6. Segment and condition the analysis. Examine groups, time periods, and relevant subpopulations.

7. Check assumptions and alternative explanations. Consider bias, confounding, dependence, and measurement limitations.

8. Formulate hypotheses and document decisions. Record what the evidence suggests and what must be tested next.

This process is iterative because an unusual pattern may reveal a data problem, while a data-quality investigation may require returning to the original question. Analysts should distinguish observations from interpretations. “The median order value is higher for membership customers” is an observation. “Membership causes customers to spend more” is a causal interpretation requiring substantially stronger evidence.

Data Structure and Quality as Analytical Evidence

The first inspection should establish the shape and granularity of the dataset. In Python, `df.shape`, `df.info()`, `df.head()`, `df.describe(include='all')`, and `df.nunique()` provide a basic structural review. In R, `dim()`, `str()`, `head()`, `summary()`, and `unique()` serve comparable purposes. These commands do not replace reasoning; they support it.

An identifier should generally identify an observation rather than act as an explanatory variable. A transaction-level dataset may contain several rows per customer, which means that treating rows as independent customers can distort averages and uncertainty. Similarly, a date field may need to be converted from text and decomposed into month, weekday, season, or elapsed time.

Data-quality checks include:

  • duplicate records and duplicated identifiers;
  • impossible values, such as negative age or a percentage above 100;
  • inconsistent units, currencies, or time zones;
  • category variations such as “M”, “Male”, and “male”;
  • missingness concentrated in particular groups;
  • values introduced after the outcome occurred;
  • extreme values that may be errors or legitimate rare cases.

Missing data is not automatically harmless. If missing values occur completely at random, their effects may be limited. If missingness depends on observed or unobserved characteristics, simply deleting records can produce biased results. A missing income value may be more common among applicants unwilling or unable to disclose income. The pattern of missingness is therefore itself an object of analysis.

Univariate Exploration: Understanding Variables Individually

Univariate analysis examines one variable at a time. For numerical variables, important summaries include count, mean, median, minimum, maximum, quartiles, variance, and standard deviation. The mean is sensitive to extreme observations, whereas the median is more robust. The interquartile range, calculated as the third quartile minus the first quartile, describes the spread of the middle half of the observations.

A distribution should be examined rather than reduced to a single statistic. Histograms and density plots can reveal symmetry, skewness, multiple modes, gaps, and heavy tails. Box plots provide a compact view of quartiles and potential outliers. For categorical variables, frequency tables and bar charts show category prevalence and rare levels.

The shape of a distribution affects both interpretation and modelling. Income, transaction values, response times, and population counts are often right-skewed: many observations are relatively small and a few are very large. In such cases, the mean may substantially exceed the median. A logarithmic transformation may make the distribution easier to model, but transformations change interpretation and should not be applied mechanically.

Outliers require investigation, not automatic removal. An outlier may be a recording error, a legitimate exceptional case, a member of a different population, or evidence of an important phenomenon. For example, an unusually large transaction could result from a decimal error, but it could also represent a valuable institutional customer. The appropriate response depends on the analytical purpose and the data-generating process.

For a binary outcome, the proportion of positive and negative cases is especially important. A fraud dataset in which only 0.5 percent of transactions are fraudulent is highly imbalanced. Accuracy alone would then be a poor summary for a classifier, and EDA should investigate whether the minority cases are systematically different from the majority.

Bivariate Exploration: Comparing Two Variables

Bivariate analysis examines whether and how two variables vary together. The correct method depends on their measurement types. Numerical variables may be compared with scatter plots, correlation coefficients, grouped summaries, or line charts. A numerical outcome and categorical predictor may be examined with box plots, violin plots, group means, medians, and confidence intervals. Two categorical variables may be compared using contingency tables, proportions, and stacked or grouped bar charts.

A scatter plot is often more informative than a correlation coefficient because it can reveal clusters, curvature, changing variance, or influential observations. Pearson correlation measures linear association and is sensitive to outliers. Spearman correlation uses ranks and can identify monotonic relationships even when the relationship is not linear. Neither measure proves causation, and a correlation near zero does not necessarily mean that no relationship exists; a strong nonlinear relationship may have little linear correlation.

Grouped comparisons must consider group size and uncertainty. A difference between two means may be unstable when one group contains very few observations. A box plot can show distributional overlap that a comparison of means conceals. Rates are often more meaningful than counts when group sizes differ. If one branch reports 50 complaints and another reports 20, the first branch may not be worse if it serves ten times as many customers.

Time is a particularly important bivariate dimension. A line chart can reveal trends, seasonality, sudden changes, and possible effects of policy or system changes. Temporal order matters: a variable observed after an outcome cannot legitimately be used to explain what preceded that outcome. Analysts must also distinguish a time trend from a causal effect, since many external conditions may change simultaneously.

Multivariate Exploration: Patterns in Context

Multivariate analysis examines three or more variables jointly. Its central purpose is to prevent misleading conclusions produced by examining relationships in isolation. A relationship between training and performance, for example, may differ by job role, experience, or manager. These variables can be examined through faceted plots, colour or shape encodings, pivot tables, heat maps, pair plots, grouped models, and dimensionality-reduction methods.

A useful concept is stratification: examining a relationship separately within meaningful subgroups. Suppose hospital readmission appears higher among patients receiving a particular treatment. If that treatment is used mainly for severe cases, severity may explain the association. Comparing treatment groups within severity bands may produce a different interpretation.

An interaction occurs when the relationship between one variable and an outcome depends on another variable. For example, a discount may increase sales among new customers but have little effect among loyal customers. A single overall average may hide this interaction. In exploratory work, interaction can be visualized by plotting separate lines or panels for the conditioning variable.

Multicollinearity occurs when explanatory variables contain overlapping information. Education and years of experience, for instance, may be strongly related. Correlated predictors can make individual effects difficult to interpret, even when prediction remains adequate. A correlation matrix is useful, but it does not capture every form of dependence and should be supplemented with domain reasoning.

Principal Component Analysis and other dimensionality-reduction methods can summarize high-dimensional structure, but their components are mathematical combinations rather than automatically meaningful constructs. Clustering can identify groups of similar observations, yet clusters depend on variable selection, scaling, distance measures, and algorithmic choices. Such methods are exploratory aids, not self-validating discoveries.

Association, Correlation, and Causation

Association means that variables occur together in a systematic way. Correlation is a numerical description of a particular kind of association, commonly linear or rank-based. Causation is a stronger claim: changing one factor would produce a change in another, under specified conditions.

Several mechanisms can create an association without direct causation:

  • Confounding: a third variable influences both variables of interest.
  • Reverse causality: the apparent outcome influences the supposed cause.
  • Selection bias: inclusion in the dataset depends on variables related to the analysis.
  • Measurement bias: a variable is recorded inaccurately or differently across groups.
  • Common trends: two variables rise together because of time or another external process.
  • Chance: a pattern appears in a particular sample but does not generalize.

Causal reasoning requires attention to study design, temporal ordering, plausible mechanisms, alternative explanations, and, where possible, randomization or credible quasi-experimental methods. EDA cannot establish causality by itself, but it can expose whether a causal interpretation is implausible or identify variables that a later causal analysis should address.

A classic error is to infer individual behaviour from aggregate data, known as ecological fallacy. The reverse error, assuming that a group-level pattern applies equally to every individual, is also dangerous. Analysts should state the level at which a finding applies and avoid language stronger than the design supports.

Bias, Assumptions, and Responsible Interpretation

Bias is a systematic distortion in data, analysis, or interpretation. Sampling bias arises when the observed sample does not adequately represent the population relevant to the decision. Survivorship bias occurs when analysis includes only entities that remain observable, such as successful firms or customers who have not yet cancelled. Label bias occurs when the target variable reflects unequal practices rather than the underlying phenomenon.

EDA should ask who is absent, who is overrepresented, and how the data were generated. A model trained on support tickets may represent customers who complain, not all customers. A health dataset collected in hospitals may not represent people who never seek treatment. Data collected for operational purposes may contain systematic recording differences across branches or demographic groups.

Analytical assumptions vary by method. Common concerns include independence of observations, linearity, constant variance, normality of residuals, adequate sample size, and reliable measurement. These assumptions should be evaluated in relation to the planned analysis rather than treated as universal rules. For example, raw variables need not be normally distributed for every regression procedure, but residual behaviour may affect inference.

Data leakage is a particularly serious risk in predictive work. Leakage occurs when information unavailable at prediction time, or information caused by the outcome, enters the analysis. A customer’s cancellation date, a post-discharge diagnosis, or a manually assigned risk category created after investigation may produce deceptively strong results. EDA must respect the information timeline.

From Patterns to Decision-Relevant Hypotheses

The purpose of exploration is not to collect attractive charts. It is to convert evidence into testable and useful next steps. A strong exploratory finding should specify:

1. the observed pattern;

2. the population and time period to which it applies;

3. plausible explanations;

4. important uncertainties and possible biases;

5. the decision it may inform; and

6. the next analysis or intervention required.

For example: “Customers with fewer than two monthly logins showed a higher cancellation rate in the previous quarter, particularly among month-to-month subscribers. This association may reflect dissatisfaction, low need for the service, or differences in customer type. We should test whether an onboarding intervention affects retention in a prospective experiment.” This statement is more useful than “low usage causes churn.”

Hypotheses should be falsifiable and operational. “Improve engagement” is vague. “A targeted onboarding message sent during the first week will increase the proportion of new customers completing two key actions within 14 days” defines an intervention and measurable outcome. Exploratory analysis can also generate null hypotheses, subgroup questions, and requests for additional data.

A Reproducible Python and R Workflow

A practical programming workflow separates data acquisition, cleaning, exploration, visualisation, and interpretation. In Python, a compact exploratory sequence might include:

```python

import pandas as pd

import seaborn as sns

import matplotlib.pyplot as plt

orders = pd.read_csv("orders.csv")

print(orders.shape)

print(orders.dtypes)

print(orders.isna().mean().sort_values(ascending=False))

print(orders.describe(include="all"))

sns.histplot(data=orders, x="order_value", bins=30)

plt.show()

sns.boxplot(data=orders, x="membership", y="order_value")

plt.show()

sns.scatterplot(data=orders, x="visits", y="order_value", hue="membership")

plt.show()

```

A comparable R workflow could use `readr::read_csv()`, `dplyr::glimpse()`, `summarise()`, `count()`, and `ggplot2` graphics. The important principle is not the particular syntax but the reproducibility of the process. Code, data definitions, package versions, filters, transformations, and chart labels should be retained. Random sampling or clustering should use a recorded seed when reproducibility is required.

Visualizations should have informative titles, labelled axes, meaningful units, and honest scales. Three-dimensional charts, excessive decoration, truncated axes, and inappropriate colour schemes can make interpretation harder. Accessibility requires adequate contrast and alternatives to colour-only distinctions.

Illustrative Case Study: Exploring Customer Churn

Background

A fictional subscription-software company, Northstar Analytics, reports that quarterly customer churn has increased. Management wants to know whether a retention campaign should target low-usage customers, customers on particular contracts, or all customers.

Situation and Data

The analyst receives 48,000 customer-quarter records containing customer identifier, contract type, tenure, monthly logins, support contacts, account size, region, and a binary indicator showing whether cancellation occurred during the next quarter. Several customers appear in multiple quarters. This means the unit of analysis is a customer-quarter, not a unique customer.

Initial Exploration

Structural inspection identifies 2,400 duplicate rows, missing region values concentrated in recently acquired customers, and a small number of negative login counts caused by a software migration. The analyst removes exact duplicates, investigates the migration records, and retains legitimate zero-login observations. Cancellation is more common among month-to-month customers than annual customers, but annual customers also have longer tenure, so contract type cannot be interpreted in isolation.

The distribution of logins is strongly right-skewed. The median customer logs in three times per month, while a small group logs in several dozen times. A histogram shows a large mass at zero. A simple mean would obscure this structure.

Bivariate and Multivariate Analysis

A grouped comparison shows greater churn among customers with zero or one login. However, when the analyst stratifies by tenure, the difference is much smaller among long-tenure customers. A faceted plot by contract type shows that low usage is most strongly associated with churn among new, month-to-month customers. Support contacts are also higher among some low-usage customers, suggesting that difficulty using the product may be an alternative explanation.

The analyst checks timing. Login counts are measured during the quarter before cancellation, while support contacts are recorded throughout the same period. A post-cancellation support ticket is excluded because it would leak outcome information. The analyst also finds that recently acquired customers are overrepresented in the missing-region group, so regional comparisons are reported cautiously.

Interpretation and Proposed Strategy

The evidence supports the hypothesis that low early engagement identifies customers who may benefit from onboarding, particularly those on month-to-month contracts. It does not prove that increasing logins will cause retention; highly motivated customers may both log in more and remain subscribed. Management therefore designs a randomized onboarding experiment among eligible new customers. The treatment group receives guided setup assistance, while the control group receives standard communication. Retention, product activation, support burden, and customer satisfaction are measured over a predefined period.

Outcome and Learning Points

The illustrative case demonstrates that a useful EDA can change the proposed intervention. An untargeted campaign would have been expensive and potentially ineffective. Exploration identified a subgroup, revealed data-quality problems, exposed a timing concern, and converted an association into a testable intervention hypothesis. Its main lesson is that segmentation and temporal reasoning are essential before organizational action.

Challenges and Common Mistakes

EDA can fail even when the code runs successfully. Common mistakes include conducting a large number of unplanned comparisons and reporting only the most attractive pattern; treating missing values as zero; deleting outliers without investigation; confusing counts with rates; ignoring repeated observations; and using inappropriate averages for skewed data.

Another error is overplotting. When millions of points are displayed, the plot may conceal rather than reveal structure. Sampling, transparency, binning, hexagonal plots, or aggregation may help, but the method should be documented. Analysts may also mistake statistical significance for practical significance. A tiny difference can be statistically detectable in a very large dataset but irrelevant to the decision.

Automation creates additional risks. Automated profiling tools can rapidly identify distributions and missingness, but they do not understand business definitions, causal direction, fairness implications, or whether a variable is ethically appropriate to use. AI-assisted coding can produce plausible but incorrect transformations or charts. Every generated result requires human review, domain validation, and reproducibility checks.

Ethical and Governance Considerations

Exploratory analysis can expose sensitive information even when no predictive model is produced. Analysts should apply data minimization, access controls, secure storage, and appropriate de-identification. Personal data should be used for a legitimate, documented purpose, with attention to applicable privacy and sector-specific regulation.

Fairness requires examining whether data quality, missingness, measurement, and outcomes differ across demographic or protected groups. Group comparisons should not be interpreted as evidence of innate differences when institutional conditions may explain them. Small groups may be identifiable through combinations of variables, and visualizations should be reviewed for disclosure risk.

Analytical decisions should be documented: the data source, inclusion criteria, transformations, exclusions, definitions, limitations, and intended use. Governance is not a barrier to exploration; it makes findings auditable and reduces the risk that provisional patterns will be converted into unjustified decisions.

Current and Emerging Developments

Modern EDA increasingly includes interactive dashboards, notebook-based collaboration, automated data-quality monitoring, and visual analytics over cloud-scale datasets. Probabilistic programming and causal-discovery tools can support deeper investigation, although their outputs remain dependent on assumptions and data quality. Privacy-preserving methods, synthetic data, and federated analysis are receiving attention where direct data sharing is restricted.

Large language models can assist with code generation, chart suggestions, and plain-language summaries. Their use is most reliable when analysts provide clear data dictionaries, validate every result, and prevent confidential data from being disclosed to unauthorized systems. The emerging professional role is therefore not merely to produce visualizations, but to combine computational fluency with statistical scepticism, domain knowledge, and responsible judgment.

Best Practices for Professional EDA

A professional EDA should begin with a decision and end with a documented set of hypotheses. Analysts should preserve raw data, work on controlled copies, inspect the unit of analysis, and maintain a data dictionary. They should use multiple summaries and visualizations, examine subgroups that are substantively justified, investigate missingness and outliers, and respect temporal order.

Findings should include uncertainty, sample sizes, relevant limitations, and the difference between description and explanation. Charts should be interpretable and accessible. Code should be reproducible, and exploratory choices should be recorded rather than silently changed. Most importantly, analysts should seek disconfirming evidence: a pattern that disappears after stratification, alternative measurement, or a time-based validation deserves caution.

Chapter Summary

Exploratory Data Analysis is an iterative practice for understanding data, diagnosing quality problems, discovering relationships, and developing testable hypotheses. It begins with a well-defined analytical question and proceeds through structural inspection, data-quality assessment, univariate analysis, bivariate comparison, and multivariate exploration. Distributions, missingness, outliers, group differences, time patterns, and interactions must be interpreted in context.

Association and correlation do not establish causation. Confounding, selection bias, reverse causality, measurement error, common trends, and leakage can produce misleading findings. A responsible analyst examines the data-generating process, respects temporal order, checks assumptions, and distinguishes observations from explanations. Python and R make EDA reproducible, but tools do not replace judgment.

The final product of EDA is not a collection of charts. It is a defensible account of what the data suggest, what remains uncertain, how bias may affect interpretation, and which decision-relevant hypotheses should be tested next.

Key Terms

Exploratory Data Analysis: The systematic examination of data to understand structure, quality, distributions, and relationships before formal modelling.

Unit of analysis: The entity represented by one observation or row in a dataset.

Univariate analysis: Examination of one variable at a time.

Bivariate analysis: Examination of the relationship between two variables.

Multivariate analysis: Examination of three or more variables jointly.

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

Skewness: Asymmetry in a variable’s distribution.

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

Interquartile range: The difference between the third and first quartiles.

Correlation: A numerical measure of association between variables, often focused on linear or rank-based dependence.

Confounding: Distortion of an observed relationship by a third variable related to both variables of interest.

Causation: A relationship in which changing one factor produces a change in another under specified conditions.

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

Interaction: A situation in which the relationship between one variable and an outcome depends on another variable.

Multicollinearity: Strong dependence or overlap among explanatory variables.

Data leakage: Use of information in analysis or prediction that would not be available at the relevant decision time.

Missingness: The condition in which expected values are absent from a dataset.

Stratification: Analysis of a relationship separately within defined subgroups.

Hypothesis: A specific, testable proposition about a pattern or relationship.

Review Questions

Short Answer Questions

1. Why should an analyst identify the unit of analysis before calculating summary statistics?

2. What is the difference between a median and a mean in the presence of skewed data?

3. Why does a correlation coefficient not establish causation?

4. Define data leakage and provide one example.

5. What is the purpose of stratifying an exploratory analysis?

Long Answer Questions

1. Explain the major stages of a professional EDA workflow, from question formulation to hypothesis development.

2. Compare univariate, bivariate, and multivariate exploration, including suitable techniques for each.

3. Discuss how missingness, outliers, and inconsistent measurement can influence analytical conclusions.

4. Explain confounding, selection bias, reverse causality, and common trends as threats to causal interpretation.

5. Describe how Python or R can support reproducible EDA and identify the responsibilities that remain with the analyst.

Analytical / Application Questions

1. A retailer finds that customers receiving discount codes purchase more than customers who do not receive them. Design an exploratory analysis that examines whether customer loyalty, prior spending, and campaign targeting could explain the association.

2. A hospital dataset shows that one treatment group has a higher readmission rate. Explain how you would investigate severity, age, timing, missingness, and treatment selection before interpreting the result.

3. A churn dashboard reports that low-login customers cancel more often. Formulate a decision-relevant hypothesis, identify two possible alternative explanations, and propose a suitable follow-up experiment or analysis.

22. Multiple Choice Questions with Answers

Question 1

Which statement best describes the primary purpose of Exploratory Data Analysis?

A. To prove that one variable causes another

B. To understand data structure, quality, patterns, and relationships before formal modelling

C. To replace the need for domain knowledge

D. To maximize the number of visualizations produced

Correct Answer: B. To understand data structure, quality, patterns, and relationships before formal modelling

Question 2

A transaction dataset contains ten rows for some customers and one row for others. What is the most important immediate concern?

A. The dataset cannot contain categorical variables

B. The unit of analysis may be confused with the unique customer

C. The mean must be equal to the median

D. All repeated rows must automatically be deleted

Correct Answer: B. The unit of analysis may be confused with the unique customer

Question 3

Which visualization is generally most suitable for examining the distribution of a single numerical variable?

A. Histogram

B. Contingency table

C. Grouped bar chart of two categories

D. Network diagram

Correct Answer: A. Histogram

Question 4

A strong correlation between ice-cream sales and swimming accidents is observed during summer. Which explanation is most plausible?

A. Ice-cream sales necessarily cause accidents

B. Swimming accidents necessarily cause ice-cream sales

C. A common factor, such as warmer weather, may influence both

D. Correlation proves the relationship is random

Correct Answer: C. A common factor, such as warmer weather, may influence both

Question 5

Why might an analyst stratify the relationship between treatment and outcome by disease severity?

A. To remove all variation from the data

B. To investigate whether severity confounds the observed relationship

C. To guarantee a causal conclusion

D. To convert categorical variables into identifiers

Correct Answer: B. To investigate whether severity confounds the observed relationship

Question 6

Which situation is an example of data leakage?

A. Using customer tenure measured before a prediction date

B. Using a cancellation date to predict whether cancellation will occur

C. Checking the number of missing values in a training dataset

D. Comparing medians across two pre-existing groups

Correct Answer: B. Using a cancellation date to predict whether cancellation will occur

Question 7

Why can a mean be misleading for a strongly right-skewed income distribution?

A. The mean ignores every observation below the median

B. A small number of very large values can pull the mean upward

C. The mean can only be used for categorical variables

D. The mean is always smaller than the minimum

Correct Answer: B. A small number of very large values can pull the mean upward

Question 8

An observed relationship disappears after customers are separated into tenure groups. What does this most directly suggest?

A. Tenure may have been masking or influencing the original relationship

B. The original relationship is automatically causal

C. The dataset contains no useful information

D. Stratification always creates false results

Correct Answer: A. Tenure may have been masking or influencing the original relationship

Question 9

Which statement is the strongest decision-relevant exploratory conclusion?

A. Low usage causes every customer to churn

B. The chart proves the retention campaign will succeed

C. Low early usage is associated with higher churn in a defined subgroup and warrants a controlled test

D. Customers with high usage are always more valuable

Correct Answer: C. Low early usage is associated with higher churn in a defined subgroup and warrants a controlled test

Question 10

Which practice best supports reproducible EDA?

A. Changing filters without recording them

B. Saving only the final chart

C. Documenting code, transformations, exclusions, definitions, and data versions

D. Relying exclusively on automated chart recommendations

Correct Answer: C. Documenting code, transformations, exclusions, definitions, and data versions

Programming for Data Science (Python/R)
Chapter 7 of 15