ladderlore
  • S3 や IAM などのサービス名を入力してください。

概念

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
Five cleaning problems and the method for each.

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

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
Five cleaning problems and the method for each.
Few rows, at random?
Skewed numbers?
Drop the rows
Median plus indicator
Mode or Unknown
yesnoyesno
How to treat missing values.

概要

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.