概念 · 基于 AIF-C01
Feature engineering techniques
Scale, encode, split and reduce features, and know which algorithms care about scale.
本课尚未翻译,暂以英文显示。
你在AI Practitioner中已学过
- A feature is an input to a model. Training data is split into training, validation and test sets.
- Feature engineering shapes raw columns into inputs a model can learn from.
- Missing values and categories need handling before training.
Standardization
- What it does
- Mean 0, spread 1
- Use it when
- Distance or gradient models
Min-max
- What it does
- Rescales to 0 to 1
- Use it when
- A bounded range is needed
Log transform
- What it does
- Pulls in a long tail
- Use it when
- Skewed counts or money
Binning
- What it does
- Number to ranges
- Use it when
- Steps or noisy values
| Numeric | What it does | Use it when |
|---|---|---|
| Standardization | Mean 0, spread 1 | Distance or gradient models |
| Min-max | Rescales to 0 to 1 | A bounded range is needed |
| Log transform | Pulls in a long tail | Skewed counts or money |
| Binning | Number to ranges | Steps or noisy values |
One-hot
- What it does
- A 0 or 1 column per category
- Use it when
- Few unordered categories
Ordinal
- What it does
- Ordered categories to integers
- Use it when
- Size or grade
Target encoding
- What it does
- Category to its average target
- Use it when
- Many categories
Feature splitting
- What it does
- Date to year, month, weekday
- Use it when
- Hidden parts matter
PCA
- What it does
- Fewer combined components
- Use it when
- Too many correlated features
TF-IDF
- What it does
- Scores words by rarity
- Use it when
- Text for classic models
| Other | What it does | Use it when |
|---|---|---|
| One-hot | A 0 or 1 column per category | Few unordered categories |
| Ordinal | Ordered categories to integers | Size or grade |
| Target encoding | Category to its average target | Many categories |
| Feature splitting | Date to year, month, weekday | Hidden parts matter |
| PCA | Fewer combined components | Too many correlated features |
| TF-IDF | Scores words by rarity | Text for classic models |
1 / 2
One-hot
- What it does
- A 0 or 1 column per category
- Use it when
- Few unordered categories
Ordinal
- What it does
- Ordered categories to integers
- Use it when
- Size or grade
Target encoding
- What it does
- Category to its average target
- Use it when
- Many categories
| Other | What it does | Use it when |
|---|---|---|
| One-hot | A 0 or 1 column per category | Few unordered categories |
| Ordinal | Ordered categories to integers | Size or grade |
| Target encoding | Category to its average target | Many categories |
2 / 2
Feature splitting
- What it does
- Date to year, month, weekday
- Use it when
- Hidden parts matter
PCA
- What it does
- Fewer combined components
- Use it when
- Too many correlated features
TF-IDF
- What it does
- Scores words by rarity
- Use it when
- Text for classic models
| Other | What it does | Use it when |
|---|---|---|
| Feature splitting | Date to year, month, weekday | Hidden parts matter |
| PCA | Fewer combined components | Too many correlated features |
| TF-IDF | Scores words by rarity | Text for classic models |
是什么
Numeric features: standardization (z-score) subtracts the mean and divides by the standard deviation, so values center on 0. Min-max normalization rescales values to a range, usually 0 to 1. A log transform pulls in a long right tail, such as income or counts. Binning turns a number into ranges, such as age groups, to capture steps or reduce noise. Fit the scaler on the training set only, then apply it to validation and test data.
是什么
Scale matters to models that use distances or gradients: k-NN, k-means, support vector machines, linear and logistic regression, neural networks and PCA. Tree-based models, such as XGBoost and random forests, split on thresholds and do not care about scale.
是什么
Categorical features: one-hot encoding makes a 0 or 1 column per category and suits few categories with no order. Ordinal encoding maps ordered categories (small, medium, large) to integers. Target encoding replaces a category by the average of the target and handles many categories, but must be computed carefully to avoid leakage. Feature splitting breaks a field into parts, such as a date into year, month and weekday. Feature selection drops features that add little. PCA combines features into fewer components. TF-IDF scores words by how special they are to a document.
要记住
- Z-score: mean 0. Min-max: a fixed range. Log: tames skew. Binning: ranges.
- Fit scalers on training data only.
- Scale matters for k-NN, k-means, SVM, linear models, neural networks and PCA.
- Trees (XGBoost, random forest) do not need scaling.
要记住
- One-hot for few unordered categories. Ordinal for ordered ones. Target encoding for many.
- Split dates. Select features. PCA reduces dimensions. TF-IDF scores words.
考试中
- “A right-skewed income column hurts a linear model” points to a log transform.
- “Many distinct categories, one-hot would be huge” points to target encoding, with care for leakage.
- “Scaling is not needed for this model” points to a tree-based algorithm such as XGBoost.
本任务内容 · 1.2
Glue ETL
DataBrew
EMR
Data Wrangler
SageMaker Processing
Athena
Feature Store
- Transforming streaming data
- Feature engineering techniques
- Embedding models for text and image
- Text pre-processing and tokenization
- Preparing documents for RAG
- Masking, redaction and anonymization
- Data for fine-tuning, continued pre-training and distillation