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 build a chronological time-series forecasting pipeline with windowed inputs, careful train/validation/test splits and a sequence model. The original starter used a RandomForest on lag columns; here we show a simple sequence-to-one model trained on fixed-length windows, compare it with a persistence baseline and a lag-feature linear regressor, and highlight limitations. Note: the environment for this assignment restricts deep-learning libraries (PyTorch/TensorFlow). To keep the exercise runnable with only the approved libraries, the code trains a small feed-forward network (MLP) on flattened windows and uses sklearn’s early stopping. The README is honest about that substitution and explains why windowing and split strategy still carry the same lessons as training an LSTM.
The data are synthetic and generated in code: 240 daily values composed from a small linear trend, a monthly-ish sinusoidal seasonality and Gaussian noise. This is a compact stand-in for real sensor/time-series data and is built with numpy inside the project (no downloads or file I/O).
Run the project module; it exposes run(seed: int = 42) and prints a JSON report when run as a script:
python project.py
run(seed) returns a JSON-serialisable dict containing the main held-out metrics, an example input window and its next-step prediction, and the tested horizon.
Use pytest. The provided test file imports run from project.py and checks keys exist, metrics fall inside valid ranges, determinism for a fixed seed, and a conservative metric floor on the main held-out metric.
Measured by running python project.py (seed 42) on 2026-10-23; the tests in test_project.py assert the floor.
| Metric | Value |
|---|---|
| seed | 42 |
| window_size | 30 |
| horizon_test_points | 30 |
| test_r2_mlp | 0.8677 |
| test_mae_mlp | 1.0226 |
| test_r2_persistence | 0.7358 |
| test_mae_persistence | 1.4200 |
| test_r2_ridge | 0.9042 |
| test_mae_ridge | 0.8480 |
| example_prediction_mlp | 6.2405 |
| notes | Model is an MLP on flattened windows used as a lightweight proxy for sequence models due to environment constraints. |
Also returned (see python project.py output): example_window (30 items).
Full case study, build steps and evaluation checks: LSTM for time series prediction on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code