Tabular Model Shootout with Pipelines
Compare linear, kNN, tree, forest and boosting models on a real regression task using leak-proof pipelines, cross-validation, tuning and learning curves, then ship one saved pipeline you can defend.
Lessons this project uses
- 1Decision Trees and Random ForestsPhase 2: Machine learning fundamentals
- 2K-Nearest Neighbors and DistancesPhase 2: Machine learning fundamentals
- 3Model EvaluationPhase 2: Machine learning fundamentals
- 4Bias-Variance TradeoffPhase 2: Machine learning fundamentals
- 5Ensemble MethodsPhase 2: Machine learning fundamentals
- 6Hyperparameter TuningPhase 2: Machine learning fundamentals
- 7ML PipelinesPhase 2: Machine learning fundamentals
What You'll Build
A fair, reproducible model comparison on a real tabular regression problem. Every model sits inside the same scikit-learn Pipeline so preprocessing is fit per fold and nothing leaks. You compare model families with cross-validation, tune the two best with random search, use learning curves to say whether the winner is limited by bias or variance, and save the final pipeline so a separate script can load it and predict.
Requirements
- Dataset. Choose a public regression dataset with at least 1,000 rows and a mix of numeric and categorical columns (for example house prices, bike rentals, insurance charges, or used car prices). Explain what the target means and what an error of 1 RMSE would cost a user.
- Hold-out. Split off a test set (20%) with a fixed seed before any modeling. Use it once at the end.
- Pipeline. Build a
ColumnTransformerthat imputes and scales numeric columns and imputes and one-hot encodes categorical columns, wrapped with each model in aPipeline. - Model families. Compare at least five with 5-fold cross-validation on the training data: a mean predictor baseline, Ridge, kNN regressor, a decision tree, a random forest, and a gradient boosting model. Report mean and std of RMSE, MAE and R^2 per model in a table.
- Tuning. Run
RandomizedSearchCV(at least 20 trials, cross-validated) on the two best families. Report the best parameters and how much CV RMSE improved over defaults. - Bias and variance. For the tuned winner, plot a learning curve (train vs validation error as training size grows) to
results/learning_curve.pngand a validation curve over one complexity parameter (for examplemax_depthorn_neighbors) toresults/validation_curve.png. State whether the model is bias limited or variance limited and what you would do next. - Final test. Refit the tuned winner on all training data, evaluate once on the test set, and compare test RMSE with its CV RMSE.
- Interpretation. Compute permutation importance on the test set and list the top 5 features.
- Ship it. Save the fitted pipeline with
joblibtomodels/final_pipeline.joblib(gitignored if over 50 MB), and writepredict.pythat loads it, reads a CSV of raw rows, and prints predictions. Show that predictions from the reloaded pipeline match the in-memory ones exactly. - Save all numbers to
results/metrics.json; one command reruns the full experiment.
Constraints
- scikit-learn, pandas, NumPy and matplotlib only (XGBoost or LightGBM allowed but not required). Free public data.
- CPU only; keep the full run under 15 minutes on a laptop. Subsample to at most 50,000 rows with a fixed seed if needed, and set
n_jobssensibly.
Stretch Goals
- Add a stacking or voting ensemble and see if it beats the single winner.
- Use nested cross-validation to estimate how optimistic the tuned CV score is.
- Log each run's parameters and scores to a CSV or MLflow as an experiment tracker.
How to Submit
Public GitHub repo with README.md, train.py (or src/), predict.py, requirements.txt, a data download script or instructions, a small sample_input.csv, and results/ with metrics.json, learning_curve.png and validation_curve.png. The README must give run commands, your CV comparison table, tuned parameters, the final test numbers vs CV, your bias or variance diagnosis, the top features, the limitations of the model, and one experiment that did not help.
How It's Reviewed
Professor Katalock reads your repository and the evidence you paste, and scores each criterion out of 100. You pass with a weighted total of 70 or more and no criterion below 40. A copied or padded submission is flagged and fails.
Submit
Push your work to a public GitHub repository with a README that explains how to run it, then paste the evidence below. Up to 3 reviews a day, free.
- Link to the public GitHub repo
- Full terminal output of `python train.py`
- Output of `python predict.py sample_input.csv` including the reload match check
- Contents of results/metrics.json
- The learning_curve.png and validation_curve.png plots
Reviews are done by AI against the rubric above. They check the evidence in your repository; they are not a substitute for a human code review, and a review can be wrong. If you think it is, improve the README so the evidence is unmistakable and resubmit.