Types of Data › Practical Applications
Machine Learning from ScratchAll chapters Types of Data › Practical ApplicationsOne section · Sections in this chapter5 / 8 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Practical Implications
Data type constrains the analytical approaches that can represent a variable faithfully, but it rarely identifies one method by itself. Method choice also depends on:
- the research question
- whether a variable is an outcome or predictor
- the study design and dependence structure
- the distribution
- the model assumptions
Both quantitative and qualitative variables support descriptive, inferential, and predictive analysis when represented appropriately (Pennsylvania State University, n.d.-a).
Paul Velleman and Leland Wilkinson later summarized the limitation of rigid scale labels directly:
“…scale types are not fundamental attributes of the data…”
Their point is that scale type also depends on how a variable was measured, what else is known about it, and which question the analysis asks. The labels remain useful, but they are the beginning of method selection rather than the end.
Consider healthcare analytics. Pearson's correlation summarizes the strength and direction of a linear relationship between paired quantitative variables (Pennsylvania State University, n.d.-b). Poisson regression models occurrence counts under a Poisson conditional distribution; unequal observation windows require an exposure adjustment, and diagnostics should assess overdispersion (Pennsylvania State University, n.d.-c). A blood-pressure measurement or hospital-visit count does not determine either method on its own. Similarly, purchase amounts and ordinal satisfaction ratings need representations that preserve their meanings. In quality control, defect counts often call for count-aware process-control methods rather than methods that assume a continuous measurement, provided the method's distributional conditions are reasonable.
Best Practices
Start by identifying the semantic type and analytical role of each variable. At minimum, a useful data dictionary records:
- variable names and definitions
- units
- data types
- value codes
- missing-value codes
- derivations
For modeling work, it can also record measurement properties and whether a variable is an outcome, predictor, identifier, or weight (UK Data Service, 2021). For mixed datasets, consider whether the estimator handles each type natively or needs type-specific transformations.
For quantitative data, distinguish interval from ratio scales. Celsius temperatures support meaningful differences but not ratios of raw readings; ratios of weights measured in compatible units are meaningful. For qualitative data, preserve the absence or presence of order: nominal and ordinal variables often need different encodings. Exploratory analysis can reveal unexpected values and coding problems, but metadata and domain knowledge are needed to establish a variable's semantic measurement level.
Data Requirements and Preprocessing
Data quality checks should reflect the variable's meaning. For quantitative data, verify units and plausible ranges, then investigate unusual values instead of deleting them automatically (NIST/SEMATECH, n.d.-b). Convert measurements of the same quantity to common units before comparing their numerical values (NIST, 2010). For qualitative data, use consistent labels and distinguish missing, unknown, not applicable, and observed categories.
Preprocessing also depends on the model:
- For scale-sensitive methods, continuous features often benefit from standardization or another scale transformation fitted only on the training data; many tree-based methods are largely insensitive to feature scale (scikit-learn developers, n.d.-a).
- For count outcomes, diagnostics that show overdispersion warn that a basic Poisson model may fit poorly. When excess zeros are present and domain knowledge supports a separate zero-generating process, a zero-inflated model may be considered (Pennsylvania State University, n.d.-c; Lambert, 1992).
- For nominal variables, one-hot encoding gives each category a separate binary feature.
- For ordinal variables, ordinal encoding can preserve a defensible order, but numeric codes may make an estimator assume ordering or equal spacing that the data do not establish (scikit-learn developers, n.d.-b).
Document mappings, learned parameters, exceptions, and the rationale for each decision.
Common Pitfalls
Common pitfalls include:
- Treating an ordinal variable as nominal, which prevents the fitted analysis from exploiting its known order unless that order is restored.
- Treating arbitrary category codes as quantitative, which can impose unsupported distances.
- Assuming interval data has ratio properties, which leads to invalid multiplicative interpretations.
- Dichotomizing a continuous variable, which discards information and usually reduces statistical power; broader binning can also conceal gradients and nonlinear relationships (Altman & Royston, 2006). Age bins, for example, can hide relationships that a suitable continuous model could retain.
- Misclassifying qualitative measurement levels, which can produce unsuitable encodings or prevent a model from using known order.
Validate representations with domain knowledge, metadata, exploratory analysis, and model diagnostics.