概念
Cleaning data: outliers, missing values, duplicates
Detect outliers, impute missing values, remove duplicates and fix types with Glue, DataBrew, Data Wrangler or Spark.
本课尚未翻译,暂以英文显示。
Outliers, skewed
- Method
- IQR rule, 1.5 times IQR
- Note
- Robust to skew
Outliers, normal
- Method
- Z-score beyond about 3
- Note
- Assumes a bell shape
Outliers, many features
- Method
- Random Cut Forest
- Note
- Unsupervised score
Duplicates
- Method
- DISTINCT or fuzzy match
- Note
- Normalize text first
Wrong types
- Method
- Cast, one unit, one encoding
- Note
- Do it before merging
| Problem | Method | Note |
|---|---|---|
| Outliers, skewed | IQR rule, 1.5 times IQR | Robust to skew |
| Outliers, normal | Z-score beyond about 3 | Assumes a bell shape |
| Outliers, many features | Random Cut Forest | Unsupervised score |
| Duplicates | DISTINCT or fuzzy match | Normalize text first |
| Wrong types | Cast, one unit, one encoding | Do it before merging |
1 / 2
Outliers, skewed
- Method
- IQR rule, 1.5 times IQR
- Note
- Robust to skew
Outliers, normal
- Method
- Z-score beyond about 3
- Note
- Assumes a bell shape
Outliers, many features
- Method
- Random Cut Forest
- Note
- Unsupervised score
| Problem | Method | Note |
|---|---|---|
| Outliers, skewed | IQR rule, 1.5 times IQR | Robust to skew |
| Outliers, normal | Z-score beyond about 3 | Assumes a bell shape |
| Outliers, many features | Random Cut Forest | Unsupervised score |
2 / 2
Duplicates
- Method
- DISTINCT or fuzzy match
- Note
- Normalize text first
Wrong types
- Method
- Cast, one unit, one encoding
- Note
- Do it before merging
| Problem | Method | Note |
|---|---|---|
| Duplicates | DISTINCT or fuzzy match | Normalize text first |
| Wrong types | Cast, one unit, one encoding | Do it before merging |
是什么
Outliers are values far from the rest. The IQR rule flags values below Q1 minus 1.5 times the IQR or above Q3 plus 1.5 times the IQR, and it works on skewed data. The z-score rule flags values more than about 3 standard deviations from the mean, and it assumes roughly normal data. Random Cut Forest (RCF) is an unsupervised model that scores how unusual each point is, for many features at once: SageMaker has it as a built-in algorithm. Investigate first. Then remove an error, cap the value at a limit (winsorizing), or keep a real extreme.
是什么
Missing values need a choice. If few rows are affected at random, drop them. Otherwise impute: the mean for symmetric numbers, the median for skewed numbers, the mode or an Unknown label for categories, the previous value for time series. Model-based imputation predicts the missing value from other columns, for example with k-NN. Add a missing indicator column, so the model learns that a value was absent. Drop a column that is mostly empty.
是什么
Duplicates: exact duplicates are removed with DISTINCT or dropDuplicates. Near duplicates need normalization (case, spaces, punctuation) and fuzzy matching, or MinHash or embedding similarity for text. Fix types too: strings to numbers and dates, one unit and one currency, one encoding. Do these in AWS Glue with Spark and DynamicFrames, in DataBrew recipe steps, in Data Wrangler transforms, or in Spark on EMR, and run them in the curated zone.
要记住
- IQR for skewed data. Z-score beyond about 3 for roughly normal data. RCF for many features.
- Outliers: investigate, then remove, cap or keep.
- Mean for symmetric, median for skewed, mode for categories, previous value for time series.
- Add a missing indicator column when absence carries meaning.
- Exact duplicates: DISTINCT. Near duplicates: normalize and match.
要记住
- Tools: Glue, DataBrew, Data Wrangler, Spark on EMR.
考试中
- “Income has a long right tail with a few extreme values” points to the median for imputation and an IQR rule for outliers.
- “Detect unusual points across many features with no labels” points to Random Cut Forest.
- “Remove near-identical customer records” points to normalization with fuzzy matching.