Feature Engineering
81 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Feature Engineering ## Encoding Categorical Data ## Feature Scaling ## Feature Selection Method Description When to Use Filter (correlation) Remove highly correlated features Quick preprocessing Wrapper (RFE) Recursive feature elimination Small to medium data Embedded (Lasso) L1 regularization High-dimensional dat...

Feature Engineering
Encoding Categorical Data
pythonimport pandas as pd from sklearn.preprocessing import LabelEncoder, OneHotEncoder # One-hot encoding df = pd.DataFrame({'color': ['red', 'blue', 'green', 'blue']}) encoded = pd.get_dummies(df, columns=['color']) print(encoded)
Feature Scaling
pythonfrom sklearn.preprocessing import StandardScaler, MinMaxScaler scaler = StandardScaler() X_scaled = scaler.fit_transform(X)
Feature Selection
| Method | Description | When to Use |
|---|---|---|
| Filter (correlation) | Remove highly correlated features | Quick preprocessing |
| Wrapper (RFE) | Recursive feature elimination | Small to medium data |
| Embedded (Lasso) | L1 regularization | High-dimensional data |
| Tree-based importance | Random Forest feature importance | Non-linear relationships |