100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This small teaching project demonstrates how to compute and inspect receiver operating characteristic (ROC) curves and area under the ROC curve (AUC) for a binary classifier. The code trains a logistic regression on synthetic, imbalanced data, computes continuous scores for the positive class, constructs ROC and precision–recall (PR) curves, and produces a compact threshold table that shows false alarms and missed cases at selected thresholds. It also includes small checks for reversed labels and tied scores to illustrate how these situations affect ranking metrics.
This project uses synthetic binary classification data generated with scikit-learn’s make_classification. The dataset is deliberately imbalanced (more negatives than positives) to make precision–recall behaviour informative. The positive class is labelled 1. No external data is required.
Run the module directly: python project.py
The script prints a JSON object containing numeric metrics and a compact threshold table for review.
Run the tests with pytest: pytest -q
The tests validate presence of expected keys, metric ranges, a conservative AUC floor, and determinism of the main metric for a fixed seed.
This is a teaching example using synthetic data. Performance numbers do not represent any real application. The model is a simple LogisticRegression used to produce continuous scores; no calibration, feature engineering, hyperparameter search, or external validation is performed. The ROC and PR computations are computed on a single held-out split; cross-validation or repeated experiments would be needed for more reliable estimates.
Full case study, build steps and evaluation checks: ROC curve generator on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code