100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This project builds a small, deterministic text-classification pipeline that assigns incoming messages to user-defined folders. It simulates email threads and message text, preserves complete threads during splitting, trains a TF-IDF + Logistic Regression model, and marks low-confidence predictions as “uncertain” rather than forcing a folder label. The pipeline emphasises reversible suggestions: predicted labels are produced alongside a confidence score and a flag indicating uncertainty so human review is straightforward.
The data is synthetic but designed to resemble short email messages across realistic folder labels: Work, Personal, Promotions and Spam. Thread structure is simulated so that related messages remain grouped and all identifiers are removed. This is a small dataset intended for teaching: it uses in-memory generated messages from simple templates and topic-specific vocabularies.
Run the project module. The command prints a JSON dictionary of metrics and sample suggestions. Example (from a terminal):
python project.py
No external data or network access is required.
Run pytest in the project directory. The tests verify deterministic behaviour, that expected metric keys exist, that metrics lie in valid ranges, and that the main held-out accuracy meets a conservative floor.
Measured by running python project.py (seed 42) on 2026-10-23; the tests in test_project.py assert the floor.
| Metric | Value |
|---|---|
| accuracy | 0.9781 |
| macro_recall | 0.9703 |
| n_test_messages | 183 |
| n_train_messages | 404 |
Also returned (see python project.py output): per_folder_recall (object), sample_high_conf_misclassifications (0 items), some_suggestions (6 items).
This is a small teaching dataset generated synthetically from templates and topic word lists; it does not reflect the full diversity, privacy issues or adversarial content of real mailboxes. The model is simple (TF-IDF + Logistic Regression) and does not handle attachments, HTML, or entity-level redaction. The uncertain category is based on a single probability threshold; in production that threshold should be calibrated and reviewers should inspect edge cases.
Possible next steps include: use larger, consented corpora; add phrase or topic models; incorporate thread context beyond single-message text; calibrate uncertainty with validation data; and implement a lightweight reviewer UI that applies reversible labels.
Full case study, build steps and evaluation checks: Email auto-categorization on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code