Based on the MLS-C01 exam guideReport an error
transform.This week covered the first half of EDA, data cleaning and feature engineering. Both are central to MLS-C01 Domain 2 (Exploratory Data Analysis) and are the stages that most determine model performance in practice.
[Raw Data]
│
├─ 1) Cleaning (Day 1)
│ Missing values: judge MCAR/MAR/MNAR → impute (mean/median/KNN/model)
│ Outliers: detect with IQR/Z-score → delete/clip/transform/keep
│ Duplicates & errors: clean before the split (prevent leakage)
│
├─ 2) Feature Engineering (Day 2–3)
│ Scaling: normalization/standardization/RobustScaler (not needed for trees)
│ Encoding: Label/One-Hot/Target (decided by order and cardinality)
│ Binning: nonlinearity and interpretability ↔ information loss
│ Dates: component decomposition + sin/cos
│ Text: BoW → TF-IDF → embeddings
│ High cardinality: target/hashing/embeddings
│
└─ 3) AWS Tools (Day 4)
Data Wrangler (visual) → Processing Job (scale) → Feature Store (reuse)| Situation | Recommendation |
|---|---|
| Right-skewed numeric | Median imputation |
| Symmetric numeric | Mean imputation |
| Categorical | Mode imputation |
| Strong correlation between variables | KNN or model-based |
| The missingness itself is a signal (MNAR) | Add an indicator variable |
| Missing rate is overwhelmingly high | Drop the column or keep only the flag |
Is there an order? ── Yes ──→ Ordinal/Label Encoding
│
└─ No ──→ Are there many unique values?
├─ Few → One-Hot
└─ Many → Target/Frequency/Hashing/Embedding| Judgment | Treatment |
|---|---|
| Obvious data-entry error | Delete |
| You only want to reduce the extreme influence | Winsorizing (clipping) |
| Right-skewed, long-tailed distribution | Log transform |
| The outlier is the target (fraud, failure) | Keep it; approach as anomaly detection |
💡 Concept: One principle runs through this entire week: preventing data leakage. Imputation statistics (mean, median), scaler parameters (min/max/μ/σ), target-encoding statistics, the vocabulary of a text vectorizer — every one of these transformations must be fit on the training data only, and validation and test data get only
transform. Duplicate removal belongs before the split, and time-series features must respect point-in-time. Leakage inflates offline performance unrealistically and then collapses in production; it is a trap in both exams and real work.
| Pair | Key difference |
|---|---|
| Mean vs median imputation | Median is robust to outliers and skew |
| Z-score vs IQR | IQR is robust and needs no distribution assumption |
| Normalization vs standardization | Normalization gives a fixed [0,1] range; standardization gives mean 0 and variance 1; with outliers use RobustScaler |
| Label vs One-Hot | Ordinal → Label, nominal → One-Hot |
| One-Hot vs Target encoding | Safe for low cardinality vs compresses high cardinality (watch for leakage) |
| Target vs Hashing | Uses target information (leakage) vs no dictionary needed (collisions) |
| BoW vs TF-IDF | TF-IDF suppresses common words |
| TF-IDF vs embeddings | Treats words independently vs captures semantic similarity |
| Equal-width vs equal-frequency binning | Even value ranges vs even sample counts |
| Online vs Offline Store | Millisecond single-record inference vs bulk training reads |
| Data Wrangler vs Processing Job | Visual EDA vs code-based large-scale processing |
| Delete vs winsorizing | Discard the row vs cap it at the boundary value and keep it |
💡 Concept: Feature engineering and model selection cannot be separated. With the same data, a linear model needs scaling, binning and one-hot encoding to capture nonlinearity and scale explicitly, while a tree or boosting model needs no scaling and gains little from binning or one-hot (because trees capture nonlinearity through splits). The answer to "Which preprocessing is right?" depends on "Which model will you use?" The exam often exploits this, using the algorithm as a clue to narrow down the correct preprocessing.
Most questions that ask you to pick the "wrong procedure" are on this list.
| Wrong procedure | Why it is leakage | Correct approach |
|---|---|---|
| Compute the mean on all data, then split | Test statistics get mixed into training | Split first, fit only on the training set |
| Remove duplicates after the split | The same record is scattered across both sets | Clean by key before the split |
| Target-encode using all data | Answer information enters the feature | K-fold target encoding / smoothing |
| Split a time series randomly | Past is predicted using future data | Split chronologically |
| Use full-period aggregate features | Includes values after the prediction time | Point-in-time aggregation |
| Vocabulary that includes test documents | Test vocabulary is reflected in training | Fit the vectorizer on the training set only |
| Feature selection on all data | The selection itself sees the test set | Select within the training set |
| Role | Technique / tool | One line |
|---|---|---|
| Missing-value diagnosis | MCAR/MAR/MNAR | Why it is missing determines the treatment |
| Missing-value imputation | Mean, median, mode, KNN, MICE | Chosen by distribution and inter-variable relationships |
| Outlier detection | IQR, Z-score, Isolation Forest | Robust statistics are the default |
| Outlier treatment | Delete, clip, log transform, keep | Domain context decides |
| Scaling | Standard, MinMax, Robust, MaxAbs | Not needed for tree-based models |
| Encoding | Label, One-Hot, Ordinal, Target, Frequency | Decided by order and cardinality |
| High cardinality | Hashing, Embedding | No dictionary needed (collisions) / captures meaning |
| Binning | Equal-width, equal-frequency, domain binning | Nonlinearity ↔ information loss |
| Dates | Component decomposition, sin/cos, lag/rolling | Watch for point-in-time leakage |
| Text | BoW, TF-IDF, N-gram, embeddings | Steps of expressiveness and cost |
| NLP services | Amazon Comprehend, BlazingText | Managed extraction / built-in embeddings |
| Visual preparation | SageMaker Data Wrangler | 300+ transforms, quality reports, flow export |
| Large-scale processing | SageMaker Processing Job | Distributed container execution, auto-termination |
| Feature reuse | SageMaker Feature Store | Online/Offline, point-in-time |
| Bias diagnosis | SageMaker Clarify | Data and model bias, and explainability |
Answer these in your head.
| Phrase in the question | What to recall immediately |
|---|---|
| "Right-skewed distribution" | Median imputation, log transform, RobustScaler |
| "Normal distribution cannot be assumed" | IQR-based outlier detection |
| "Whether a value is missing is itself meaningful" | Add an indicator variable (MNAR) |
| "Uses XGBoost / Random Forest" | Scaling options are usually wrong |
| "KNN / SVM / neural network / PCA" | Scaling is required |
| "Ordered grades" | Ordinal Encoding |
| "Unordered colors or regions" | One-Hot Encoding |
| "Thousands to millions of unique values" | Target / Hashing / Embedding |
| "New categories keep appearing in production" | Feature Hashing |
| "23:00 and 0:00 should be close" | sin/cos transform |
| "Want to reduce the influence of common words" | TF-IDF |
| "Want to group words with similar meanings" | Embeddings |
| "Extreme values in fraud detection" | Do not remove them |
| "No-code, quick preparation and diagnosis" | Data Wrangler |
| "Large-scale distributed processing with custom code" | Processing Job |
| "Consistent training and inference feature definitions" | Feature Store |
| "Millisecond single-record lookup" | Feature Store Online |
| "Only values as of the prediction time" | point-in-time lookup |
Next week (Week 4) covers the second half of EDA — data visualization, distribution and correlation analysis, and dimensionality reduction (PCA), the techniques for analysis and drawing insights.
Click a choice to reveal the answer and explanation.
Question 1
You have decided to use a Random Forest model. Which of the following preprocessing steps has the LEAST effect on this model?
Question 2
Which of the following is a faulty preprocessing procedure that causes data leakage?
Question 3
There are three categorical variables: "gender (male/female)," "grade (low < medium < high)," and "city (thousands of values)." Which is the correct pairing of the most appropriate encoding for each?
Question 4
You want to prepare data visually and then export the transformation flow to a Processing Job for large-scale execution and to Feature Store. Which starting tool is MOST appropriate?
Question 5
There is a numeric variable with a distribution that is long-tailed to the right, and you plan to use a linear regression model. Which of the following is the MOST inappropriate treatment?