Lesson 3.13core3 h

Feature engineering, data quality and data-centric ML

The unglamorous work that decides whether anything else matters

In applied ML the model is rarely the bottleneck; the data is. Scaling and encoding decide whether distance-based models work at all, leakage silently fakes good results, and imbalanced classes make accuracy lie. The data-centric mindset you build here carries straight into the LLM era, where data quality dominates pretraining and fine-tuning outcomes (8.1 The LLM lifecycle and model landscape, 8.2 Fine-tuning and PEFT) and evaluation sets are the most valuable asset you own (8.7 Evaluating LLMs).

You'll be able to

  • Choose scaling, encoding and transformation strategies per feature type and per model family
  • Detect and prevent the main kinds of leakage with pipelines and time-aware splits
  • Handle missing values, outliers and class imbalance without corrupting evaluation
  • Measure feature importance with permutation importance and SHAP, and practice data-centric error analysis

Key ideas

  1. Scale features for distance/gradient-based models (kNN, SVM, regularized linear, neural nets); trees don't need it. Fit scalers on training data only.
  2. One-hot for low cardinality; target encoding only out-of-fold with smoothing; embeddings for high-cardinality categories.
  3. Encode cyclical time with sin/cos; build time-series features from the past only; let domain knowledge create ratios and interactions.
Show 5 more key ideas
  1. Impute thoughtfully (MCAR/MAR/MNAR) and add missing indicators; treat outliers deliberately rather than deleting them.
  2. Leakage = target leakage, train–test contamination, or temporal leakage; prevent it with pipelines, dedup and time-based splits.
  3. For imbalance use PR-AUC/F1, class weights and threshold tuning; never resample validation or test data.
  4. Prefer permutation importance and SHAP (Shapley values sum to prediction − baseline) over impurity importance; importance ≠ causality.
  5. Data-centric ML: fix labels, cover failing slices, deduplicate, document (datasheets, model cards) and protect your evaluation set.

Suggested path through this lesson