Train LinearSVC to beat a hidden baseline
DRWMachine Learning Engineer · Online AssessmentLast updated
Train LinearSVC to beat a hidden baseline evaluates ML product requirements, data/labeling, modeling, serving architecture, evaluation, monitoring, and trade-offs in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Question
You are given a dataset and a fixed model class: LinearSVC. Implement train(X_train, y_train) and test(X_test) so that the model's accuracy on a held-out (hidden) test set beats a provided baseline accuracy. The model class is fixed — you may only modify preprocessing, feature engineering, and training hyperparameters; you may not switch to a different estimator.
Address the following:
- Implement
train()andtest().train(X_train, y_train)fits the pipeline;test(X_test)returns predictions (and a way to report accuracy) on data it has never seen. Keep the final classifier strictlyLinearSVC. - Propose and justify data-centric improvements. Experiment with adjustments and explain why each helps a linear large-margin model — e.g. standardization/normalization, robust scaling, outlier handling, TF–IDF or hashing for text, tokenization/n-grams, one-hot or frequency encoding for categoricals, dimensionality reduction / feature selection, feature crosses, deduplication and label-noise cleanup, and class-imbalance strategies (
class_weight='balanced', threshold tuning on margins). Note which side — data tweaks vs. model tweaks — moved accuracy more. - Handle mixed-type data. Build one pipeline that correctly routes numeric, categorical, and free-text columns.
- Tune without peeking at the test set. Describe a robust validation strategy (stratified k-fold, nested CV, or a held-out set) that lets you tune and decide you've beaten the baseline using only the training data, then freeze the configuration. Prevent data leakage by fitting all preprocessing inside the training folds only.
- Make it reproducible and measurable. Provide reproducible code (fixed seeds, saved artifacts), an experiment log, and a plan for estimating generalization (CV mean ± std, confidence intervals, robustness checks).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.