100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This small teaching project demonstrates a toy image-captioning pipeline using only scikit-learn and the built-in digits images (8x8 grayscale). It connects a simple image encoder (a RandomForestClassifier operating on flattened pixels) to a tiny, deterministic caption decoder that produces short template captions from the predicted digit label plus a small, explainable visual attribute. The goal is pedagogical: to show how an image representation can be connected to a language output and how to evaluate and check for hallucinations or missing objects in captions.
This project uses the sklearn.datasets.load_digits built-in dataset (8x8 grayscale images of handwritten digits 0–9). This is a synthetic/small stand-in and not photographic imagery. Ground-truth captions are synthetic templates generated from the digit label and a simple image-derived attribute (“stroked” vs “filled”) so the project demonstrates mechanics rather than real-world captioning.
Run project.py directly with Python 3.11+; it prints a JSON dictionary of metrics. Example:
python project.py
The main entrypoint is run(seed: int = 42) -> dict.
This repository includes pytest tests in test_project.py. Run:
pytest -q
Tests check the returned keys, numeric ranges, determinism and a conservative metric floor on the held-out caption token F1.
Measured by running python project.py (seed 42) on 2026-10-23; the tests in test_project.py assert the floor.
| Metric | Value |
|---|---|
| digit_accuracy | 0.9600 |
| caption_token_f1 | 0.9943 |
| num_train | 1347 |
| num_test | 450 |
| model | RandomForestClassifier |
| decoder | deterministic-template |
Read the
caption_token_f1value with care: the data here is small and synthetic with a planted, learnable structure, so a near-perfect score shows the pipeline works, not that the method would reach this on real data. See Limitations.
Full case study, build steps and evaluation checks: Image captioning model on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code