Train and improve a scikit-learn binary classifier
Practical ML Fundamentals (Python + scikit-learn)
You are provided with a small toy binary classification dataset, which may be given as separate training and validation sets (e.g., X_train, y_train, X_valid, y_valid) or as a single dataset that you need to split.
Your task is to:
- Train a baseline binary classifier using scikit-learn.
- Select a suitable model (e.g., logistic regression, linear SVM, random forest, gradient boosting).
- Fit the chosen model to the training data.
- Evaluate the trained model on the validation set using appropriate metrics.
- Consider metrics such as accuracy, precision, recall, F1-score, ROC-AUC, PR-AUC, and confusion matrix.
- Improve the evaluation metric(s) based on the initial results.
- This may involve changing the model, tuning hyperparameters, adjusting data preprocessing steps, addressing class imbalance, modifying decision thresholds, or refining the validation strategy.
Constraints / Expectations
- Implement the solution using Python and scikit-learn APIs.
- Ensure the code is clean, reproducible, and avoids data leakage. Consider using
Pipelineand settingrandom_state. - Clearly articulate your choices and explain the expected impact of each modification on the chosen evaluation metrics.
AI interview prep
Core dilemma
Balancing model complexity and generalization performance on unseen data, while ensuring reproducible and robust evaluation.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Train and improve a scikit-learn binary classifier
Practical ML Fundamentals (Python + scikit-learn)
You are provided with a small toy binary classification dataset, which may be given as separate training and validation sets (e.g., X_train, y_train, X_valid, y_valid) or as a single dataset that you need to split.
Your task is to:
- Train a baseline binary classifier using scikit-learn.
- Select a suitable model (e.g., logistic regression, linear SVM, random forest, gradient boosting).
- Fit the chosen model to the training data.
- Evaluate the trained model on the validation set using appropriate metrics.
- Consider metrics such as accuracy, precision, recall, F1-score, ROC-AUC, PR-AUC, and confusion matrix.
- Improve the evaluation metric(s) based on the initial results.
- This may involve changing the model, tuning hyperparameters, adjusting data preprocessing steps, addressing class imbalance, modifying decision thresholds, or refining the validation strategy.
Constraints / Expectations
- Implement the solution using Python and scikit-learn APIs.
- Ensure the code is clean, reproducible, and avoids data leakage. Consider using
Pipelineand settingrandom_state. - Clearly articulate your choices and explain the expected impact of each modification on the chosen evaluation metrics.