This project explores linear regression and state space models with a focus on practical forecasting workflows. The code originated from a semiconductor yield analysis engagement where online linear regression was the baseline and state space modeling provided better fidelity for drifting processes and level shifts. The repository now offers reproducible simulations, side-by-side comparisons, and lightweight visual artifacts.
SimulateRegressionModel.py— a Python script organised with#%%cells that synthesises several time-series scenarios, benchmarks online OLS against statsmodels' unobserved components models, and saves plots plus GIF animations.SimulateRegressionModel.ipynb— a notebook view of the same workflow for interactive inspection.artifacts/— generated figures and animations (created after running the script or notebook).
The repository is configured for the uv package manager and ships with:
pyproject.tomldescribing runtime dependenciesuv.lockcapturing resolved versions
Feel free to use another toolchain, but uv ensures fast, reproducible setups.
# Create the virtual environment and install dependencies
uv sync
# Regenerate synthetic data, plots, and GIF animations
uv run python SimulateRegressionModel.pyAll artefacts are written to the artifacts/ directory. Existing files are
overwritten on subsequent runs.
Open SimulateRegressionModel.ipynb in VS Code or Jupyter. Each section mirrors
the script's #%% cells. Running every cell will populate the same figures and
metrics that the CLI workflow produces.
The legacy/SimulateRegressionModel_old.ipynb notebook contains the earliest
experiments, including Stan-based heavy-tailed models and alternative animation
snippets. It is not maintained, but remains available for historical context.