The resampling placement tripped me up more than I expected.
Structure your answer as a clear, modular pipeline: start with a train-test split, then build a ColumnTransformer for preprocessing, apply a resampling technique (e.g., SMOTE) only to the training data, and train a classifier. Evaluate on the untouched test set using precision, recall, and F1, and discuss trade-offs and alternatives.
Pro tip: Always apply resampling inside a pipeline or only to the training fold to avoid data leakage; use imbalanced-learn's Pipeline to combine resampling and classification seamlessly.
Split the data into training and test sets with stratification to preserve class ratios. Build a preprocessing pipeline using ColumnTransformer to handle numerical and categorical features (e.g., scaling, one-hot encoding).
Choose a resampling method like SMOTE, ADASYN, or RandomUnderSampler based on the imbalance severity and dataset size. Apply it only to the training data to prevent leakage.
Use imbalanced-learn's Pipeline to chain preprocessing, resampling, and a classifier (e.g., RandomForest, LogisticRegression). This ensures resampling is applied only during training.
Fit the pipeline on the training set and predict on the held-out test set. Compute precision, recall, and F1 score using scikit-learn's metrics, focusing on the minority class.
Discuss the impact of resampling on precision-recall balance, consider alternative approaches like class weights or threshold tuning, and mention cross-validation with resampling inside each fold.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.