Build pipeline for imbalanced classification
Problem Description
You are tasked with building an end-to-end classification pipeline for a tabular dataset characterized by a severely imbalanced binary target variable, where the minority class constitutes less than 5% of the data. The goal is to develop a robust pipeline that addresses this imbalance and accurately evaluates model performance.
Requirements
The pipeline must fulfill the following technical requirements:
- Data Splitting: Divide the dataset into training and testing sets using stratification to ensure that the original class ratios are preserved in both subsets.
- Feature Preprocessing:
- Numeric Features: Implement imputation for missing values, followed by standardization.
- Categorical Features: Implement imputation for missing values, followed by safe encoding (e.g., one-hot encoding, label encoding).
- Resampling Strategy: Apply a suitable resampling method exclusively to the training data to mitigate class imbalance, strictly avoiding data leakage from the test set.
- If the dataset contains only numeric features, SMOTE (Synthetic Minority Over-sampling Technique) is an acceptable choice.
- If the dataset contains a mix of numeric and categorical features, SMOTENC (SMOTE for Nominal and Continuous features) must be used to correctly handle the different data types.
- Model Training: Train a reasonable baseline classifier. Examples include logistic regression or a tree-based model.
- Performance Evaluation: Report the precision, recall, and F1-score on the held-out test set. Both per-class metrics and macro/weighted averages are acceptable.
Assumptions
- The input features
Xwill be provided as a pandas DataFrame. - The target variable
ywill be provided as a pandas Series.
Deliverables
- Reproducible Python code, primarily utilizing
scikit-learnandimbalanced-learnlibraries, that implements the described pipeline and outputs the specified performance metrics on the held-out test set. - Brief, concise comments within the code or a separate short write-up justifying key architectural and methodological choices, such as the selected resampling method and the overall pipeline order.
AI interview prep
Core dilemma
Balancing the need to effectively learn from a severely underrepresented minority class against the risk of data leakage, overfitting to synthetic samples, and misinterpreting real-world model performance.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Build pipeline for imbalanced classification
Problem Description
You are tasked with building an end-to-end classification pipeline for a tabular dataset characterized by a severely imbalanced binary target variable, where the minority class constitutes less than 5% of the data. The goal is to develop a robust pipeline that addresses this imbalance and accurately evaluates model performance.
Requirements
The pipeline must fulfill the following technical requirements:
- Data Splitting: Divide the dataset into training and testing sets using stratification to ensure that the original class ratios are preserved in both subsets.
- Feature Preprocessing:
- Numeric Features: Implement imputation for missing values, followed by standardization.
- Categorical Features: Implement imputation for missing values, followed by safe encoding (e.g., one-hot encoding, label encoding).
- Resampling Strategy: Apply a suitable resampling method exclusively to the training data to mitigate class imbalance, strictly avoiding data leakage from the test set.
- If the dataset contains only numeric features, SMOTE (Synthetic Minority Over-sampling Technique) is an acceptable choice.
- If the dataset contains a mix of numeric and categorical features, SMOTENC (SMOTE for Nominal and Continuous features) must be used to correctly handle the different data types.
- Model Training: Train a reasonable baseline classifier. Examples include logistic regression or a tree-based model.
- Performance Evaluation: Report the precision, recall, and F1-score on the held-out test set. Both per-class metrics and macro/weighted averages are acceptable.
Assumptions
- The input features
Xwill be provided as a pandas DataFrame. - The target variable
ywill be provided as a pandas Series.
Deliverables
- Reproducible Python code, primarily utilizing
scikit-learnandimbalanced-learnlibraries, that implements the described pipeline and outputs the specified performance metrics on the held-out test set. - Brief, concise comments within the code or a separate short write-up justifying key architectural and methodological choices, such as the selected resampling method and the overall pipeline order.