100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This small project demonstrates training a boosted-tree classifier on tabular data and comparing it to a simple forest baseline. The goal is pedagogical: to show how to prepare a labelled table (including deliberate missing values), hold out a final test set, train a boosted-tree model with early stopping on a training-derived validation split, and report discrimination, calibration and runtime. Because the xgboost Python package is not available in the constrained environment for this assignment, this project uses scikit-learn’s HistGradientBoostingClassifier as a faithful, deterministic stand-in for XGBoost-style gradient boosting; the README and code explicitly note this.
The dataset is synthetic and created with sklearn.datasets.make_classification. It contains 1000 rows and 12 numeric features, of which several are informative. To emulate real-world data issues, a documented 5% of values are set to missing at random. The dataset is split stratified into a training set (80%) and an untouched test set (20%); the training set further uses an internal validation fraction for early stopping.
Run the project file with Python 3.11+: python project.py. The script prints a JSON object with metrics, runtime and a short report. The run(seed: int = 42) function can be imported and called programmatically.
Run pytest in the project directory: pytest -q. The test suite checks that run(42) returns the expected keys, that metric values lie in sensible ranges, that a conservative metric floor is met for the held-out ROC AUC, and that repeated calls with the same seed are deterministic.
Measured by running python project.py (seed 42) on 2026-10-23; the tests in test_project.py assert the floor.
| Metric | Value |
|---|---|
| n_samples | 1000 |
| n_features | 12 |
| auc_test | 0.9365 |
| brier_test | 0.0987 |
| accuracy_test | 0.8600 |
| auc_baseline | 0.9258 |
| brier_baseline | 0.1089 |
| accuracy_baseline | 0.8600 |
| time_seconds_boosted | 0.8322 |
| time_seconds_baseline | 0.7985 |
Also returned (see python project.py output): feature_names (12 items), packages (object), report (object).
Full case study, build steps and evaluation checks: XGBoost implementation for tabular data on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code