100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This small teaching project implements a Gaussian-process-based Bayesian optimiser (a surrogate model + acquisition rule) to tune two hyperparameters of a RandomForestClassifier on a synthetic binary classification task. It compares the optimiser to repeated random search under the same trial budget and records trial histories (including failed runs). The aim is to demonstrate how a surrogate-guided search can more efficiently find good hyperparameters than pure random sampling under a fixed budget, and to make the optimisation loop explicit so students see the surrogate, acquisition and evaluation steps.
This project uses a synthetic classification dataset generated with sklearn.datasets.make_classification (800 samples, 10 informative features, balanced classes). The data is intentionally small and synthetic so the code runs quickly and deterministically for teaching.
Run the module as a script. It exposes run(seed: int = 42) -> dict and prints JSON when executed. Example: python project.py
This repository includes pytest tests. Run pytest in the project directory. The tests check that the run function returns the expected keys, that metrics are in sensible ranges, that the main held-out metric meets a conservative minimum, and that run(seed) is deterministic.
Measured by running python project.py (seed 42) on 2026-10-23; the tests in test_project.py assert the floor.
| Metric | Value |
|---|---|
| best_val_loss | 0.2971 |
| best_val_loss_random | 0.2910 |
| improvement | -0.0061 |
| budget | 12 |
Also returned (see python project.py output): best_params (object), trials (12 items), random_histories (3 items), dataset (object).
Full case study, build steps and evaluation checks: Bayesian optimization for hyperparameters on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code