From 11d66a4884a9be3b2a892024ed2c35ccc71207d5 Mon Sep 17 00:00:00 2001 From: 1bananas1 Date: Mon, 19 Oct 2026 16:40:38 -0500 Subject: [PATCH 1/4] Reorganize inference/ into one package (#244) Move the flat scripts into inference/pilot_inference/, grouped by the domain concerns in GLOSSARY.md: - capture/: data_logger - performance/: deviation features, clustering, synthetic pilots - event_classification/: the rule-based labeler and Random Forest, kept apart because the client has not asked for it - angles.py and paths.py shared at the package root The package is installed editable (hatchling build-system), so scripts run as `python -m pilot_inference..` from any directory. Paths for data/ and models/ come from paths.py instead of each script's own __file__. Also: - lowercase Data/, Models/ and dataset/ (prepared splits now live in data/prepared/); tests/ mirrors the package - test_model.py -> evaluate_model.py, since it is not a test - stop tracking models/*.pkl (already in .gitignore) and write only bestModel.pkl, not an identical finalModel.pkl - drop requirements.txt, Results/results.txt and Models/sample_Models.txt - keep raw_flight_data_updated.csv: it is the source of the committed labeled dataset, documented in inference/README.md - GLOSSARY.md: add Segment and Instruction, move the event classification terms to an out-of-scope section - update README, AGENTS.md, docs and .gitignore for the new paths --- .gitignore | 27 +- AGENTS.md | 6 +- GLOSSARY.md | 45 +- README.md | 4 +- .../0002-cluster-on-std-and-absolute-bias.md | 2 +- docs/telemetry_schema.md | 10 +- inference/Models/bestModel.pkl | Bin 815713 -> 0 bytes inference/Models/finalModel.pkl | Bin 815713 -> 0 bytes inference/README.md | 389 +++++++++--------- .../{Data => data}/labeled_flight_data.csv | 0 .../{dataset => data/prepared}/X_test.csv | 0 .../{dataset => data/prepared}/X_train.csv | 0 .../prepared}/label_mapping.json | 0 .../prepared}/scaler_params.json | 0 .../prepared}/test_processed.csv | 0 .../prepared}/train_processed.csv | 0 .../{dataset => data/prepared}/y_test.csv | 0 .../{dataset => data/prepared}/y_train.csv | 0 inference/{Data => data}/raw_flight_data.csv | 0 .../raw_flight_data_updated.csv | 0 .../__init__.py} | 0 inference/{ => pilot_inference}/angles.py | 0 .../capture/__init__.py} | 0 .../capture}/data_logger.py | 4 +- .../event_classification/__init__.py | 0 .../event_classification/evaluate_model.py} | 24 +- .../generate_balanced_data.py | 8 +- .../event_classification}/label_generator.py | 9 +- .../event_classification}/prepare_data.py | 14 +- .../event_classification}/train_model.py | 29 +- .../event_classification}/validate_labels.py | 8 +- inference/pilot_inference/paths.py | 8 + .../pilot_inference/performance/__init__.py | 0 .../performance}/cluster_pilots.py | 11 +- .../performance}/clustering.py | 2 +- .../performance}/compute_features.py | 9 +- .../performance}/features.py | 4 +- .../performance}/generate_synthetic_pilots.py | 10 +- inference/pyproject.toml | 9 +- inference/requirements.txt | 18 - .../tests/{ => capture}/test_data_logger.py | 10 +- .../test_label_generator.py | 2 +- .../{ => performance}/test_cluster_pilots.py | 6 +- .../{ => performance}/test_clustering.py | 6 +- .../tests/{ => performance}/test_features.py | 2 +- .../test_generate_synthetic_pilots.py | 4 +- inference/tests/test_angles.py | 2 +- inference/uv.lock | 84 ++-- 48 files changed, 372 insertions(+), 394 deletions(-) delete mode 100644 inference/Models/bestModel.pkl delete mode 100644 inference/Models/finalModel.pkl rename inference/{Data => data}/labeled_flight_data.csv (100%) rename inference/{dataset => data/prepared}/X_test.csv (100%) rename inference/{dataset => data/prepared}/X_train.csv (100%) rename inference/{dataset => data/prepared}/label_mapping.json (100%) rename inference/{dataset => data/prepared}/scaler_params.json (100%) rename inference/{dataset => data/prepared}/test_processed.csv (100%) rename inference/{dataset => data/prepared}/train_processed.csv (100%) rename inference/{dataset => data/prepared}/y_test.csv (100%) rename inference/{dataset => data/prepared}/y_train.csv (100%) rename inference/{Data => data}/raw_flight_data.csv (100%) rename inference/{Data => data}/raw_flight_data_updated.csv (100%) rename inference/{Models/sample_Models.txt => pilot_inference/__init__.py} (100%) rename inference/{ => pilot_inference}/angles.py (100%) rename inference/{Results/results.txt => pilot_inference/capture/__init__.py} (100%) rename inference/{Data => pilot_inference/capture}/data_logger.py (98%) create mode 100644 inference/pilot_inference/event_classification/__init__.py rename inference/{test_model.py => pilot_inference/event_classification/evaluate_model.py} (93%) rename inference/{ => pilot_inference/event_classification}/generate_balanced_data.py (97%) rename inference/{ => pilot_inference/event_classification}/label_generator.py (97%) rename inference/{ => pilot_inference/event_classification}/prepare_data.py (95%) rename inference/{ => pilot_inference/event_classification}/train_model.py (91%) rename inference/{ => pilot_inference/event_classification}/validate_labels.py (96%) create mode 100644 inference/pilot_inference/paths.py create mode 100644 inference/pilot_inference/performance/__init__.py rename inference/{ => pilot_inference/performance}/cluster_pilots.py (87%) rename inference/{ => pilot_inference/performance}/clustering.py (99%) rename inference/{ => pilot_inference/performance}/compute_features.py (83%) rename inference/{ => pilot_inference/performance}/features.py (98%) rename inference/{ => pilot_inference/performance}/generate_synthetic_pilots.py (93%) delete mode 100644 inference/requirements.txt rename inference/tests/{ => capture}/test_data_logger.py (92%) rename inference/tests/{ => event_classification}/test_label_generator.py (88%) rename inference/tests/{ => performance}/test_cluster_pilots.py (88%) rename inference/tests/{ => performance}/test_clustering.py (97%) rename inference/tests/{ => performance}/test_features.py (99%) rename inference/tests/{ => performance}/test_generate_synthetic_pilots.py (93%) diff --git a/.gitignore b/.gitignore index f6812ae..7e19bc1 100644 --- a/.gitignore +++ b/.gitignore @@ -39,26 +39,27 @@ iMotions.xml **/.venv/ **/__pycache__/ -# Generated ML pipeline outputs (regenerated by test_model.py / train_model.py) +# Generated ML pipeline outputs (regenerated by evaluate_model.py / train_model.py) inference/predictions_output.csv inference/evaluation_metrics.json -inference/Models/*.pkl -inference/dataset/test.csv +inference/models/*.pkl +inference/data/prepared/test.csv # Generated clustering inputs and outputs (regenerated by the scripts under inference/) -inference/Data/synthetic_pilot_telemetry.csv -inference/Data/synthetic_pilot_tiers.csv -inference/Data/flight_features.csv -inference/Data/pilot_features.csv -inference/Data/pilot_clusters.csv -inference/Data/group_centres.csv -inference/Data/client/* +inference/data/synthetic_flight_data.csv +inference/data/synthetic_pilot_telemetry.csv +inference/data/synthetic_pilot_tiers.csv +inference/data/flight_features.csv +inference/data/pilot_features.csv +inference/data/pilot_clusters.csv +inference/data/group_centres.csv # Collected telemetry (one file per collection session, written by data_logger.py) -inference/Data/session_flight_data.csv +inference/data/session_flight_data.csv # Local build archives /xplane_plugin.zip /src.zip -## Client Data -inference/data/Client/* \ No newline at end of file +## Client Data (restricted, never commit) +inference/data/Client/* +inference/data/client/* \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md index 2552e5d..b2cd181 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,7 +9,7 @@ Data flow: `xplane_plugin` (C++) → `baton` (Rust library, compiled to C++) → - `xplane_plugin/`: X-Plane plugin, built with Meson. `baton` lives in `xplane_plugin/subprojects/baton`. - `relay/`: Rust relay with a GUI. - `src/server/`: mock iMotions TCP server for testing without iMotions. -- `inference/`: logging, labeling, training. See `inference/README.md`. +- `inference/`: logging, pilot performance groups, and an out-of-scope event classification pipeline. One package, `inference/pilot_inference/`. See `inference/README.md`. ## Build and test @@ -18,14 +18,14 @@ Run from the repo root, in order, per component: - Plugin (also builds baton): `cd xplane_plugin && meson setup build && meson compile -C build && meson test -C build` - Relay: `cd relay && cargo test` - Baton: `cd xplane_plugin/subprojects/baton && cargo test` -- Inference: `cd inference && uv sync`, then `uv run python