Repository navigation
Feat/containerize - #6
Merged
Merged
Conversation
This commit introduces a new FastAPI application for serving the Human Activity Recognition (HAR) model, along with Docker support for deployment. Key changes include: - Creation of a FastAPI app with endpoints for health checks, label retrieval, and predictions based on input data. - Implementation of a Dockerfile to facilitate containerization of the application, ensuring a lightweight and reproducible environment. - Addition of a .dockerignore file to exclude unnecessary files from the Docker context. - Updates to the pyproject.toml to include new dependencies for ONNX model handling and HTTP client testing. - Comprehensive documentation updates, including a new model card and serving instructions in the README. These enhancements enable efficient deployment and usage of the HAR model in production environments, improving accessibility and usability for end-users.
…lation This commit introduces a new CI workflow and a Makefile to facilitate testing and installation processes. Key changes include: - Creation of a `.github/workflows/ci.yml` file to automate testing with Python 3.12, including steps for installing dependencies, running Ruff for linting, and executing pytest for tests. - Addition of a `Makefile` with targets for installation, testing, auditing, preparing data, training, evaluating, and serving the model. - Updates to `.editorconfig` and `.gitattributes` to ensure consistent formatting and line endings for the Makefile across different environments. These enhancements improve the development workflow by automating testing and providing a clear structure for project setup and execution.
This commit includes several key updates: - Downgraded `pyarrow` dependency from `23.0.1` to `19.0.1` to ensure compatibility with MLflow 2.22.5. - Updated the CI configuration in `.github/workflows/ci.yml` to use Python 3.13. - Rewritten sections of the `README.md` to provide clearer insights into model performance metrics and evaluation protocols, emphasizing the primary metric of macro-F1. - Improved the `data/README.md` to clarify the checksum handling for dataset integrity. - Enhanced documentation across various files, including `docs/data_card.md`, `docs/limitations.md`, and `docs/model_card.md`, to better reflect the current state of the project and its methodologies. These changes improve the overall clarity, compatibility, and usability of the project.
This commit introduces several key updates to the evaluation framework: - Added a new `figures` target in the Makefile to generate visualizations from evaluation reports. - Integrated `matplotlib` for plotting and added new functions to create confusion matrices and per-class F1 score visualizations. - Updated `README.md` to include instructions for generating figures and added new images to the documentation. - Introduced new dependencies in `pyproject.toml` for `matplotlib`. - Enhanced the `evaluate.py` script to automatically generate figures after summarizing reports. - Added unit tests for the new plotting functionalities to ensure correctness. These changes improve the project's ability to visualize and interpret model performance metrics, facilitating better insights into evaluation results.
… it. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ship a CPU inference path for the honest watch model, plus the CI/Makefile/docs needed to reproduce and talk about the numbers without leaking the student notebook split.
The headline result does not change: Protocol B watch statistical XGBoost is 0.7031 macro-F1. Phone under the same protocol is 0.3272. The student 0.8559 accuracy is Protocol A only (leaky windows, same people in train and test). This PR makes that distinction the default story in the README, and it makes the watch tree runnable as an API.
Serving
python -m har.models.exportfits one device from a train YAML and writes ONNX (XGBoost trees via onnxmltools) plus a sidecar JSON. joblib is the fallback for stubs / non-XGB.har.serve.app) exposesGET /health,GET /labels,POST /predictfor one 5 s / 20 Hz window (T=100,C=6). WrongT,C,device, orhzis 422. Body over 1 MiB is 413.device: cpueven if the YAML says cuda.serving/Dockerfile) is inference-only: numpy, FastAPI, uvicorn, onnxruntime. It does not install MLflow, XGBoost, or pyarrow. Build from the repo root, mountmodels/.configs/protocol_b_watch_stat_xgb.yaml). Phone is a different model; do not send phone windows to a watch bundle.The served fit is a refit on all windows (one subject held out only for early stopping). Cite GroupKFold numbers from
docs/reports/, not from the export command. Abstain ismax(proba) < thresholdwith default0.0(never abstain). Uncalibrated.Evaluation and docs
har.eval.plotsbuilds the README ladder, leakage, ablation, per-class, and per-group figures fromdocs/reports/.make eval/make figureskeep those images aligned with the JSON.Tooling
pip install -e ".[dev]", ruff, pytest. No WISDM download.install,test,audit,prepare,train,eval,figures,serve.pyarrowpinned to19.0.1so it stays compatible with MLflow 2.22.5.CI fix on this branch
models/in.gitignorematched any directory namedmodels, includingsrc/har/models/. Older files in that package were already tracked;export.pywas added after the ignore rule, so it never left the laptop. CI then failed withNo module named 'har.models.export'. The rule is now/models/. There is a regression test so this does not come back.The matplotlib / pydantic messages in the CI log are third-party deprecation warnings. They are not failures.
Test plan
python -m ruff check src testspython -m pytest -q(fixtures only; 146 tests locally)src/har/models/export.pyis in the GitHub tree for this branchpython -m har.models.export --config configs/protocol_b_watch_stat_xgb.yaml --out models/watch_stat_xgb.onnxthenHAR_MODEL_PATH=... make serveand hit/health+/predictdocker build -f serving/Dockerfile -t har-api .and run with$PWD/models:/models(Git Bash needsMSYS_NO_PATHCONV=1)Out of scope
No TCN / 1D CNN. Hierarchical does not beat flat 18-way macro-F1 and cannot be exported (
predict_proba). Protocol C is still 46/5 x 3, not 51-fold LOSO. Concat is stacked 6-channel windows, not 12-channel phone+watch fusion.