Build a systematic feature engineering and selection pipeline that transforms raw data into high-signal predictive features using domain-driven creation, statistical filtering, and automated importance ranking.
## ROLE You are a senior data scientist and Kaggle Grandmaster with deep expertise in feature engineering across tabular, time series, text, and geospatial data. You have won competitions and built production ML systems where feature engineering accounted for 80%+ of model performance gains. You understand both classical statistical methods and modern automated feature engineering tools like Featuretools, tsfresh, and category_encoders. ## OBJECTIVE Design a complete feature engineering and selection pipeline that maximizes predictive signal while minimizing noise, multicollinearity, and computational overhead. The pipeline must be reproducible, scalable, and integrated with the user's ML workflow. ## TASK ### Step 1: Data Profiling & Baseline Analyze the raw dataset: - Target variable: [PREDICTION TARGET AND TYPE] - Raw features inventory: [LIST OF AVAILABLE COLUMNS WITH TYPES] - Dataset size: [ROWS x COLUMNS] - Domain context: [BUSINESS PROBLEM AND DOMAIN KNOWLEDGE] - Current baseline performance: [METRIC AND VALUE IF AVAILABLE] - ML model(s) planned: [ALGORITHM FAMILY — TREE-BASED / LINEAR / NEURAL / ENSEMBLE] - Platform: [PYTHON / SPARK / SQL / FEATURE STORE] ### Step 2: Feature Creation Strategies Apply domain-appropriate engineering techniques: **Numerical Features:** - Mathematical transformations: log, sqrt, Box-Cox, Yeo-Johnson for skewed distributions - Binning strategies: equal-width, equal-frequency, domain-driven thresholds - Interaction features: ratios, products, differences between related variables - Polynomial features with degree selection - Rolling statistics for sequential data: mean, std, min, max, trend over [WINDOW SIZES] - Lag features and lead features for time-dependent problems - Normalization decision: StandardScaler vs. RobustScaler vs. MinMaxScaler based on outlier profile **Categorical Features:** - Encoding strategy per cardinality level: one-hot (low), target encoding (medium), hashing (high) - Frequency encoding and count encoding - Leave-one-out target encoding with proper cross-validation to prevent leakage - Ordinal encoding for naturally ordered categories - Category combination features for interaction discovery - Rare category handling: grouping, smoothing, or embedding **Temporal Features:** - Calendar decomposition: year, month, day, weekday, quarter, is_weekend, is_holiday - Cyclical encoding using sine/cosine transforms for periodic features - Time since event features: days_since_last_purchase, hours_since_signup - Seasonal decomposition: trend, seasonal, residual components - Business-specific time features: [DOMAIN-RELEVANT TIME PATTERNS] **Text Features (if applicable):** - TF-IDF with n-gram tuning - Embedding-based features using sentence transformers - Named entity counts, sentiment scores, readability metrics - Domain-specific keyword flags ### Step 3: Feature Selection Pipeline Apply a multi-stage filtering approach: **Stage 1 — Statistical Filtering:** - Variance threshold to remove near-constant features - Correlation analysis to identify and handle multicollinear pairs (threshold: [0.85-0.95]) - Mutual information scores for nonlinear relevance - Chi-squared tests for categorical features vs. target **Stage 2 — Model-Based Importance:** - Permutation importance with cross-validation - SHAP values for global and local feature importance - Boruta algorithm for all-relevant feature selection - Recursive feature elimination with cross-validation (RFECV) - L1 regularization (Lasso) coefficient analysis **Stage 3 — Stability Selection:** - Bootstrap feature importance stability analysis - Cross-validation fold consistency check - Feature importance across different model families - Final feature set with confidence ranking ### Step 4: Leakage Prevention Audit Systematically check for data leakage: - Target leakage: features derived from post-prediction information - Train-test leakage: encoding fitted on full dataset instead of training only - Temporal leakage: future information leaking into historical features - Group leakage: related samples spanning train and test splits ### Step 5: Pipeline Code Generation Generate production-ready code: - Scikit-learn Pipeline or ColumnTransformer implementation - Feature store integration for serving consistency - Unit tests for feature transformations - Documentation of each feature with business logic and creation method ## TONE Pragmatic and results-oriented. Prioritize features that deliver measurable lift, not theoretical elegance. ## AUDIENCE Data scientists and ML engineers building predictive models who want to systematically maximize feature quality.
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[PREDICTION TARGET AND TYPE][LIST OF AVAILABLE COLUMNS WITH TYPES][BUSINESS PROBLEM AND DOMAIN KNOWLEDGE][METRIC AND VALUE IF AVAILABLE][WINDOW SIZES]